In a nutshell, all you have to do is create a public_html directory within your own home directory, put your web page files in it, and set the files to be publicly accessible. This document tells you how and why.
Each user in the Computer Science Department has a home directory stored on an NFS server. This directory is accessible from the open lab machines.
Our web server hosts each website at students.cs.byu.edu/~username, where username is the user's CS username, assuming that the public_html directory actually exists in the user's home directory.
As long as you have the file permissions set correctly, your page will be visible on the Internet. If you try to access your web page and get an error saying, You don't have permission to access /~username on this server, then your permissions are not set correctly. See the section on permissions later on in this document for more information.
A website is nothing more than a directory structure that is visible over the Internet. The URL you type in is simply the location of the file you're looking for. For example, the URL students.cs.byu.edu/~username/pages/mypage.html points to the file that is found at the following location on the fileserver:
If a directory is specified instead of a file, the server will search through a list of default filenames. If none of those filenames match, the web server will then decide whether directory listings are allowed. If listings are allowed for this directory, the server will build a directory listing and display it as the webpage. Otherwise, it will display a “403 Forbidden” error.
In order to allow access to your website, your
public_html directory needs to make sure the webserver has both read and execute permissions. To set these permissions, you could run the command:
chmod 755 ~/public_html. Keep in mind that this command only sets permissions on the top level of your web root unless you use the -R flag. If you already have files and folders in your public_html folder, you may need to add the -R (recursive) flag:
chmod -R 755 ~/public_html. You will need to ensure that any files you want to be visible have the same permissions as your
public_html folder itself.
Another slightly more nuanced way to accomplish this is to use Linux Access Control Lists (ACLs). You could leave the standard permissions as they are and give only the
www-data user (the user used by the webserver) the read and execute permissions. To apply the needed ACLs you would type the following commands into the terminal:
setfacl -Rm u:www-data:r-x ~/public_html setfacl -d --set u:www-data:r-x ~/public_html setfacl -m u:www-data:–x ~
The first command sets the permissions to read and execute just for Apache. The second one makes these the default permissions for all new folders and files created. The final line puts execute only permissions on your home directory to the public_html folder can be seen by Apache, even if you have no permissions for the world on your home directory.
Using Linux ACLs allows you to be more specific about who gets access and who doesn't. So rather than giving read and execute access to the world, you just give it to the webserver so it can display your webpages.