如何在Ubuntu中建立公共HTML文件夹

如何在Ubuntu中建立公共HTML文件夹

本文介绍了如何在Ubuntu中建立公共HTML文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题,但是由于某种原因,我在Google上找不到确切的答案:

Simple question, but for some reason I couldn't find the exact answer on Google:

我在Slicehost上重新安装了Ubuntu,并希望在我的主目录中为包含一个静态HTML文件的简单网站建立一个公共目录.我该怎么做呢?仅仅是键入mkdir public_html并设置权限的问题,还是有一种更简洁的方法? (我记得以前曾经遇到过这样的问题:每次将文件复制到public_html目录时,我都必须手动设置其权限,这很令人沮丧.)

I have a fresh Ubuntu install on Slicehost, and would like to make a public directory in my home dir for a simple website containing a bunch of static HTML files. How do I do this? Is it just a matter of typing mkdir public_html and setting the permissions, or is there a cleaner way? (I remember in the past I've had issues where every time I copied a file into my public_html directory, I would have to manually set its permissions, which was quite frustrating.)

推荐答案

假设您已经安装了apache,请执行以下操作:

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

sudo a2enmod userdir
sudo service apache2 reload

第一个命令启用userdir apache mod,它完全可以执行您想要的操作.第二个重新加载apache配置,以便它开始使用新配置.

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.

要安装apache2:

To install apache2:

sudo apt-get install apache2

当然,您还需要确保对public_html文件夹的权限允许www-data用户查看其中的文件-755通常可以正常工作.为此:

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

这将递归(-R)遍历您的public_html并将权限设置为755(所有者rwx,以及组和其他r-x,r-x).

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).

这篇关于如何在Ubuntu中建立公共HTML文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 08:28