在 CentOS 上,Apache(通常叫 httpd)的配置文件位置和修改方式取决于你用的是 CentOS 7/8 还是 CentOS Stream,以及 Apache 的安装方式(系统自带或编译安装)。下面是最常见情况(系统自带 Apache)。
/etc/httpd/conf/httpd.conf
这是 最核心的配置文件,绝大多数全局设置都在这里改。
/etc/httpd/conf.d/
一般建议:
/etc/httpd/conf.d/example.conf/etc/httpd/conf.modules.d/
vi /etc/httpd/conf/httpd.conf
或
vi /etc/httpd/conf.d/你的站点.conf
httpd -t
或
apachectl configtest
看到:
Syntax OK
才可以重启。
systemctl restart httpd
开机自启(如未设置):
systemctl enable httpd
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
AllowOverride All
</Directory>
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/example
<Directory /var/www/example>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
which httpd
或
rpm -ql httpd | grep conf
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
如果你能告诉我:
我可以直接给你精准配置示例。