apache 站点可用文件的哪些部分是必需的?

发布于 2024-11-15 21:01:55 字数 288 浏览 2 评论 0 原文

我注意到默认的站点可用文件(/etc/apache2/sites-available/default)包含许多带有各种选项的“目录”标签。

<目录/><目录/var/www/><目录“/usr/lib/cgi-bin”>

我是否需要其中任何一个,或者我可以安全地删除它们吗?

I noticed that the default sites-available file (/etc/apache2/sites-available/default) contained many "directory" tags with various options.

<Directory />, <Directory /var/www/>, <Directory "/usr/lib/cgi-bin">, and <Directory "/usr/share/doc/">

Do I need any of those, or can I safely remove them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丶情人眼里出诗心の 2024-11-22 21:01:55

不要开始调整默认站点,它只会变得一团糟,而且您将无法弄清楚哪个指令是做什么的。
我建议您编写自己的虚拟主机配置,这样您实际上知道您的网站确实如此。这里有一些简单的配置可以帮助您入门。

<VirtualHost *:80>
    ServerName www.mywebsite.com
    DocumentRoot /home/www/public_html/
    <Directory /home/www/public_html/>
        Options None
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

只需将其放入 sites-available 中,然后运行 ​​a2ensite mywebsitemywebsite 是虚拟主机配置的文件名),然后使用以下命令重新加载服务器配置/etc/init.d/apache2 重新加载
我使用的所有指令的解释可以在 apache 文档 中找到(我假设您运行版本 2.2)。

哦,当然,如果 ServerName 发生冲突,您需要禁用默认站点 (a2dissite default)。

Don't start adjusting the default site, it will just become a mess and you won't be able to figure out what directive does what.
I would recommend you write your own virtual host configuration, this way you actually know what your site does. Here is a little bare bones configuration to get you started.

<VirtualHost *:80>
    ServerName www.mywebsite.com
    DocumentRoot /home/www/public_html/
    <Directory /home/www/public_html/>
        Options None
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

Just put it in sites-available and then run a2ensite mywebsite (mywebsite being the filename of the vhost configuration), then reload the server configuration with /etc/init.d/apache2 reload.
An explanation for all the directives I used can be found in the apache documentation (I am assuming you run version 2.2).

Oh, and of course you need to disable the default site (a2dissite default) if the ServerNames are conflicting.

秋千易 2024-11-22 21:01:55

我说得再好不过了。我也一直在努力解决这个问题,这就是正确的。您还可以使用 service apache2 restartservice apache2 reload 而不是 /etc/init.d/apache2 reload。它做同样的事情,并且可能更容易记住,尽管我认为某些设置需要上述内容。
毫无疑问,Apache 是一个棘手的设置。我刚刚开始使用 Ubuntu 13.04,他们有一本非常棒的手册,可以帮助您完成整个设置、不同的选项等,但同样,上面的内容是正确的。
祝你好运,坚持下去。它会变得更容易并开始有意义。
该手册位于:https://help.ubuntu.com/13.04/serverguide/serverguide。 pdf

更新:这是我使用的另一个。

<VirtualHost xx.xxx.xxx.xx:80>
     ServerAdmin [email protected]
     ServerName domain.com
     ServerAlias www.domain.com
     DocumentRoot /var/www/domain.com/html/drupal
     ErrorLog /var/www/domain.com/logs/error.log
     CustomLog /var/www/domain.com/logs/access.log combined
</VirtualHost>

I couldn't have said that better. I have been struggling with this too and this is right on. You can also use service apache2 restart and service apache2 reload instead of /etc/init.d/apache2 reload. It does the same thing and may be easier to remember although I think some setups need the above.
Apache is a tricky setup, no doubt. I just started using Ubuntu 13.04 and they have a really great manual that will help you on the entire setup, different options, etc but again, the above is spot on.
Good luck and just keep at it. It will get easier and start to make sense.
The manual is here: https://help.ubuntu.com/13.04/serverguide/serverguide.pdf

Update: this is another one I use.

<VirtualHost xx.xxx.xxx.xx:80>
     ServerAdmin [email protected]
     ServerName domain.com
     ServerAlias www.domain.com
     DocumentRoot /var/www/domain.com/html/drupal
     ErrorLog /var/www/domain.com/logs/error.log
     CustomLog /var/www/domain.com/logs/access.log combined
</VirtualHost>
吝吻 2024-11-22 21:01:55

<虚拟主机 *:80>
服务器名称 www.mywebsite.com
文档根目录 /home/www/public_html/
<目录/home/www/public_html/>>
选项 无
订单拒绝、允许
允许所有

               Note ----> here instead of "None"  Used "all"

<VirtualHost *:80>
ServerName www.mywebsite.com
DocumentRoot /home/www/public_html/
<Directory /home/www/public_html/>
Options None
Order deny,allow
Allow from all

               Note ----> here instead of "None"  Used "all"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文