本文介绍了在Mac OS Sierra上设置Apache Web服务器(Macbook Pro 13 2014)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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,其中用户名是我的实际用户名.并得到了回应

http://digitalshore.io/local-web-development-environment-apache-macos-sierra-10-12 This is the guide that i used to set up an apache server.I did everything that was necessary but i wasn't able to run this command$ sudo cp httpd-userdir.conf httpd-userdir.conf.bakAnswer from terminal was "Access denied"So, I decided not to make back-up files. When i completed the proccess, i entered this in the browser http://localhost/~username, where username was my actual username.And got this response

您无权访问此服务器上的/〜用户名.

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


我跑了apachectl configtest.并得到了:


I ran apachectl configtest. And got this:

我该怎么办?

推荐答案

尝试 http://localhost/directory/其中目录是文件夹在您的站点文件夹中.由于某种原因,在Seirra之前,这对我有用,而 http://localhost/〜username/directory 无效(很可能是我的方式配置好之后,就不太记得我是怎么做到的了,以防万一,请尝试一下.)

Try http://localhost/directory/ where directory is an folder in your sites folder. For some reason before Seirra this worked for me and http://localhost/~username/directory didn't (most likely the way I had it configured, don't quite remember how I did it, try them both just in case).

如果两种方法都不起作用,请在终端中尝试以下操作.

If both doesn't work, try the following in terminal.

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

将此添加到文件中.注意:下面的用户名以及此答案中的其他任何地方都应该是您的计算机的用户名.

Add this in the file.Side Note: username below and anywhere else in this answer should be your machines username.

<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取消注释以下几行(即,删除每行前面的#,如果有的话)

Next: sudo nano /etc/apache2/httpd.confUncomment the following lines (i.e. remove the # in front of each line if it has one)

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/.我只是完成了这些步骤,对我有用.

Then sudo nano /etc/apache2/extra/httpd-userdir.conf and uncomment the line Include /private/etc/apache2/users/*.confSave and restart apache. sudo apachectl restarthttp://localhost/~username/ should then be accessible. I just went through these steps and it worked for me.

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

这篇关于在Mac OS Sierra上设置Apache Web服务器(Macbook Pro 13 2014)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:55