本文主要是介绍LAMP-(FCGI)-实现虚拟主机,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、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.phpmkdir 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.comErrorLog "/app/httpd24/logs/1.com/error_log" CustomLog "/app/httpd24/logs/1.com/access_log" commonDirectoryIndex index.phpProxyRequests OffProxyPassMatch ^/(.*\.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.comErrorLog "/app/httpd24/logs/2.com/error_log"CustomLog "/app/httpd24/logs/2.com/access_log" commonDirectoryIndex index.phpProxyRequests OffProxyPassMatch ^/(.*\.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
这篇关于LAMP-(FCGI)-实现虚拟主机的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!