标签:Apache默认虚拟主机
11.14/11.15 Apache和PHP结合httpd主配置文件/usr/local/apache2.4/conf/httpd.conf
vim /usr/local/apache2.4/conf/httpd.conf //修改以下4个地方
ServerName
Require all denied
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/usr/local/apache2.4/bin/apachectl -t //测试语法
/usr/local/apache2.4/bin/apachectl graceful //重新加载
/usr/local/apache2.4/bin/apachectl start //启动服务
netstat -lntp
curl localhost
vim /usr/local/apache2.4/htdocs/test.php //增加如下内容
<?php
echo 123;
?>
curl localhost/test.php
/usr/local/php7/bin/php -i |less
一台服务器可以访问多个网站,每个网站都是一个虚拟主机
概念:域名(主机名)、DNS、解析域名、hosts
任何一个域名解析到这台机器,都可以访问的虚拟主机就是默认虚拟主机
vim /usr/local/apache2.4/conf/httpd.conf //搜索httpd-vhost,去掉#
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf //改为如下
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/martin.com"
ServerName martin.com
ServerAlias www.martin.com www.abc.com
ErrorLog "logs/martin.com-error_log"
CustomLog "logs/martin.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/lgx168.com"
ServerName lgx168.com
ServerAlias www.lgx168.com www.1234.com
ErrorLog "logs/lgx168.com-error_log"
CustomLog "logs/lgx168.com-access_log" common
</VirtualHost>
/usr/local/apache2.4/bin/apachectl –t
/usr/local/apache2.4/bin/apachectl graceful
11.14/11.15 Apache和PHP结合 11.16/11.17 Apache默认虚拟主机
标签:Apache默认虚拟主机
原文地址:http://blog.51cto.com/12058686/2082895