是否需要停止 Apache 来编辑“/etc/apache2/sites-available/default”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2473515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does Apache need to be stopped to edit "/etc/apache2/sites-available/default"?
提问by webworm
I am attempting to edit the "default" file located at ..
我正在尝试编辑位于 .. 的“默认”文件。
"/etc/apache2/sites-available/default"
on my Ubuntu machine running Apache 2.2.8.
在我运行 Apache 2.2.8 的 Ubuntu 机器上。
I want to do this in order to enable the use of .htaccess files. I have downloaded the "default" file and edited it and now I am trying to upload it back to the server via SFTP. I keep getting permission denied errors.
我想这样做是为了能够使用 .htaccess 文件。我已经下载了“默认”文件并对其进行了编辑,现在我正在尝试通过 SFTP 将其上传回服务器。我不断收到许可被拒绝的错误。
Could it be because Apache is running and making use of the file? I am an admin on the machine so I would expect to be able to overwrite the file. Thanks for any assistance.
可能是因为 Apache 正在运行并正在使用该文件?我是机器上的管理员,所以我希望能够覆盖文件。感谢您的任何帮助。
回答by Daniel Vassallo
No it does not need to be stopped.
不,它不需要停止。
Try accessing the file through ssh, and make sure you access it with root privileges:
尝试通过 访问该文件ssh,并确保您使用 root 权限访问它:
sudo nano /etc/apache2/sites-available/default
You would still need to force-reloadApache after changing the config files, as tux21b suggested in a comment below:
force-reload正如 tux21b 在下面的评论中所建议的那样,更改配置文件后您仍然需要使用Apache:
sudo /etc/init.d/apache2 force-reload
回答by user3836879
For Apache/2.4.7 , the file that you want to edit is:
对于 Apache/2.4.7 ,您要编辑的文件是:
/etc/apache2/apache2.conf

