Step-by-step guide: Creating a website using a Linux VPS

Step-by-step guide: Creating a website using a Linux VPS

VPS hosting allows you to get dedicated resources to host your website on a shared server. So basically a VPS host is offered as a partial and dedicated one. VPS is one of several ways you can host your website on the Internet. It is usually preferred over shared and dedicated hosting servers because:

A) Shared hosting multiplies in flexibility, availability and performance.

b) It is much cheaper compared to fully dedicated hosting.


In a VPS hosting, there are different website files but each set of files are in a separate virtual space, which allows website owners to enjoy the benefits of dedicated resources at a fraction of the price. In this article, we will share a step-by-step guide to creating a website using VPS hosting. We will first describe the main components and programs used, including Apache, MySQL, Perl/CGI, and PHP.

After that, we will show you how to upload your website content using FTP. This tutorial is designed to meet the needs of beginners and experts alike, so it doesn’t matter if you’ve never hosted a website before, this tutorial will cover everything you need to host your first VPS use:

The first thing you should do is get a VPS hosting from a reliable VPS hosting platform. After purchase, you should be given login information which will be required to continue setup.

Connect to the remote server (Remote server)

To connect to a remote VPS server, you will use the ssh command as follows:
ssh root@XXXX where root is the username provided to you and XXXX is the local IP where the server is hosted. When prompted, enter your password to continue.

Update the system

As a recommended preliminary step, you should update your system packages. This is especially important since we’re going to install PHP and Apache, which often have a large number of dependencies that a system-wide update will automatically receive. Depending on the Linux distribution your server is running, use the apt-get or yum commands to update your system (as follows):

Sudo apt-get update
Sudo yum update

Installing the necessary tools:

Now we need to install our web server, Apache, database application, MySQL and code interpreters, Perl and PHP. From

yum install httpd php php-mysql perl mysql mysql-server

or use:

Apt-get install httpd php php-mysql perl mysql mysql-server
Apache configuration

Now we are going to the technical part of this tutorial. If you plan to host a single website, all you have to do is copy your files to the default var /www/ directory and watch the magic happen. However, you can host multiple websites on a VPS server to take advantage of its true potential. For security, it is recommended to create a user for each website and then keep the files for that website in the public_html folder in main /home. This creates a clean, easily maintainable directory structure and also adds security to the mix. Let’s start the process:

1. Add new user: useradd john

2. Set a password for the newly created user: passwd john

3. Create a new folder in the home/ folder: mkdir / home / john / public_html

4- Give ownership of the newly created folder to the newly created user: chown john: john / home / john / public_html /

5. Set the permissions for the folder: chmod 755 / home / john / public_html / && chown 711 / home / example /

6. Edit the /etc/httpd/conf/httpd.conf file using your favorite editor. For this example, we will use vi: vi /etc/httpd/conf/httpd.conf

Scroll down to the bottom of the file and enter the following code to add a virtual host:

NameVirtualHost *:80
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.ariaservice\.net$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
DocumentRoot /home/john/public_html
ErrorLog /var/log/ ariaservice.net_error_log
CustomLog /var/log/ ariaservice.net_access_log combined
DirectoryIndex index.html index.htm index.php index.php4 index.php5
SetOutputFilter DEFLATE
Options -Indexes +IncludesNOEXEC +SymLinksifOwnerMatch +ExecCGI
allow from all
AllowOverride All

In the lines of code above, modify the /home/john/public_html path according to your username, wherever you see it. Also change to your website domain name wherever required. Save the file and close it.

7. Now, we need to make sure that Apache starts as soon as the device is turned on.

etc/init.d/httpd start/
chkconfig httpd on

8- As the last step, we need to connect the DNS A record to the IP address of our server. It maps your domain to the device’s IP address and ensures that whenever your domain name is entered, a request is sent to your server. Once you’ve done this, you can visit your domain to see if you’ve been redirected to the default Apache page. If everything is fine, continue.

MySQL configuration

1. As a first step, start the MySQL server and set it to start on startup.

/etc/init.d/mysqld start
chkconfig mysqld on

2. Set the root user password for MySQL. To do this, use the following commands:

mysql -u root
UPDATE mysql.user SET Password = PASSWORD(‘P@ssw0rd’) WHERE User = ‘root;'

Replace the string “P @ ssw0rd” with the password you want to set.

3- In the next step, create a database and grant the necessary privileges to the relevant user.

mysql -u root -p

Creating a database test:

grant all privileges on test.* to john@localhost;

Obviously, you’ll replace test and john@localhost with whatever name you want for your database and username, respectively.

Upload your files using SFTP

Now that MySQL and Apache are up and running, you simply need to upload your website files. You can use any SFTP (SSH File Transfer Protocol) client, but we recommend using FileZilla. Follow these steps:

1. Connect to your server using the username you created.

2. Select all your website files and upload them to the home / public_html/ directory.
This is it. Now when you enter your domain name in the browser, you should be redirected to the home page of your website.

And finally, VPS hosting is an affordable way to enjoy the benefits of dedicated server web hosting without paying full price. In this tutorial, we have taught you all the necessary steps to host your first website on a VPS hosting server. Once your website is live, you can modify it to your liking.

support hosting100