在 CentOS 上,Apache(通常叫 httpd)的配置文件位置如下:
/etc/httpd/conf/httpd.conf
这是 Apache 的主配置文件,几乎所有全局配置都在这里。
/etc/httpd/conf.d/
*.conf 文件会被自动加载php.conf、ssl.conf)/etc/httpd/conf.modules.d/
.so)默认网站目录:
/var/www/html
可在 httpd.conf 中通过 DocumentRoot 修改。
/var/log/httpd/
access_log:访问日志error_log:错误日志# 启动
systemctl start httpd
# 停止
systemctl stop httpd
# 重启
systemctl restart httpd
# 开机自启
systemctl enable httpd
# 检查配置是否正确
httpd -t
在 /etc/httpd/conf.d/ 下新建:
vim /etc/httpd/conf.d/example.conf
内容示例:
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/example
<Directory /var/www/example>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
如果你用的是 CentOS 8 + nginx/apache 组合,或 CentOS Stream,配置位置基本一致。需要我帮你具体改某个配置也可以说。