How can I make a public HTML folder in Ubuntu?

你说的曾经没有我的故事 提交于 2019-12-03 01:16:01
rz.

Assuming you've already installed apache, do the following:

sudo a2enmod userdir
sudo service apache2 reload

The first command enables the userdir apache mod, which does exactly what you want. The second reloads apache configurations so that it starts using the new configuration.

To install apache2:

sudo apt-get install apache2

Of course, you'll also need to make sure that the permissions on your public_html folder allow the www-data user to see the files in there -- 755 usually works well. To do this:

mkdir ~/public_html
chmod -R 755 ~/public_html

This will recursively (-R) go through your public_html and set the permissions to 755 (owner rwx, and both group and other r-x, r-x).

David Z

The other answers are on the right track with mod_userdir, but using that will give your website the base URL http://www.yourdomain.com/~username/ - for instance, a file /home/username/public_html/index.html would be accessible as http://www.yourdomain.com/~username/index.html. If you want your files to be accessible under the domain root, as http://www.yourdomain.com/index.html for example, then you'll need to put the directive

DocumentRoot /home/username/public_html

in the Apache configuration file.

By the way, this kind of question is more suited for the Slicehost Forums.

You need to use mod_userdir for Apache, otherwise you need to set up symlinks from /var/www/ or wherever.

Your permissions issue is because Apache does not have read access to your files. You need to allow read access to www-data (or whatever the user is; distro-specific).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!