Difference between revisions of "Personal Web Pages"
(Misc changes, fixing up making long <code> blocks into <nowiki>) |
(fix url) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | Every user account in the | + | Every user account in the CS department can have a personal web site associated with it. To activate this site, one must place a <code>public_html</code> directory in one's home directory to house the web site. The contents of that directory will then become available for public access at the url <nowiki>http://people.cs.ksu.edu/~<username></nowiki> |
== Permissions == | == Permissions == | ||
− | One common sticking point with personal web sites in the | + | One common sticking point with personal web sites in the CS department is the issue of file permissions. The proper file permissions are essential if others are to be able to successfully view your content. |
In Linux the three primary permission categories are <code>user</code>, <code>group</code>, and <code>everyone</code>. Each of these categories then has <code>read</code>, <code>write</code>, and <code>execute</code> permissions. They are traditionally viewed as strings that look like <code>rwxrwxr--</code> or something similar. Here are some examples: | In Linux the three primary permission categories are <code>user</code>, <code>group</code>, and <code>everyone</code>. Each of these categories then has <code>read</code>, <code>write</code>, and <code>execute</code> permissions. They are traditionally viewed as strings that look like <code>rwxrwxr--</code> or something similar. Here are some examples: | ||
Line 16: | Line 16: | ||
Therefore, it is very common to need to set the following permission on your home directory and <code>public_html</code> directory when first creating your personal site. | Therefore, it is very common to need to set the following permission on your home directory and <code>public_html</code> directory when first creating your personal site. | ||
− | < | + | <pre>chmod 711 ~ |
chmod 755 ~/public_html | chmod 755 ~/public_html | ||
− | chmod 644 ~/public_html/index.html</ | + | chmod 644 ~/public_html/index.html</pre> |
Line 28: | Line 28: | ||
At this time you may wish to run the command <code>man chmod</code> to learn more about how to set file permissions. | At this time you may wish to run the command <code>man chmod</code> to learn more about how to set file permissions. | ||
+ | |||
+ | === Fixing permissions on all files in a directory === | ||
+ | |||
+ | Sometimes when you upload new files to your site, the permissions may all be incorrect. The following commands will recursively look in the current directory and fix permissions for all subdirectories and files accordingly. | ||
+ | |||
+ | To fix all subdirectories | ||
+ | find ./ -type d -exec chmod 755 {} + | ||
+ | |||
+ | To fix all files | ||
+ | find ./ -type f -exec chmod 644 {} + | ||
+ | |||
+ | These are the equivalent of "find files (f) or directories (d) recursively, starting in the current directory (./) and run the chmod command on anything found that matches ({})". The + at the end tells the shell to combine commands as much as possible to save time and resources. Run <code>ls -la</code> before and after to make sure permissions are changed correctly. | ||
=== Static Content === | === Static Content === | ||
Line 37: | Line 49: | ||
Dynamic content is content that is executed on the server and the output of that execution is sent to the client. All dynamic content for personal websites are executed as CGI scripts. Permissions are very important on executable scripts and it is essential that '''no other user but the owner may have write permission to the script and the directory that contains the script.''' An example acceptable permission scheme is: | Dynamic content is content that is executed on the server and the output of that execution is sent to the client. All dynamic content for personal websites are executed as CGI scripts. Permissions are very important on executable scripts and it is essential that '''no other user but the owner may have write permission to the script and the directory that contains the script.''' An example acceptable permission scheme is: | ||
− | < | + | <pre>chmod 755 public_html |
− | chmod 644 public_html/index.php</ | + | chmod 644 public_html/index.php</pre> |
Traditionally, cgi scripts that are not PHP (or other inline embedded language) are stored in a <code>cgi-bin</code> directory inside of your <code>public_html</code> directory. An example acceptable permission scheme for the <code>cgi-bin</code> is: | Traditionally, cgi scripts that are not PHP (or other inline embedded language) are stored in a <code>cgi-bin</code> directory inside of your <code>public_html</code> directory. An example acceptable permission scheme for the <code>cgi-bin</code> is: | ||
− | < | + | <pre>chmod 755 public_html/cgi-bin |
− | chmod 755 public_html/cgi-bin/your-script.cgi</ | + | chmod 755 public_html/cgi-bin/your-script.cgi</pre> |
The header of your file should not use direct paths. Instead use the <code>/usr/bin/env</code> program as follows:: | The header of your file should not use direct paths. Instead use the <code>/usr/bin/env</code> program as follows:: | ||
<code>#!/usr/bin/env perl</code> | <code>#!/usr/bin/env perl</code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 14:18, 12 April 2019
Every user account in the CS department can have a personal web site associated with it. To activate this site, one must place a public_html
directory in one's home directory to house the web site. The contents of that directory will then become available for public access at the url http://people.cs.ksu.edu/~<username>
Permissions
One common sticking point with personal web sites in the CS department is the issue of file permissions. The proper file permissions are essential if others are to be able to successfully view your content.
In Linux the three primary permission categories are user
, group
, and everyone
. Each of these categories then has read
, write
, and execute
permissions. They are traditionally viewed as strings that look like rwxrwxr--
or something similar. Here are some examples:
rwxrwxr--
- User: read, write, execute; Group: read, write, execute; Everyone: read onlyrw-r-----
- User: read and write; Group: read only; Everyone: no accessr-xr-xrwx
- User: read and execute; Group: read and execute; Everyone: read, write, executer-x-----x
- User: read and execute; Group: no access; Everyone: execute
Importantly, Linux uses the execute
permission to determine if a client can traverse a directory. Even if every file in a directory is full access for everyone
, if the directory those files are in do not have the execute
permission set for everyone
, they will not be able to see it.
Therefore, it is very common to need to set the following permission on your home directory and public_html
directory when first creating your personal site.
chmod 711 ~ chmod 755 ~/public_html chmod 644 ~/public_html/index.html
These commands correspond to:
- Set permissions of my home directory to
rwx--x--x
- Set permissions of my public_html directory to
rwxr-xr-x
- Set permissions of my index.html file in public_html to
rw-r--r--
At this time you may wish to run the command man chmod
to learn more about how to set file permissions.
Fixing permissions on all files in a directory
Sometimes when you upload new files to your site, the permissions may all be incorrect. The following commands will recursively look in the current directory and fix permissions for all subdirectories and files accordingly.
To fix all subdirectories
find ./ -type d -exec chmod 755 {} +
To fix all files
find ./ -type f -exec chmod 644 {} +
These are the equivalent of "find files (f) or directories (d) recursively, starting in the current directory (./) and run the chmod command on anything found that matches ({})". The + at the end tells the shell to combine commands as much as possible to save time and resources. Run ls -la
before and after to make sure permissions are changed correctly.
Static Content
Static content includes images, html, and other content that is not executed on the server side. The everyone
group will need to have read
permission to any file that you wish to make available via your web site. All directories that contain static files will need to have the execute
permission for the everyone
group.
Dynamic Content
Dynamic content is content that is executed on the server and the output of that execution is sent to the client. All dynamic content for personal websites are executed as CGI scripts. Permissions are very important on executable scripts and it is essential that no other user but the owner may have write permission to the script and the directory that contains the script. An example acceptable permission scheme is:
chmod 755 public_html chmod 644 public_html/index.php
Traditionally, cgi scripts that are not PHP (or other inline embedded language) are stored in a cgi-bin
directory inside of your public_html
directory. An example acceptable permission scheme for the cgi-bin
is:
chmod 755 public_html/cgi-bin chmod 755 public_html/cgi-bin/your-script.cgi
The header of your file should not use direct paths. Instead use the /usr/bin/env
program as follows::
#!/usr/bin/env perl