LAMP: HTTP 2.4.25 + PHP 5.4.13 + MySQL 5.5.28 separate deployment of CentOS 6.6, 2.4.25centos
Environment Description:
- System: CentOS 6.6
- Deployment mode: Separate (three services are deployed on three Services)
- Version: HTTP 2.4.25 + PHP 5.4.13 + MySQL 5.5.28
- IP address planning: HTTP: 192.168.205.116 PHP: 192.168.205.117 MySQL: 192.168.205.115
Effect:
Httpd compilation and Installation
1) wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz
2) tar xf apr-1.5.2.tar.gz
3) cd apr-1.5.2
4)./configure
5) make & makeinstall
1) wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
2) cd apr-util-1.5.4
3) tar xf apr-util-1.5.4.tar.gz
4)./configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr/
5) make & makeinstall
1) yum install pcre-devel-y
2) yum install openssl-devel-y
3) wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.25.tar.bz2
4) cd httpd-2.4.25
5)./configure \
-- Prefix =/usr/local/httpd \
-- Sysconfdir =/etc/httpd \
-- Enable-so \
-- Enable-rewrite \
-- Enable-ssl -- enable-cgi \
-- Enable-cgid -- enable-modules = most \
-- Enable-mpms-shared = all \
-- With-apr =/usr/local/apr \
-- With-apr-util =/usr/local/apr-util \
-- With-ssl =/usr/local/openssl \
-- Enable-proxy \
-- Enable-proxy-fcgi
6) make & make install
1) getenforce
2) setenforce 0
3) vim/etc/selinux/config
4) getenforce
5) iptables-F
1) vim/etc/httpd. conf
2) Add PidFile "/var/run/httpd. pid": Modify the pid process file location.
1)/usr/local/httpd/apachectl start
2) netstat-tnlp
1) vim/etc/init. d/httpd
. /etc/rc.d/init.d/functions #chkconfig: 2345 10 90 # # pull in sysconfig settings [ -f /etc/sysconfig/httpd ] && . /etc/sysconfig/httpd HTTPD_LANG=${HTTPD_LANG-"C"} INITLOG_ARGS="" #apachectl=/usr/local/apache/bin/apachctl #httpd=${HTTPD-/usr/local/apache/bin/httpd} httpd=${HTTPD-/usr/local/httpd/bin/apachectl} prog=httpd pidfile=${PIDFILE-/var/run/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 start() { echo -n $"Starting $prog: " LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d 10 $httpd RETVAL=$? # if we are in halt or reboot runlevel kill all running sessions # so the TCP connections are closed cleanly echo [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then RETVAL=$? echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else killproc -p ${pidfile} $httpd -HUP RETVAL=$? fi echo } restart() { stop start } case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) restart ;; condrestart) if [ -f ${pidfile} ]; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1 esac exit $RETVAL
Httpd
2) Add execution permission
A) chmod + x/etc/init. d/httpd
3) Add to the startup service list
A) chkconfig -- add httpd
B) chkconfig -- list httpd
C) chkconfig -- level 35 httpd on
4) handle error messages
A) vim/etc/httpd. conf
ServerName localhost: 80
A) vim/etc/profile. d/httpd. sh
A) export PATH = $ PATH:/usr/local/httpd/bin/
B) Make sure that the httpd-t takes effect and you need to log out and log on again.
MySQL binary Installation
1) wget https://downloads.mysql.com/archives/get/file/mysql-5.5.28-linux2.6-i686.tar.gz
Ii. decompress the package to the specified directory
1) tar xf mysql-5.5.28-linux2.6-i686.tar.gz-C/usr/local/
Iii. Switch to this directory
1) cd/usr/local/
Iv. Link
1) ln-sv mysql-5.5.28-linux2.6-i686/mysql
V. Add a user and modify the owner and group
1) groupadd-r-g 306 mysql
2) useradd-g 306-r-u 306 mysql
3) chown-R root. mysql/usr/local/mysql /*
Vi. Create a logical volume
1) fdisk/dev/sdb
2) pvcreate/dev/sdb5
3) vgcreate myvg/dev/sdb5
4) lvcreate-n mydata-L 5G myvg
5) lvs
6) mke2fs-j/dev/myvg/mydata
Vii. Store database data to logical volumes
1) mkdir/mydata/
2) mount/dev/myvg/mydata/
Viii. Modify the/etc/fstab file
1)/dev/myvg/mydata ext3 defaults 0 0
2) mount-
Ix. modify data storage folder Permissions
1) chown-R mysql. mysql data/
2) chmod o-x/mydata/data/
1) yum install-y libaio: the solution that indicates an error during initialization
2) cd/user/local/mysql
3) scripts/mysql_install_db -- user = mysql -- datadir =/mydata/data/
4) chown-R root/usr/local/mysql /*
Xi. Modify the Startup File
1) cp support-files/mysql. server/etc/init. d/mysqld
Xii. Add boot start
1) chkconfig -- add mysqld
2) chkconfig -- list mysqld
1) cp/usr/local/mysql-5.5.28-linux2.6-i686/support-files/my-huge.cnf/etc/my. cnf
2) vim/etc/my. cnf
A) datadir =/mydata/data/mysql
B) thread_concurrency = 8
C) One cpu in mysql provides two threads.
I) Check the number of CPUs in the current system: cat/proc/cpuinfo
Ii) so there can be a maximum of 2 threads, and the thread is changed to 2.
1) vim/etc/profile. d/mysqld. sh
A) export PATH = $ PATH:/usr/local/mysql/bin
2) log out and log on again
1) service mysqld start
Mysql-u root mysql
Mysql> use mysql;
Mysql> desc user;
Mysql> grant all privileges on *. * TO root @ "%" identified by "william"; // Add the remote connection capability TO the root user.
Mysql> update user set Password = password ('xxxxxx') where User = 'root ';
Mysql> select Host, User, Password from user where User = 'root ';
Mysql> flush privileges;
Mysql> exit
Log On again: mysql-u root-p
PHP source code compilation and Installation
1) wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.6.tar.gz
2) tar xf libmcrypt-2.5.6.tar.gz
3) cd libmcrypt-2.5.6
A)./configure -- prefix =/usr/local/libmcrypt
Ii. wget http://museum.php.net/php5/php-5.4.13.tar.bz2
Iii. yum install gcc openssl-devel libxml2-devel bzip2-devel-y
Cd php-5.4.13
Iv. Compile and install
./Configure \
-- Prefix =/usr/local/php \
-- Enable-fpm \
-- With-config-file-path =/etc \
-- With-config-file-scan-dir =/etc/php. d \
-- With-libxml-dir =/usr \
-- With-openssl \
-- With-zlib \
With-bz2 \
-- With-jpeg-dir \
-- With-png-dir \
-- With-freetype-dir \
-- Enable-mbstring \
-- With-mcrypt \
-- Enable-sockets \
-- With-mysql = mysqlnd \
-- With-mysqli = mysqlnd \
-- With-pdo-mysql = mysqlnd \
-- Enable-maintainer-zts \
-- With-mcrypt =/usr/local/libmcrypt
1) make & make install
1) cp php. ini-production/etc/php. ini
2) provide the Sysv init script for php-fpm and add it to the service list.
A) cp sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm
B) chmod + x/etc/init. d/php-fpm
C) chkconfig -- add php-fpm
D) chkconfig -- list php-fpm
Vi. Modify httpd. conf
1) AddType application/x-httpd-php. php
2) AddType application/x-httpd-source. phps
Vii. Configure php-fpm
1) provide the Sysv init script for php-fpm and add it to the server list.
A) cp sapi/fpm/init. d. php-fpm/etc/rc. d/init. d/php-fpm
B) chmod + x/etc/rc. d/init. d/php-fpm
C) chkconfig -- add php-fpm
D) chkconfig php-fpm on
2) provide configuration files for php-fpm
A) cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
3) edit the configuration file of php-fpm.
A) vim/usr/local/php/etc/php-fpm.conf
B) Configure fpm-related options for the values you need and enable the pid File
I) pm. max_children = 50
Ii) pm. start_servers = 5
Iii) pm. min_spare_servers = 2
Iv) pm. max_spare_servers = 8
V) pid =/usr/local/php/var/run/php-fpm.pid
Viii. Start the service
1) service php-fpm start
2) netstat-tnlp
E. Connect to Apache
I. Modify the php-fpm file vim/usr/local/php/etc/php-fpm and locate listen = 192.9.205.117: 9000.
Ii. Create a virtual host directory on the host to store webpage files
Mkdir-pv/www/{glinux, gliuxstar}
Iii. Configure Apache Virtual Host to use php
1) on the httpd host, 192.9.205.116, create a directory as the Home Directory of the VM
A) mkdir-pv/www/{glinux, glinuxstar}
2) edit the master configuration file (disable the central host and enable the virtual host)
A) vim/etc/httpd. conf
One. Note # DocumentRoot "/usr/local/apache/htdocs"
Two. and enable Include/etc/httpd/extra/httpd-vhosts.conf
Three. Locate AddType at the same time; Add the following two rows
First. AddType application/x-httpd-php. php
Second. AddType application/x-httpd-php-source. phps
Four. And locate DirectoryIndex
First. <IfModule dir_module>
1. DirectoryIndex. php index.html # add index. php (preferably at the beginning)
Second. </IfModule>
Five. startup Module
First. also enable proxy_module proxy-fcgi_module and so on
Second. LoadModule proxy_module modules/mod_proxy.so # enable
Third. LoadModule proxy_connect_module modules/mod_proxy_connect.so
Fourth. LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
Th. LoadModule proxy_http_module modules/mod_proxy_http.so
Sixth. LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so # enable
3) edit a VM
<VirtualHost *: 80>
DocumentRoot "/www/glinux"
ServerName www.glinux.com
ServerAlias glinux.com
ErrorLog "/usr/local/httpd/logs/glinux. error_log"
CustomLog "/usr/local/httpd/logs/glinux. access_log" combined
ProxyRequests off
ProxyPassMatch ^/(. *. php) $ fcgi: // 192.9.205.117: 9000/www/glinux/$1
<Directory "/www/glinux">
Options none
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Iv. Create webpage files under the/www/glinux directory on the php server and restart the service.
1) phpinfo is successfully tested.
V. php supports the extension function xcache
1) wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
2) install xcache
A) tar xf xcache-3.2.0.tar.gz
B) cd xcache-3.2.0
C) install dependency
I) yum-y install m4 autoconf
D)/usr/local/php/bin/phpize
E)./configure -- enable-xcache -- with-php-config =/usr/local/php/bin/php-config
F) make & make install
3) after the installation is complete, such a line of Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20131226/
4) EDIT php. ini and integrate php and xcache:
A) First, import the sample configuration provided by xcache to php. ini.
I) # mkdir/etc/php. d
Ii) # cp xcache. ini/etc/php. d
Iii) Description: The xcache. ini file is in the xcache source code directory.
5) edit/etc/php. d/xcache. ini, find the line starting with extension, and change it to the following line:
A) extension =/usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache. so
B) Note: If the php. ini file contains multiple zend_extension command lines, make sure that the new lines are in the first place.
6) Then restart the service to view the xcache options on the phpinfo page.
7) disable the xcache Method
A) vim/etc/php. d/xcache. ini
I) xcache. size = 0: Set 0 to disable xcache
F. Integrate php
Go to mysql
Use mysql;
Grant all privileges on *. * to 'root' @ '192. 9.205.105 'identified by 'a ___ 100 ';
Select Host, User, Password from user where User = 'root ';
Flush privileges;
I. Go to the php host and edit the index. php file.
<? Php
$ Link = mysql_connect ('192. 168.197.205 ', 'root', 'frank ');
If ($ link ){
Echo "success... frank! ";
} Else {
Echo "failed... frank! ". Mysql_error ();
}
Mysql_close ($ link );
Phpinfo ();
?>
1) Remember to disable the firewall!
G. Deploy PHPmyAdmin
I. Configure phpmyadmin
1) create a folder named pma in the/www directory or any virtual host directory on the php host and http host respectively.
2) For example, in the directory/var/www/frank/pma on the php host
3) unzip phpMyAdmin-4.4.10-all-languages.zip
4) Music phpMyAdmin-4.4.10-all-languages /*./
5. The two hosts perform the same operation.
6) Configure phpmyadmin on the php host.
7) cp config. sample. inc. php config. inc. php
8) vim config. inc. php
A) mainly find
B) $ cfg ['servers'] [$ I] ['host'] = '198.197.205 'IP address of the Database Server
C) $ cfg ['blowfish _ secret'] = 'frank'; the characters here are random, mainly to distinguish cookies.
9) restart the services on the three hosts to test.