Basic setup of a multi user hosting environment on Ubuntu or Debian.
This is a very simple, minimal and safe setup which allows users to have their own web sites hosted in a central web server. The main advantage of this method is that it is very secure.The main features of this setup are the following:
- Each user has his own home directory
- Each user can have one or more websites hosted
- Web server does not need extra configuration regarding users, groups etc.
- Users are owners of their website(s) and can connect and modify their sites at will.
- Users can only view the web directories that they own.
- Simple and fast setup
Steps
- Login as root
- Create user with his own home dir
- Assign a password to the user
- Create virtual host's directory and set permission to user and group.
- Change ownership of vhost directory
- Add apache user www-data to user's group
- Check the groups that the user www-data belongs to:
- Create virtual host or virtual directory apache configration
- Virtual directory setup
- Virtual host setup. Let's assume <site> is example.com. A sample config virtual host config could be similar to the configuration below:
- Reload/Restart apache
- Ready!
sudo su -
useradd -s /bin/bash -m -d /home/<username> <username>
passwd <username>
mkdir -m o-rwx /var/vhosts/<site>
chown -R <username>:<username> /var/vhosts/<site>
usermod -a -G <username> www-dataThe statement above gives apache web server the required permissions in order to run effectively all of the user's websites.
root# groups www-data www-data : www-data <username> ...
Alias /<subsite> /var/vhosts/<site> <Directory /var/vhosts/<site> Options None AllowOverride All Order allow,deny Allow from all </Directory>
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/vhosts/example.com ServerName www.example.com <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/vhosts/example.com> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> CustomLog ${APACHE_LOG_DIR}/example.com.access.log combined ErrorLog ${APACHE_LOG_DIR}/example.com.error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn </VirtualHost>
service apache2 reloadIn case reload doesn't work (although it should) try restart:
service apache2 restart
Find the Best Web Hosting i would like to say thank you about this cool post,and this idea very helpful to me, Thank You.
ReplyDeleteshared hosting
Bluehost is definitely one of the best web-hosting company for any hosting services you need.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for providing valuable information.Here is the hosting provider hostingforsell website reviews which provide you best hosting services with afforadble price.I know you like it.
ReplyDelete