在CentOS 7上用Apache+PHP建立虚拟主机
默认的CentOS就自带了Apache,本篇主要是用系统自带的Apache来完成的 首先先新建一个配置文件 vim /etc/httpd/conf.d/site.conf 内容如下: <VirtualHost *:80> DocumentRoot /home/www ServerName siglud.com.cn <Directory /> Require all granted AllowOverride All DirectoryIndex index.php index.htm </Directory> </VirtualHost> 然后systemctl restart httpd 打开iptables的端口 iptables -I INPUT -p tcp --dport 80 -j ACCEPT /usr/libexec/iptables/iptables.init save 这个时候去访问大部分都会收到403了,原因在于selinux chcon -Rv --type=httpd_sys_content_t /home/www 如果这个时候报错 那么执行 chcon -R -h system_u:object_r:usr_t /home/www/ 之后再执行它就可以了