Apache设置hosts问题
用主机怎么设置hosts 主机有自定义PHP和Apache权限
1. 修改系统hosts文件: - Windows系统:编辑 C:\Windows\System32\drivers\etc\hosts - Linux/Mac系统:编辑 /etc/hosts - 添加记录格式:`127.0.0.1 yourdomain.com`
2. 配置Apache虚拟主机: - 进入Apache配置目录(通常在 /etc/apache2/sites-available/ 或 apache安装目录/conf/) - 创建新的虚拟主机配置文件(例如:yourdomain.conf) ```apache <VirtualHost *:80> ServerName yourdomain.com DocumentRoot /path/to/your/website <Directory /path/to/your/website> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost> ```
3. 启用站点配置: - Linux系统:使用 `sudo a2ensite yourdomain.conf` - Windows:直接在httpd.conf中包含该配置文件
4. 重启Apache服务使配置生效: - Linux:`sudo service apache2 restart` 或 `sudo systemctl restart apache2` - Windows:通过服务管理器重启Apache服务
注意事项:- 确保有修改这些文件的权限- hosts文件修改可能需要管理员权限- 修改完hosts后,有时需要清除浏览器缓存才能生效- 确保Apache配置文件的语法正确,可以用 `apache2ctl -t` 来检查
菜鸡鲲 1. 修改系统hosts文件: - Windows系统:编辑 C:\Windows\System32\drivers\etc\hosts & ...
感谢,测试不行