gpt4 book ai didi

macos - 在 mac os Sierra 上设置 apache Web 服务器(macbook pro 13 2014)

转载 作者:行者123 更新时间:2023-12-04 22:57:25 25 4
gpt4 key购买 nike

http://digitalshore.io/local-web-development-environment-apache-macos-sierra-10-12这是我用来设置 apache 服务器的指南。
我做了所有必要的事情,但我无法运行这个命令
$ sudo cp httpd-userdir.conf httpd-userdir.conf.bak
终端的回答是“拒绝访问”
所以,我决定不制作备份文件。当我完成这个过程时,我在浏览器中输入了这个http://localhost/~username ,其中 username 是我的实际用户名。
并得到了这个回应

Forbidden

You don't have permission to access /~username on this server.



我跑了 apachectl configtest .得到了这个:

Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not existAH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not existAH00557: httpd: apr_sockaddr_info_get() failed for MacBook-Pro-Tim.localAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message Syntax OK


我该怎么办?

最佳答案

试试 http://localhost/directory/其中 directory 是您站点文件夹中的一个文件夹。出于某种原因,在 Seirra 之前,这对我和 http://localhost/~username/directory 有用没有(很可能是我配置它的方式,不太记得我是怎么做的,以防万一)。

如果两者都不起作用,请在终端中尝试以下操作。

sudo nano /etc/apache2/users/username.conf;

在文件中添加这个。
旁注:下面和此答案中其他任何地方的用户名应该是您的机器用户名。
<Directory "/Users/username/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>

保存更改。然后 sudo chmod 644 username.conf
下一个: sudo nano /etc/apache2/httpd.conf取消对以下几行的注释(即,如果每行有一行,则删除其前面的 #)
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule include_module libexec/apache2/mod_include.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
Include /private/etc/apache2/extra/httpd-userdir.conf

然后 sudo nano /etc/apache2/extra/httpd-userdir.conf并取消注释该行 Include /private/etc/apache2/users/*.conf保存并重启apache。 sudo apachectl restart http://localhost/~username/然后应该可以访问。我刚刚完成了这些步骤,它对我有用。

引用: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/

关于macos - 在 mac os Sierra 上设置 apache Web 服务器(macbook pro 13 2014),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39757902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com