LAMP web site construction (1)

Source: Internet
Author: User

Build LAMP

A complete LAMP web architecture consists of linux + http + mysql + php.

I. Compile and install apache, use the httpd-2.4.6 version

1. Prepare the compilation and installation environment to resolve dependencies;

[root@localhost ~]# yum gruoplist[root@localhost ~]# yum gruopinstall "Development tools" "Server Platfrom Development"

2. Download and build the httpd software packages, apr, apr-util, and httpd;

[root@localhost ~]# lftp 172.16.0.1lftp 172.16.0.1:~> cd pub/Sources/sources/httpd/lftp 172.16.0.1:/pub/Sources/sources/httpd> ls.......lftp 172.16.0.1:/pub/Sources/sources/httpd> mget apr-1.4.6.tar.bz2 apr-util-1.5.2.tar.bz2 httpd-2.4.6.tar.bz26428879 bytes transferred                             Total 3 files transferred


[root@localhost ~]# lsanaconda-ks.cfg    apr-util-1.5.2.tar.bz2  install.logapr-1.4.6.tar.bz2  httpd-2.4.6.tar.bz2     install.log.syslog

3. Compile and install apr;

[root@localhost ~]# tar xf apr-1.4.6.tar.bz2[root@localhost ~]# cd apr-1.4.6[root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr[root@localhost apr-1.4.6]# make && make install

4. Compile and install apr-util;

[root@localhost ~]# tar xf apr-util-1.5.2.tar.bz2[root@localhost ~]# cd apr-util-1.5.2[root@localhost apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr[root@localhost apr-util-1.5.2]# make && make install

5. Compile and install httpd;

L

[root@localhost ~]# tar xf httpd-2.4.6.tar.bz2[root@localhost ~]# cd httpd-2.4.6[root@localhost httpd-2.4.6]# yum -y install pcre-devel[root@localhost httpd-2.4.6]# yum -y install openssl-devel[root@localhost httpd-2.4.6]# ./configure --prefix=/usr/local/apache  --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event[root@localhost httpd-2.4.6]# make && make install

6. Provide the httpd Sysv service script, modify the httpd configuration file, and set the path of the pid file;

[root@localhost httpd-2.4.6]# cp build/rpm/httpd.init /etc/rc.d/init.d/httpdcp: overwrite `/etc/rc.d/init.d/httpd'? y[root@localhost httpd-2.4.6]# vim /etc/rc.d/init.d/httpdprog=httpdhttpd=${HTTPD-/usr/local/apache/bin/httpd}pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}lockfile=${LOCKFILE-/var/lock/subsys/${prog}}RETVAL=0# check for 1.3 configurationcheck13 () {        CONFFILE=/usr/local/apache/conf/httpd.conf


[root@localhost httpd-2.4.6]# vim /usr/local/apache/conf/httpd.conf ServerName 172.16.20.5:80

7. Add environment variables for the httpd service;

[root@localhost ~]# echo "PATH=/usr/local/apache/bin/:$PATH" > /etc/profile.d/httpd.sh[root@localhost ~]# source /etc/profile.d/httpd.sh

8. Add the httpd service to the list and start it.

[root@localhost ~]# chkconfig --add httpd[root@localhost ~]# chkconfig httpd on[root@localhost ~]# chkconfig --list httpdhttpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off[root@localhost ~]# service httpd startStarting httpd:                                            [  OK  ]

2. Compile and install mysql and use mysql-5.5.28

1. Prepare a compilation and installation environment, create a file system for data storage, and download and decompress the mysql Binary Package;

[root@localhost ~]# mkdir -pv /mysql/mydatamkdir: created directory `/mysql'mkdir: created directory `/mysql/mydata'[root@localhost ~]# lftp 172.16.0.1lftp 172.16.0.1:~> cd pub/Sources/6.x86_64/mysql/lftp 172.16.0.1:/pub/Sources/6.x86_64/mysql> ls-rw-r--r--    1 0        0        186839926 Aug 22 04:37 mysql-5.5.33-linux2.6-x86_64.tar.gz-rw-r--r--    1 0        0        307062424 Aug 22 05:15 mysql-5.6.13-linux-glibc2.5-x86_64.tar.gzlftp 172.16.0.1:/pub/Sources/6.x86_64/mysql> get mysql-5.5.33-linux2.6-x86_64.tar.gz186839926 bytes transferred in 21 seconds (8.31M/s)


[root@localhost ~]# tar  xf mysql-5.5.33-linux2.6-x86_64.tar.gz  -C /usr/local/[root@localhost ~]# cd /usr/local/[root@localhost local]# lsapache  apr-util  etc    include  lib64    mysql-5.5.33-linux2.6-x86_64  shareapr     bin       games  lib      libexec  sbin                          src[root@localhost local]# ln -sv mysql-5.5.33-linux2.6-x86_64/ mysql`mysql' -> `mysql-5.5.33-linux2.6-x86_64/'[root@localhost local]# cd mysql[root@localhost mysql]# lsbin      data  include         lib  mysql-test  scripts  sql-benchCOPYING  docs  INSTALL-BINARY  man  README      share    support-files

