在Mac OS Sierra上设置Apache Web服务器(Macbook Pro 13 2014) [英] Setting up an apache web server on mac os Sierra (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.bak
Answer 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:
警告:DocumentRoot [/usr/docs/dummy-host.example.com]不存在 AH00112:警告:DocumentRoot [/usr/docs/dummy-host2.example.com]不存在 AH00557:对于MacBook Pro-Tim.local httpd:apr_sockaddr_info_get()失败 AH00558:httpd:无法使用127.0.0.1可靠地确定服务器的标准域名.全局设置"ServerName"指令以禁止显示此消息语法确定
Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist AH00557: httpd: apr_sockaddr_info_get() failed for MacBook-Pro-Tim.local AH00558: 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/其中目录是文件夹在您的站点文件夹中.由于某种原因,在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.conf
Uncomment 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/*.conf
Save and restart apache. sudo apachectl restart
http://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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!