一、LAMP實現過程
1.rpm包安裝實現
LAMP部署(php-fpm模式)
2.自定義編譯實現
LAMP——最新版組合(CGI)
二、虛擬主機實現
1.httpd的主站點目錄創建(服務器A)
cd /app/httpd24/htdocs
mkdir 1.com
mkdir 2.com
2.php服務中php程序所在目錄創建(服務器B)
cd /app/php/var/run
mkdir 1.com
vim 2.com/index.php
mkdir 2.com
vim 2.com/index.php
3.在mysql服務器創建對應數據庫和用戶(服務器C)
grant all on php1.* to php1@'%' identified by 'centos';
grant all on php2.* to php2@'%' identified by 'centos';
4.取消httpd服務配置文件對vhost.conf的註釋
/etc/httpd24/httpd.conf
取消下面行的註釋
Include /etc/httpd24/extra/httpd-vhosts.conf
5.修改vhost.conf文件
<VirtualHost *:80>
<Directory /app/httpd24/htdocs/1.com>
Require all granted
</Directory>
DocumentRoot "/app/httpd24/htdocs/1.com"
ServerName www.1.com
ErrorLog "/app/httpd24/logs/1.com/error_log"
CustomLog "/app/httpd24/logs/1.com/access_log" common
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://172.17.17.173:9000/app/php/var/run/1.com/$1
</VirtualHost>
<VirtualHost *:80>
<Directory /app/httpd24/htdocs/2.com>
Require all granted
</Directory>
DocumentRoot "/app/httpd24/htdocs/2.com"
ServerName www.2.com
ErrorLog "/app/httpd24/logs/2.com/error_log"
CustomLog "/app/httpd24/logs/2.com/access_log" common
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://172.17.17.173:9000/app/php/var/run/2.com/$1
</VirtualHost>
三、測試
1.修改測試機hosts文件
vim /etc/hosts
添加下行
172.17.16.173 www.1.com www.2.com