2. Create a mysql user and run it securely;

[root@localhost mysql]# chown -R mysql:mysql *[root@localhost mysql]# lltotal 200drwxr-xr-x  2 mysql mysql   4096 Sep 11 22:32 bin-rw-r--r--  1 mysql mysql  17987 Jul 15 20:01 COPYINGdrwxr-xr-x  3 mysql mysql   4096 Sep 11 22:33 datadrwxr-xr-x  2 mysql mysql   4096 Sep 11 22:32 docsdrwxr-xr-x  3 mysql mysql   4096 Sep 11 22:33 include-rw-r--r--  1 mysql mysql 134493 Jul 15 20:01 INSTALL-BINARYdrwxr-xr-x  3 mysql mysql   4096 Sep 11 22:33 libdrwxr-xr-x  4 mysql mysql   4096 Sep 11 22:33 mandrwxr-xr-x 10 mysql mysql   4096 Sep 11 22:33 mysql-test-rw-r--r--  1 mysql mysql   2496 Jul 15 20:01 READMEdrwxr-xr-x  2 mysql mysql   4096 Sep 11 22:33 scriptsdrwxr-xr-x 27 mysql mysql   4096 Sep 11 22:33 sharedrwxr-xr-x  4 mysql mysql   4096 Sep 11 22:33 sql-benchdrwxr-xr-x  3 mysql mysql   4096 Sep 11 22:33 support-files[root@localhost ~]# useradd mysql[root@localhost ~]# chown -R mysql:mysql /mysql/mydata[root@localhost ~]# chmod -R 755 /mysql/mydata/

3. Compile and install mysql and initialize it;

[root@localhost mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/mydata

4. Add environment variables for the mysql service;

[root@localhost mysql]# echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysqld.sh[root@localhost mysql]# source /etc/profile.d/mysqld.sh


5. Provide the master configuration file for the mysql service;

[root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnfcp: overwrite `/etc/my.cnf'? y[root@localhost mysql]# vim /etc/my.cnf# Try number of CPU's*2 for thread_concurrencythread_concurrency = 4datadir = /mysql/mydata

6. Provide Sysv service scripts for mysql services;

[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

7. Assign the service script, add the service to the List, and start the mysql service.

[root@localhost mysql]# chmod +x /etc/rc.d/init.d/mysqld[root@localhost mysql]# chkconfig --add mysqld[root@localhost mysql]# chkconfig mysqld on[root@localhost mysql]# chkconfig --list mysqldmysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off[root@localhost mysql]# service mysqld startStarting MySQL..                                           [  OK  ]

3. Compile and install php-fpm and use php 5.4.19

1. Based on the development and compilation environment, additional relationships need to be resolved;

[root@localhost ~]# yum -y install libxml2-devel curl-devel bzip2-devel libmcrypt libmcrypt-devel

2. Download and compile and install php;

[root@localhost ~]# lftp 172.16.0.1lftp 172.16.0.1:/pub/Sources/sources/php> mget php* xcache-3.0.3.tar.bz2[root@localhost ~]# tar xf php-5.4.19.tar.bz2[root@localhost ~]# cd php-5.4.19[root@localhost php-5.4.19]# ./configure --prefix=/usr/local/php  --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl  --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml  --with-mhash --with-mcrypt  --with-config-file-path=/etc  --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl --enable-maintainer-zts --enable-fpm[root@localhost php-5.4.19]# make and make install

3. Provide the main configuration file for the php service;

[root@localhost php-5.4.19]# cp php.ini-production /etc/php.ini[root@localhost php-5.4.19]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm[root@localhost php-5.4.19]# cd /etc/rc.d/init.d/[root@localhost init.d]# cp init.d.php-fpm php-fpm[root@localhost php-5.4.19]# cd /usr/local/php/etc/[root@localhost etc]# cp  php-fpm.conf.default php-fpm.conf[root@localhost etc]# vim php-fpm.conflisten = 172.16.20.5:9000

4. Add environment variables for the php Service

[root@localhost php-5.4.19]#  echo "PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH" >/etc/profile.d/php-fpm.sh[root@localhost php-5.4.19]# source /etc/profile.d/php-fpm.sh

5. Edit the main configuration file of apache to support php


[root@localhost ~]# vim /usr/local/apache/conf/httpd.confAddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps.............<IfModule dir_module>    DirectoryIndex index.html index.php</IfModule>

6. Add the php-fpm service to the list and start the php-fpm service;

[root@localhost ~]# chmod +x /etc/rc.d/init.d/php-fpm[root@localhost ~]# chkconfig --add php-fpm[root@localhost ~]# chkconfig php-fpm on[root@localhost ~]# chkconfig --list php-fpmphp-fpm         0:off   1:off   2:on    3:on    4:on    5:on    6:off[root@localhost ~]# service php-fpm startStarting php-fpm  done

7. Restart the httpd service, configure the relevant page files, and access the relevant web pages for testing.


This article is from the author's blog "broad Sky Summit one peice". For more information, contact the author!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.