• 安装apache
yum install -y httpd

#启动
systemctl start httpd
systemctl enable httpd
  • 配置站点
    /etc/httpd/conf/httpd.conf
<Directory />
    AllowOverride None
    Options  FollowSymLinks     #禁止目录 浏览
    Options Indexes FollowSymLinks
</Directory>

#设置index.php 为首页
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
  • 添加新网站
    /etc/httpd/conf.d/*.conf
<VirtualHost *:80>
    DocumentRoot /web/xxxx/
    ServerName www.xxxx.cn
    #ServerAlias www.xxxx.cn 
</VirtualHost>
  • 设置网站目录权限
chmod o+x  /web/
  • 禁止显示php版本的信息 /etc/php.ini
expose_php=Off
  • 禁止IP直接访问,防止恶意解析/etc/httpd/conf.d/default.conf
<VirtualHost *:80>
    <Location/>
    Order Allow,Deny 
    Deny from all
    </Location>
</VirtualHost>