CentOS 7 LAMP + xcache (php-fpm Mode)
CentOS 7 deploy separate LAMP + xcache (php-fpm) through the RPM package)
Requirements:
Run the rpm package to deploy LAMP and separate the LAMP environment.
(1) a vm provides wordpress
One VM provides phpMyadmin
(2) Use xcache to accelerate the page speed
Environment:
Three hosts are separated to provide different services:
192.168.1.104 -------> httpd service
192.168.1.110 -------> Provide mariadb-server Service
192.168.1.113 -------> provides the php-fpm php-mysql xcache Service
1. Deploy the httpd service on the 192.168.1.104 Server:
1. Install the httpd service program
[Root @ bogon ~] # Yum-y install httpd
[Root @ bogon ~] # Vim/etc/httpd/conf/httpd. conf
ServerNAme localhost: 80 # It is too slow to start if the server name cannot be resolved.
2. Create a VM
[Root @ bogon ~] # Vim/etc/httpd/conf. d/vhosts1.conf
DirectoryIndex index. php
<VirtualHost 192.168.1.104: 80>
ServerNAme wp.bkjia.com
DocumentRoot/data/vhosts/www1
ProxyRequests off
ProxyPassMatch ^/(. * \. php) $ fcgi: // 192.168.1.113: 9000/data/vhosts/www1/$1
#### Indicates that files starting with. php are transmitted to php-fpm for processing. The address here is the php server address.
<Directory "/data/vhosts/www1">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
[Root @ bogon ~] # Vim/etc/httpd/conf. d/vhosts2.conf
DirectoryIndex index. php
<VirtualHost 192.168.1.104: 80>
ServerNAme pam.bkjia.com
DocumentRoot/data/vhosts/www2
ProxyRequests off
ProxyPassMatch ^/(. * \. php) $ fcgi: // 192.168.1.113: 9000/data/vhosts/www2/$1
<Directory "/data/vhosts/www2">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
3. Create webpages and related paths
[Root @ bogon ~] # Mkdir-p/data/vhosts/www1
[Root @ bogon ~] # Mkdir-p/data/vhosts/www2
[Root @ bogon ~] # Echo "vhosts111">/data/vhosts/www1/index.html
[Root @ bogon ~] # Echo "vhosts222">/data/vhosts/www2/index.html
4. Start the service and test whether the VM is normal.
[Root @ bogon www1] # curl http://wp.bkjia.com
Vhosts111
[Root @ bogon www1] # curl http://pam.bkjia.com
Vhosts222
2. Deploy and install php-fpm on 192.168.1.113 Server
1. Install the php-fpm php-mysql php-mbstring Program
123 [root @ pxe132 ~] # Rpm-q php ### make sure there are no php programs in the past. If this happens, uninstall the programs if they do not meet your requirements.
Package php is not installed
[Root @ pxe132 ~] # Yum-y install php-fpm php-mysql php-mbstring
2, edit/etc/php-fpm.d/www. conf
1234 [root @ pxe132 ~] # Vim/etc/php-fpm.d/
Listen = 192.168.1.113: 9000 ### set the php server listening address, that is, the local address that can communicate with the external address.
Listen. allowed_clients = 192.168.1.104 ### listen to IP addresses with httpd services
3. Create the following file and start the php-fpm service. Check whether the file has been listened.
[Root @ pxe132 ~] # Mkdir/var/lib/php/session
[Root @ pxe132 ~] # Chown apache. apache/var/lib/php/session/
[Root @ pxe132 ~] # Ls-ld/var/lib/php/session/
Drwxr-xr-x 2 apache 6 Jul 18 20:37/var/lib/php/session/
[Root @ pxe132 ~] # Systemctl start php-fpm.service
[Root @ pxe132 ~] # Ss-tnl
State Recv-Q Send-Q Local Address: Port
LISTEN 0 128 192.168.1.113: 9000 #### php address monitored
LISTEN 0 128 *: 22
LISTEN 0 128 127.0.0.1: 631
LISTEN 0 100 127.0.0.1: 25
LISTEN 0 128 127.0.0.1: 6010
LISTEN 0 128: 1: 631
LISTEN 0 100: 1: 25
LISTEN 0 128: 1: 6010
4. Create a DocumentRoot path on the php server and the http server, and write a php test to check whether the file can be connected to the http server.
[Root @ pxe132 ~] # Mkdir-p/data/vhosts/www1/
[Root @ pxe132 ~] # Mkdir-p/data/vhosts/www2/
[Root @ bogon ~] # Vim/data/vhosts/www2/index. php ### test the connection between php and httpd in VM 2
This is vhost2
<? Php
Phpinfo ();
?>
[Root @ bogon ~] # Vim/data/vhosts/www1/index. php ### test the connection between php and httpd in VM 1
This is vhost1
<? Php
Phpinfo ();
?>
5. Load the Service Access Site and test whether the connection between php and httpd is normal.
OK! This proves that the connection between the php server and the http server is successful!
You may also like the following LAMP-related content:
Install Xcache and Memcached on the LAMP platform to accelerate website operation
Build a LAMP platform environment in CentOS 7
CentOS 6.5 system installation and configuration LAMP (Apache + PHP5 + MySQL) server environment
Configure the LAMP + phpMyAdmin PHP (5.5.9) development environment in Ubuntu 14.04
Install LAMP in Ubuntu 14.10
LAMP combines NFS to build a small blog site
Install and deploy the LAMP environment under CentOS7
For more details, please continue to read the highlights on the next page: