How to add a new user for a new website on your VPS

Step 1:Create an adress for your new website

Go to a free website hosting company and sign up for a site. Or use the account you might already have to add another website. Make sure you link the website to your vps ip adress.

Step 2: Add a new user when logged in as root
sudo adduser newuser
Step 3: Log in as newuser and a a directory public_html

Go to your terminal. Log out as root.

Log in as newuser and open Midnight Commander.

Create on the left side a directory named public_html

Step 4: Adding New Virtual Hosting using Apache

The Apache web server is the most popular way of serving web content on the internet. Each domain that is configured will direct the visitor to a specific directory holding that site’s information, never indicating that the same server is also responsible for other sites.

nano /home/newuser/public_html/index.html

In this file, create a simple HTML document that indicates the site it is connected to. My file looks like this:

    <h1>This is just a test </h1>

Save and close the file when you are finished.

Use the list command to see what’s under your available apache sites

spicey@voodoo:~$ ls /etc/apache2/sites-available/
 000-default.conf  default-ssl.conf  quincy.conf  voodoospace.conf

Now copy the confguration from an existing site to your new site.

 spicey@voodoo:~$ sudo cp /etc/apache2/sites-available/voodoospace.conf /etc/apache2/sites-available/hamradio.conf


sudo nano /etc/apache2/sites-available/newsite.conf
<VirtualHost *:80>
 # The ServerName directive sets the request scheme, hostname and port that
 # the server uses to identify itself. This is used when creating
 # redirection URLs. In the context of virtual hosts, the ServerName
 # specifies what hostname must appear in the request's Host: header to
 # match this virtual host. For the default virtual host (this file) this
 # value is not decisive as it is used as a last resort host regardless.
 # However, you must set it for any further virtual host explicitly.

 DocumentRoot /home/username/public_html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
 # error, crit, alert, emerg.
 # It is also possible to configure the loglevel for particular
 # modules, e.g.
 #LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
 # enabled or disabled at a global level, it is possible to
 # include a line for only one particular virtual host. For example the
 # following line enables the CGI configuration for this host only
 # after it has been globally disabled with "a2disconf".
 #Include conf-available/serve-cgi-bin.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Now you need to enable the virtual host files.
sudo a2ensite newsite.conf

When you are finished, you need to restart Apache to make these changes take effect:

sudo service apache2 restart


Leave a Reply

Your email address will not be published. Required fields are marked *