
To facilitate this course, and to test cPanel hosting, everyone in this class has been given a cPanel account. cPanel is an online control panel that makes it easy to setup and maintain an advanced website.
You can access your account by going to https://username.people.haverford.edu:2083/. You may get a message asking whether you wish to accept the security certificate or not -- say yes. Then you will be asked for your login and password. Your login will be your username, and your password will be the initial password that we provided you.
When you first connect to cPanel, you will see a main window with information about your account on the left and lots of buttons on the right. These buttons let you configure and control various aspects of your hosting account. The buttons are organized into categories, such as Mail and MySQL Databases. The online cPanel users manual is very helpful, and will explain what all of these buttons do. We will be covering some of them.
Use this panel to change your main account password. Please do this right away!
The File Manager panel gives you an online means for manipulating your files and directories. We've already learned how to do this via the shell, and I recommend you use the shell instead of the online file manager, but it may still be convenient at times. Additionally, the File Manager lets you easily upload files to your account from your web browser, and this can be quite handy.
This panel allows you to setup and maintain your MySQL databases. We will come back to this panel later when we discuss MySQL in a future lesson. This panel also gives you access to phpMyAdmin, which gives you complete control of your MySQL databases.
The Web/FTP Stats panel gives you access to a number of site traffic analysis and statistics packages. They will tell you what site pages are most popular, where traffic is coming from, what types of browsers your visitors use, etc.
A number of panels in cPanel use something called .htaccess, which we will now discuss. To be specific, Index Manager, IP Deny Manager, Password Protect Directories, Error Pages, and Redirects all use .htaccess file configuration to work.
The webserver that we use is called Apache. Apache is an open source webserver with many advanced features, including something called .htaccess files. Htaccess files are files with the name .htaccess that you put in directories to tell Apache how it should behave when working with those directories or any of their sub-directories. Htaccess files overload eachother, so if I configure something in directory a with an htaccess file, and then set something else in directory b, a subdirectory of a, then the changes in b override those made in a. Lets look at an example .htaccess file that turns off the display of a file index:
Options -Indexes
order allow,deny deny from 103.49.2.7 deny from 012.34.5. allow from all
AuthUserFile /home/pathto/.htpasswd AuthType Basic AuthName "Secret Place" <LIMIT GET POST> require valid-user </LIMIT>
.htpasswd files are quite simple. They take the form:
username1:encrypted password username2:encrypted password ...
In UNIX, any file that begings with a period (.) will be hidden from view when you use the ls command. To see these files, use ls -la.
Ok, so now we get back to cPanel. A number of panels in cPanel use .htaccess files. When you use these panels, .htaccess files will be automatically generated in the affected directories. Let's look at the cPanel panels that use .htaccess files, and see how you can use them to do fancy things:
My coverage here was terse. The comprehensive guide to .htaccess is a good place to learn more about htaccess files.
Okay, now we're going to talk about something a little different. Last time we explored the UNIX shell and learned how to make files, but we didn't learn very much about looking at directories or setting file permissions.
In UNIX, there are users and groups. You are a user, and you have a user name. You also have a group, which in this case has the same name as your user name. This is pretty common on multiuser systems like the one we're using. However, a single user can be in multiple groups. For example, if more than one person needs to maintain a web page, instead of sharing a user account, a group (call it webdesigner) could be created with all of the designers in it. Then, as we will see in a moment, the website files could be setup so that anyone in the webdesigner group could edit them.
In order to see the file permissions of the files in a directory, you need to pass the -la option to the ls command, as we did before to view UNIX dot files.
-jailshell-2.05b$ ls -la total 420 drwxr-x--- 8 acantino nobody 4096 May 27 12:13 . drwx--x--x 16 acantino acantino 4096 May 27 12:31 .. -rw-r--r-- 1 acantino acantino 62 May 25 14:33 .htaccess -rw-r--r-- 1 acantino acantino 1303 May 19 10:28 camel.gif drwxr-xr-x 2 acantino acantino 4096 May 27 11:47 cgi-bin -rwxr-xr-x 1 acantino acantino 311 May 24 15:24 date.cgi ...
Back to the first column from above. The first character indicates whether or not the item is a directory. If the first character is a d then the entry is a directory, as with cgi-bin above. The next three characters indicate the file or directory's read (r), write (w), and execute (x) permissions for the owner of the file or directory. The next three characters are the read, write, and execute permissions for the group of the file or directory. The final three characters are the read, write, and execute permissions for everyone else. I'll summarize this here:
+---Directory indicator
|
[-][---][---][---]
| | |
User Group World
Each [---] is [read (r), write (w), execute (x)]
Sometimes you need to change file permissions. To do this, use the chmod command. Chmod is a bit cryptic, but you'll get it. The letters u, g, o are user, group, and other (world). The letter a is all, equivalent to ugo. The letters r, w, and x are read, write, and execute, as before. The equals (=) character assigns permissions, minus (-) takes away permissions, and plus (+) adds permissions. Here are some chmod examples: 3
chmod u+r file # Give user read chmod u-x directory # Take away user execute chmod a=rx file # Give all (ugo) read and execute chmod u=rwx file # Give user read, write, execute chmod o=r file # Give other read and nothing else chmod ug+rw file # Give user and group read and write.
Login to cPanel by going to https://your-username.people.haverford.edu:2083/ and take a look around! Try uploading some files, setting some directory permissions, and playing with all of the various panels that we have discussed.
Try making some directories in your account and putting .htaccess files in them, either by hand, or using the tools in cPanel. Password protect one of the directories. Turn of indexing in another one. Play around.
Make a few test files (you can make a blank test file by typing touch filename) and chmod them in different ways. Try the =, +, and - commands in chmod.
Continue learning Perl. Try some more example programs from last time.
 
[1] - These files are stored in a directory structure that mirrors your directory structure, located at /home/username/.htpasswds/.
 
[2] - The '.' directory means 'this directory' in UNIX, so './camel.gif' just refers to 'camel.gif in this directory.' The '..' directory refers to the parent of this directory. Thus, as we saw, 'cd ..' goes back one directory level.
 
[3] - http://catcode.com/teachmod/chmod_cmd.html
This document was generated using AFT v5.094