Jor*_*dan 31 apache macos apache2 apache2.4 osx-yosemite
我已经安装了干净的Mac OSX Yosemite,但我无法配置Apache 2.4,就像我一直在较旧的OSX版本上做的那样.
这是我想要做的:将"localhost"目录设置为"/ Users/username/Public /".但是,我尝试的一切都行不通,我总是得到一个"Forbiden,无法访问/"或者我得到默认的"它有效!" 页...
如何简单地重新连接我的本地主机?
谢谢
编辑(感谢Krister Andersson的答案)
适用于Mac OSX 10.10 Yosemite
我还发布了我必须做的改变以保持运行.
在"/ etc/apache2/users /"中,我创建了一个由我的用户名命名的文件,如"myUsername.conf".
您可以在终端输入"id"来获取用户名.您应该在"uid = 501(myUsername)"中找到您的用户名.
在这个新的"myUsername.conf"文件中,只需复制过去:
<Directory "/Users/myUsername/Sites/">
AllowOverride All
Options Indexes MultiViews
Options +FollowSymLinks
Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
不要原谅改变myUsername
价值.
然后,在"/etc/apache2/httpd.conf"文件中,取消注释所有这两行:
167 #LoadModule userdir_module libexec/apache2/mod_userdir.so
169 #LoadModule php5_module libexec/apache2/libphp5.so
Run Code Online (Sandbox Code Playgroud)
第236行,将"DocumentRoot"的目录更改为您想要的任何内容.第250行,将"选项"设置为"选项"选项索引FollowSymLinks Multiviews".第258行,将"AllowOverride None"设置为"AllowOverride All".第263行,将"Require all denied"设置为"Require all granted"
在终端中,键入"sudo apachectl restart"重新启动apache.
它适用于Mac OS X 10.10优胜美地清洁安装.
Cyc*_*ode 42
我刚刚安装了Yosemite,我设法改变了DocumentRoot
没有任何问题.首先,我修改了以下几行/private/etc/apache2/httpd.conf
:
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks Multiviews
AllowOverride None
</Directory>
Run Code Online (Sandbox Code Playgroud)
至:
DocumentRoot "<CUSTOM_PATH>"
<Directory "<CUSTOM_PATH>">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
</Directory>
Run Code Online (Sandbox Code Playgroud)
以上将设置自定义DocumentRoot
,启用目录列表并允许.htaccess
文件覆盖配置.
然后我通过执行重新启动了apache sudo apachectl restart
.
另一种方法是设置虚拟主机.首先确保在您的/private/etc/apache2/httpd.conf
文件中取消注释以下行:
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
Run Code Online (Sandbox Code Playgroud)
然后,您可以在httpd-vhosts.conf
文件中添加以下内容:
<VirtualHost *:80>
ServerAdmin webmaster@example.local
DocumentRoot "/Library/WebServer/Documents"
ServerName example.local
ErrorLog "/private/var/log/apache2/example.local-error_log"
CustomLog "/private/var/log/apache2/example.local-access_log" common
<Directory "/Library/WebServer/Documents">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
以上将为名为的新虚拟主机设置文档根example.local
目录并启用目录列表,并允许.htaccess
文件覆盖配置.当然,您还需要重新启动apache才能使更改生效:
sudo apachectl restart
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
24870 次 |
最近记录: |