LAMP-(FCGI)-实现虚拟主机
程序员文章站
2022-07-14 23:29:21
...
一、LAMP实现过程
1.rpm包安装实现
2.自定义编译实现
二、虚拟主机实现
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 [email protected]'%' identified by 'centos';
grant all on php2.* to [email protected]'%' 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