# /bin/bash # HOW TO SET UP A WEB SERVER USED BY MULTIPLE OWNERS IN A LINUX PC # Imagine a scenario faced by a server maintainer: 10 users request to set up their own webpages in the same Linux system. The system maintainer has to design a convenient way so that each of them can modify their webpage content independently of others. One of the necessary requirement is that each of them can only has the right the modify their own content but not others, while the webpage content stored in the host Linux PC must be accessible by everyone in the world. This document tell you how to do just that. # The main requirement are : (1) the linux PC must be already installed with apache webserver, and that (2) the Linux PC must has an IP address that allows the Linux PC accessible via internet. (3) Must assure that SELinux is set to 'permissive' instead of 'enforcing'. This can be automatically realized by issuing getenforce #If the response is 'Enforcing', you may want to execute setenforce 0 # If (2) is not fulfilled, the webpage set up in the apacher server can only be accessed internally within the campus. The following instruction has been proven to work at least using centos-7.0. It is possible that the instruction also works with other linux systems. # To use this scrip, it must be executed as su mkdir /home/apache chown -R root:root /home/apache # All directories used as internet-accessible webpages are to be placed in /home/apache. # For example, let's assume an user, user=tlyoon ### modify this if required # intends to build an internet webpage. A directory has to be setup for $user by root, namely, cd /home/apache mkdir /home/apache/$user # The owners of this directory must be $user:apache chown -R $user:apache $user # The owner of /home/apache/$user must be added to the group apache, e.g., usermod -g apache $user # To check e.g. the group $user belongs to, groups $user # The output will be something like # $user : $user apache # That confirms $user has been associated with the group 'apache' # Link the folder /home/apache/$user to /var/www/html cd /var/www/html ln -s /home/apache/$user/ . # Now, the user $user can build his/her own webpage by modifying the content in /home/apache/$user. echo 'hello world, this webpage is created by user' $user >> /home/apache/$user/index.html chown -R $user:apache /home/apache/$user service httpd restart ### If the output from this command line fails to indicate correct restart of the httpd, the webpage by $user may be fail. # The above mentioned procedure can be trivially generalised to any number of users by (1) creating a new directory, $user, in /home/apache (2) associate the new $user with group apache, (3) change the ownership of /home/apache/$user to that of the particular user, $user:apache, # All these users can maintain their own webpages independently of the others and without the possibility to interfer other's webpages. # To view the webpage content in e.g., /home/apache/tlyoon, simply type # xx.yy.zz.kk/tlyoon in your web browser, where xx.yy.zz.kk is the ip address of your server. To check what the ip address is , simply issue # ifconfig in the terminal. # As as example, for anatta wiht ip address 10.205.18.97, the webpage set up by tlyoon can be accessed at http://10.205.18.97/tlyoon # If the ip 10.205.18.97 is registered as an DNS open to the public, it can be accessed from anywhere in the world. Else, it can only be accessed from witihin the campus. #typing 10.205.19.205/tlyoon from anywhre in the world can see my webpage. #By Yoon Tiem Leong #School of Physics #Universiti Sains Malaysia #11800 USM #Penang #Malaysia #31 Dec 2018 ############ storage, ignore the following ####### # Backup the following file: # cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig # Modify /etc/httpd/conf/httpd.conf as mentioned below so that two occasions of reference is changed to ... ## # ##... ##... ## #