11.14/11.15 Apache和PHP结合 11.16/11.17 Apache默认虚拟主机
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了11.14/11.15 Apache和PHP结合 11.16/11.17 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
11.16/11.17 Apache默认虚拟主机
一台服务器可以访问多个网站,每个网站都是一个虚拟主机
概念:域名(主机名)、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默认虚拟主机的主要内容,如果未能解决你的问题,请参考以下文章
11.14/11.15 Apache和PHP结合 11.16/11.17 Apache默认虚拟主机
11.14/11.15 Apache和PHP结合 11.16/11.17 Apache默认虚拟主机
11.14/11.15 Apache和PHP结合 11.16/11.17 Apache默认虚拟主机