我只是想在我的用户名下的Red Hat Linux服务器上创build一个public_html文件夹(这一切都有点头疼)。
我做了该文件夹,并将权限设置为755。
我不知道如何处理Apache(并承认findhttpd.conf文件是一个噩梦,感谢非传统的目录布局),但现在我已经find了,我不知道该怎么做。
我见过这个问题。 为linux机器的每个用户设置单独访问的public_html ,但我不明白答案。 我怎样才能'使用mod_userdir'(我对这一切都很陌生)。
我看过这个;
http://httpd.apache.org/docs/2.0/mod/mod_userdir.html
我应该为“httpd..conf文件”添加一些内容吗?
我尝试追加'UserDir启用用户名'的顶部,并重新启动Apache,但我仍然无法find一个页面;
domain.com/~username/
问题是什么?
我是不正确地使用mod_userdir? (我甚至不知道如何使用它)
谢谢!
您安装了哪个RedHat版本? 在RedHat 6.x上,它非常简单:
1)我们假设我有一个用户ec2-user用home目录/home/ec2-user
2)创build一个目录/home/ec2-user/public_html ,并确保目录/home/ec2-user和/home/ec2-user/public_html设置了权限至less为0711(可执行位设置为其他方式,表示apache用户哪个apache2 web服务器运行将有权限进入这些目录)。 另外,该目录的任何内容都必须由apache用户读取。
3)在文件/etc/httpd/conf/httpd.conf提供的apache2 web服务器configuration中启用UserDir模块。 将UserDir disabled行UserDir disabled并注释掉UserDir public_html行:
<IfModule mod_userdir.c> # # UserDir is disabled by default since it can confirm the presence # of a username on the system (depending on home directory # permissions). # #UserDir disabled # # To enable requests to /~user/ to serve the user's public_html # directory, remove the "UserDir disabled" line above, and uncomment # the following line instead: # UserDir public_html </IfModule>
4)用httpd -ttestingapache2 web服务器configuration,应该返回Syntax OK否则出现问题
5)重新启动service httpd restart重启apache2 web服务器,并可select启动chkconfig httpd on on启动服务
6)最后,如果您在enforcing模式下启用了selinux,您可以使用sestatus来检查它 – 您必须运行此命令setsebool -P httpd_read_user_content=on以允许apache2 web服务器读取用户内容
7)testing一下,例如从服务器运行w3m http://localhost/~ec2-user ,如果有错误应该logging到日志文件/var/log/httpd/error_log