How to Setup Linux, Nginx, MariaDB and PHP (LEMP) Stack on CentOS 7

LEMP stack is a collection of four open-source applications that are installed together on a server to run dynamic websites. These include Linux, Nginx, MariaDB, and PHP.

When setting up a VPS (Virtual Private Server) account, you will be prompted to select a Linux image (e.g. CentOS 7) when deploying the server. Linux is an operating system based on the Linux Kernel. It is very powerful, secure and runs most of the world’s servers.

Nginx is an event-driven web server popularly used for serving dynamic content. It has a very predictable performance, especially for high trafficked websites.

MariaDB is a fork of MySQL database and is compatible with all SQL commands. It is considered as a drop-in replacement for MySQL. The Relational Database Management System is fast, highly scalable and secure.

PHP is a scripting language that is popularly used as the middleware between the database server and web server.

In this guide, we will show you how to install Nginx, MariaDB, and PHP on a VPS plan running CentOS 7 as the operating system.

Prerequisites

Before you begin make sure you have the following:

Step 1: Installing Nginx on CentOS 7

Nginx packages are available in the EPEL repositories. If you don’t have EPEL repository already installed you can do it by typing:

Nginx packages can be pulled from the EPEL repositories, so you can first install it by typing the command below:

$ sudo yum install epel-release

Once installed, run the command below to install Nginx

$ sudo yum install nginx

Press Y and hit Enter when prompted to confirm the installation. Next, enable the Nginx server by typing the command below:

$ sudo systemctl start nginx

In order to start the web server when the system is rebooted, run the command below:

$ sudo systemctl enable nginx

The default CentOS 7 inbuilt firewall is set to block Nginx traffic. In order to allow inbound traffic to the Nginx server, run the commands below:

$ sudo firewall-cmd --zone=public --permanent --add-service=http
$ sudo firewall-cmd --zone=public --permanent --add-service=https
$ sudo firewall-cmd --reload

To check if Nginx was successfully installed on your server, enter the IP address associated with your VPS instance on a web browser like Google Chrome:

$ 192.0.0.1

You should see the default Nginx home page as shown below:

Alternatively, if you wish to check the status of the web server on the command line tool, enter the command below:

$ sudo systemctl status nginx

Output:

nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset                                             : disabled)

Active: active (running) since Wed 2019-02-13 07:52:14 UTC; 3min 17s ago

Main PID: 12740 (nginx)

CGroup: /system.slice/nginx.service

├─12740 nginx: master process /usr/sbin/nginx

└─12741 nginx: worker process



Feb 13 07:52:14 lemp-server-1 systemd[1]: Starting The nginx HTTP and revers....

Feb 13 07:52:14 lemp-server-1 nginx[12735]: nginx: the configuration file /e...k

Feb 13 07:52:14 lemp-server-1 nginx[12735]: nginx: configuration file /etc/n...l

Feb 13 07:52:14 lemp-server-1 systemd[1]: Failed to read PID from file /run/...t

Feb 13 07:52:14 lemp-server-1 systemd[1]: Started The nginx HTTP and reverse....

Hint: Some lines were ellipsized, use -l to show in full.

Step 2: Installing MariaDB on CentOS 7

Next, we are going to install the MariaDB database server on the CentOS 7 machine. We are going to use the yum package manager

$ sudo yum install mariadb-server

Press Y and hit Enter when prompted to confirm the installation. After a while, your MariaDB server installation should be completed.

To start the database server, run the command below:

$ sudo systemctl start mariadb

Just like we did for the Nginx server, we want to make sure that the database server is started when the system boots. To do this, run the command below

$ sudo systemctl enable mariadb

You can check if the MariaDB server is running by typing the command below

$ sudo systemctl status mariadb

Output:

mariadb.service - MariaDB database server

Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)

Active: active (running) since Wed 2019-02-13 08:02:03 UTC; 56s ago

Main PID: 12913 (mysqld_safe)

CGroup: /system.slice/mariadb.service

├─12913 /bin/sh /usr/bin/mysqld_safe --basedir=/usr

└─13075 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-...



Feb 13 08:02:01 lemp-server-1 mariadb-prepare-db-dir[12835]: MySQL manual for more instructions.

Feb 13 08:02:01 lemp-server-1 mariadb-prepare-db-dir[12835]: Please report any problems at http://mariadb.org/jira

Feb 13 08:02:01 lemp-server-1 mariadb-prepare-db-dir[12835]: The latest information about MariaDB is available at http...rg/.

Feb 13 08:02:01 lemp-server-1 mariadb-prepare-db-dir[12835]: You can find additional information about the MySQL part at:

Feb 13 08:02:01 lemp-server-1 mariadb-prepare-db-dir[12835]: http://dev.mysql.com

Feb 13 08:02:01 lemp-server-1 mariadb-prepare-db-dir[12835]: Consider joining MariaDB's strong and vibrant community:

Feb 13 08:02:01 lemp-server-1 mariadb-prepare-db-dir[12835]: https://mariadb.org/get-involved/

Feb 13 08:02:01 lemp-server-1 mysqld_safe[12913]: 190213 08:02:01 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.

Feb 13 08:02:01 lemp-server-1 mysqld_safe[12913]: 190213 08:02:01 mysqld_safe Starting mysqld daemon with databases f...mysql

Feb 13 08:02:03 lemp-server-1 systemd[1]: Started MariaDB database server.

The default MariaDB installation is not secure, so we are going to run the command below to set a root password, remove anonymous users and disable remote access

The default MariaDB installation is not secure, so we are going to run the command below to set a root password, remove anonymous users and disable remote access

$ sudo mysql_secure_installation
Enter current password for root (enter for none):
Set root password: Y
New password: STRONGPASSWORDHERE
Re-enter new password: REPEATSTRONGPASSWORDHERE
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

Output:

Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

Once the MariaDB  installation is complete, you can log in to the database server using the command below:

$ sudo mysql -uroot -p

Enter the root password of your MariaDB server and press Enter to continue.

You should see the MariaDB command line interface

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Once logged in, you can run any SQL command e.g., to list databases, run the command below:

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

Step 3: Installing PHP on CentOS 7

Next, we are going to install PHP(Hypertext Preprocessor).

This is a general-purpose scripting language that is highly suitable for web applications. In fact, most Content Management Systems (CMS) are coded in PHP.

To install the PHP software package, run the command below:

$ sudo yum install php php-mysql php-fpm

Again, press Y and hit Enter when prompted to confirm the PHP installation on CentOS 7 server.

Once PHP is installed, we will make a few changes to the configuration file. Open the file using nano text editor

$ sudo nano /etc/php.ini

Then, look for the line below:

;cgi.fix_pathinfo=1

And change it to:

cgi.fix_pathinfo=0

Press CTRL+X, Y and hit Enter to continue.

Then, we are going to edit the PHP-fpm configuration file:

$ sudo nano /etc/php-fpm.d/www.conf

Make the following changes to the file:

listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
user = nginx
group = nginx

We can now start the PHP package by running the command below:

$ sudo systemctl start php-fpm
$ sudo systemctl enable php-fpm

To enable Nginx to process PHP pages, we are going to create a configuration file using nano text editor

$ sudo nano /etc/nginx/conf.d/default.conf

Then, enter the following details:

server {
    listen   80;
    server_name  192.0.0.1;

    # note that these lines are originally from the "location /" block
    root   /usr/share/nginx/html;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Save the file by pressing CTRL+X, Y, and Enter. Then, restart the Nginx web server:

$ sudo systemctl restart nginx

To test if PHP is working, create PHP info file:

$ sudo nano sudo nano /usr/share/nginx/html/info.php

Then enter the information below:

<?php
 phpinfo();
?>

Save and close the file. Then, on a web browser visit the page below and remember to replace 192.0.0.1 with your IP address:

http://192.0.0.1/info.php

You should see a page similar to the one shown below with lots of information about PHP

Conclusion

That’s all when it comes to installing the LEMP stack on your VPS machine. Once the setup is complete, you can import your website files and have a fully functioning web server.

Remember to point your domain name DNS records the public IP address associated with your VPS machine.

New to VPS hosting and cloud computing. Sign up with Digitial Ocean today and enjoy up to $100 worth of free trial credit.

How to Setup WordPress Website with Apache, MySQL and PHP on Ubuntu 18.04 VPS

Since May 2003, WordPress has remained the most popular, stable, secure and easy to use Content Management System (CMS) for setting up websites.

The free Open-source software is fully built-in and comes with thousands of beautiful themes and plugins for extended functionalities.

WordPress WYSIWYG interface is browser-based and does not require complicated FTP or HTML coding software applications to launch a website.

Due to its clean and simple code, the CMS is loved by all major search engines because it is easier to index.

WordPress is based on PHP and MySQL and runs on most popular web servers including Apache and Nginx.

On a shared hosting, WordPress can be installed by automatic script installers such as Softaculous.

However, the installation method on a VPS hosting  takes a new approach and can be done with just a few and simple shell commands.

This is a step-by-step guide on setting up a WordPress website with  Apache, MySQL and PHP on Ubuntu 18.04 VPS.

Prerequisites

  • A VPS account running Ubuntu 18.04 Operating System. Sign up with Digital Ocean and get free trial credit worth $100 to configure this article and test other cloud products.
  • A domain name (e.g. example.com). You can buy a domain name from a registrar of your choice(e.g. Namecheap).
  • A non-root user that can perform sudo tasks for your Ubuntu 18.04 Server.

Step 1: Point your Domain Name DNS records to your VPS

The first step is to point the DNS records of your domain name to your VPS . When visitors enter your domain name on a browser, they should be routed to the IP address associated with your VPS account.

You should ask your VPS provider about the correct DNS records to use if you are in doubt.

For instance, if you are running a VPS from Vultr, the DNS records look like these:

  • ns1.vultr.com
  • ns2.vultr.com

Step 2: Connecting to Your VPS Server

SSH to your Ubuntu 18.04 server using the public IP address (e.g. 198.18.0.22) associated with your VPS instance.  You can do this via the Command Line Interface (CLI) that ships with Linux or Mac. If you are running Windows on your local computer, consider downloading PuTTY SSH client.

Step 3: Installing Apache Web Server

The first software we are going to install is Apache. It’s an Open source web server application that runs the world’s busiest sites. Apache can handle large traffic and has lots of built-in security features and expandable modules.

To install Apache, first update the package information list on your Ubuntu server using the command below:

$ sudo apt-get update

Then, pull Apache from Ubuntu’s software repository using the command below:

$ sudo apt-get install apache2 php libapache2-mod-php

Press Y and hit Enter when prompted to confirm the installation.

Step 4: Initializing WordPress Website Directory Structure

Apache has a special feature called Virtual Hosts. This advanced feature allows you to host unlimited websites on a single Linux machine.

Before we create the Virtual Host configuration file, we must initialize the directory for holding our website files.

We have to create the directory under the /var/www/ folder using the command below:

$ sudo mkdir -p /var/www/example.com/public_html

Step 5: Creating a Virtual Host for the WordPress Website

When you install Apache, a default Virtual host (000-default.conf) is created under the /etc/apache2/sites-available directory. To keep things simple, we will create our own virtual host to run our WordPress site.

Please note, virtual hosts configuration files must end with a ‘.conf’ extension. So let’s create the configuration file for our domain name www.example.com

$ sudo nano /etc/apache2/sites-available/example.com.conf

Then, copy and paste the below content on that file:

<VirtualHost *:80>

    ServerAdmin admin@example.com

    ServerName example.com

    ServerAlias www.example.com

    DocumentRoot /var/www/example.com/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log

    CustomLog ${APACHE_LOG_DIR}/access.log combined

  <Directory /var/www/example.com/public_html>

     Options -Indexes +FollowSymLinks -MultiViews

     AllowOverride All

     Require all granted

  </Directory>

</VirtualHost>

Press CTRL+X, Y, and Enter to save the file.

We need to disable the default virtual host and enable the one we have just created, run the commands below:

$ sudo a2dissite 000-default.conf
$ sudo a2ensite example.com.conf

Restart Apache web server

$ sudo systemctl restart apache2

Step 6: Installing MySQL Database Server

WordPress relies on MySQL to store data. Apart from photos, plugins, and themes, post and web pages are stored in the MySQL relational database.

Like WordPress and Apache, MySQL is free and Open-source. It is also available on the Ubuntu’s software repository and we can install it using the apt command:

$ sudo apt-get install mysql-server

Press Y and hit Enter when prompted to confirm the installation

Step 7: Securing MySQL Server

MySQL installation is not secure by default. It comes with some test databases and other settings that we must disable. To do this, run the command below:

$ sudo mysql_secure_installation

You will get a prompt to answer multiple questions. We have prepared the correct responses, just follow the settings below:

Setup 'validate password' plugin? [Y/N] Y
Password Validation Policy Level: 2
Root Password: PASSWORD
Re-enter password: REPEAT PASSWORD
Continue with the password provided? Y
Remove anonymous users? [Y/N] Y
Disallow root login remotely? [Y/N] Y
Remove test database and access to it? [Y/N] Y
Reload privilege tables now? [Y/N] Y

If all goes well, you will get a success message.

Step 8: Creating a WordPress Database and User

Next, we are going to create a database and username for our WordPress software. First, log in to the MySQL command line interface using the command below:

$ sudo mysql -u root -p

Enter the root password of your MySQL server when prompted and hit Enter.

Then, on the command prompt that appears, enter the below SQL command to create a database:

mysql> Create database wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

To create a database user, run the command below:

mysql>Create user  'wp_user'@'localhost' IDENTIFIED BY 'PASSWORD';

Then, assign all privileges to the ‘wordpress’ database to the user we have created above using the command below:

mysql> Grant all privileges on wordpress.* to  'wp_user'@'localhost';

Flush privileges for the changes to take effect:

mysql> Flush privileges;

Exit from the MySQL command line interface:

mysql> Exit;

Step 9: Installing PHP on Ubuntu 18.04 Server

WordPress is written in PHP language and we must install the software on our Ubuntu 18.04 server in order for the application to function.

We are also going to install all the required PHP modules that WordPress require.

We can install all the software and modules in one line using the command below:

$ sudo apt-get install php php-cli php-common php-mbstring php-gd php-intl php-xml php-mysql php-zip php-curl php-xmlrpc

Restart Apache web server for the changes to take effect:

$ sudo systemctl restart apache2

Step 10: Downloading and Installing WordPress on Ubuntu 18.04 VPS

We now have a web server, a database for our WordPress software and PHP scripting language. We can now go ahead and download WordPress.

First, cd to the ‘tmp’ directory:

$ cd /tmp

Then, grab the latest WordPress version using wget command:

$ wget -c http://wordpress.org/latest.tar.gz

To unzip the WordPress installation files to the root directory of the virtual host that we created earlier, run the commands below:

$ sudo tar -xzvf latest.tar.gz
$ sudo cp -r wordpress/.  /var/www/example.com/public_html/

Apache runs under the www-data user, we need to grant the web server full permissions to control our website’s file. Run the command below:

$ sudo chown -R www-data:www-data /var/www/example.com/public_html

Then, we can set the appropriate permissions to ensure the outside world has read and execute permissions only:

$ sudo chmod -R 755 /var/www/example.com/public_html

To make sure that newly created files and folders inherit the correct permissions, we can run the command below:

$ sudo find /var/www/example.com/public_html -type d -exec chmod g+s {} \;

Step 11: Finalizing WordPress Installation on Ubuntu 18.04 Server

We now have WordPress installation files on the root of our website. However, we need to configure the database settings on the WordPress configuration files.

So type the command below to copy wp-config.php file from the default wp-config-sample.php file:

$ sudo cp /var/www/example.com/public_html/wp-config-sample.php /var/www/example.com/public_html/wp-config.php

Then, open the new configuration file that we have copied using a nano editor:

$ sudo nano /var/www/example.com/public_html/wp-config.php

Look for the values:

define('DB_NAME', 'database_name_here');
/** MySQL database username */
define('DB_USER', 'username_here');
/** MySQL database password */
define('DB_PASSWORD', 'password_here');

And change them to:

define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wp_user');
/** MySQL database password */
define('DB_PASSWORD', 'PASSWORD');

Remember to replace PASSWORD with the correct value.

Before you close the file add the line below at the top:

<?php

And the line below at the bottom

?>

If you don’t add the two lines, PHP will not be able to parse the configuration file.

On a browser, enter your domain to finalize WordPress installation. If you followed all the steps, you should see the below web page:

Configuring WordPress with Apache, MySQL and PHP on Ubuntu 18.04 VPS

Congratulations! Your WordPress site is now installed. Just follow the wizard to complete the final settings.

Finally, you can create new posts, add a new web page or probably change the WordPress theme to match the look and feel of your company brand.

Conclusion

We have shown you how to install WordPress with Apache, MySQL, and PHP on Ubuntu 18.04 server.

Remember, you can run as many WordPress sites as required on your VPS plan by leveraging the power of Apache Virtual Host feature.

Sign up with Digital Ocean today and enjoy up to $100 worth of free trial credit to test this article and other cloud products.

Top VPS providers offering $5 Virtual Private Server Plans

I have seen a blog listing cheap vps server providers going for $19.95/month and this is quite misleading!. The cost of VPS hosting has dramatically dropped over the last few years. Today, you can get a fully working VPS plan for around $5/month.  In this guide, I am going to talk about the best VPS providers who are on top of the market. Also, I have selected the only renowned VPS provider with proven track record. Remember, cheap VPS does not always mean the best and this is why I have selected only the best companies offering the Virtual Private Servers.

VPS hosting comparison

VPS Provider Digital Ocean Linode Vultr Amazon Lightsail
Price $5 $5 $5 $5
RAM 1GB 1GB 1GB 512MB
Storage 25GB 20GB 20GB 20GB
CPU Cores 1 1 1 1
Bandwidth 1TB 1TB 1TB 1TB
VPS Purchasing Links Try Digital Ocean Try Linode Try Vultr Try Amazon Lightsail

Digital Ocean $5 VPS

Digital Ocean was founded in 2011 and its droplets goes for as little as $5/month, 1Vcpu and an extended SSD drive space of 25Gb. You can see this is the noteable difference that makes digital ocean stand among the other players.

Their Cheap VPS hosting are well balanced and fine-tuned with a vast amount of memory that allows you to scale up as required. You should consider Digital Ocean whether you are running blogs, web applications or just testing with a server environment.

The New York based giant boasts of over a million customers and is the 3rd largest cloud computing company in the world rivaling Alibaba and Amazon.

Linode $5 virtual host plan

Linode was started in 2003 and has customers across more than 100 countries. They have friendly support and good services. Linode sees VPS as their top niche and are quite consistent with their services and their data centres are spread across the globe. Apart from their $5 VPS hosting, they have better VPS plans with more RAM, CPU cores and SSD storage. Linode boasts of a reliability of around 99.99%.

Vultr $5 vps hosting

Vultr offers $5 brilliant VPS hosting and you can deploy your Linux instance with their bare metal cloud storage. They also have great add-on products apart from the compute engine including dedicated servers block storage and dedicated cloud. Vultr has also introduced $2.5 plan that comes with a RAM of 512MB, 20GB SSD and a monthly bandwidth transfer of around 500GB. Vultr VPS runs on 100% Intel CPU’s

Amazon Lightsail $5 cheap vps

Amazon Lightsail advertises their $5 plans as ‘Virtual private servers made easy’. They have everything you need to jump start your cloud needs including compute engine, storage and network products. Amazon is a Big name and they keep their products simple, reliable and secure. They make virtual private server a breeze. Scaling up or down in Amazon is also very easy and their data centres span across 10 different global regions. They have a no non-sense pricing starting from $5 to $40.

Conclusion

If you are looking for cheap vps hosting , I would advise you to go with these top VPS providers in the market today. Do not be mislead by blogs that advertise for $19.95 VPS hosts. Most of them advertise high ticket plans so that they can make more commissions but they haven’t done any proper research on the best vps hosting. I hope my vps hosting comparison will assist you to buy the best VPS server.

As always if you are getting started, try Digital Ocean or Vultr and install Ubuntu 16.04 as the operating system because it is easy to deploy and manage. You can later switch to CentOs and other Os as your familiarize yourself with linux vps hosting.

Advantages of Virtual Private Server over Shared Hosting

The advantages of Virtual Private Server are quite staggering compared to shared hosting services. But before we dig deep on the merits of VPS web hosting , let’s first define some terms.

What is VPS hosting? VPS is an acronym of Virtual Private Server. As its name suggests, it is a service offered by the best VPS hosting providers in the market.

VPS allows a customer to have a virtual machine/computer that runs its own operating system and software applications.

The most notable and useful feature of virtual server hosting is root access. A customer running a VPS has a super-admin access and he can shut-down, boot, reboot or perform any task on the virtual machine instance.

Why VPS?

VPS is quickly gaining a lot of popularity and it’s the new form of hosting that is sought by millions of web masters on the internet today. However, there is still a lot of confusion for those who are looking for a web host. According to my experience VPS is far better than shared hosting and there is no comparison at all.

Benefits of VPS hosting

VPS hosting offers more control

VPS gives customer the autonomy to install any software of their choice including operating systems (OS). When you buy vps hosting from a company such as Vultr or Digital Ocean, you get access to a control panel where you can provision your VPS instance.

You can then boot your virtual machine and install an OS that will work well depending on your needs. Installing an OS, upgrading and updating just requires a few clicks of a mouse.

The most common operating system is Linux and vps providers offer different distributions that you can choose from. These include Ubuntu, CentOs, Fedora, Windows e,t,c.

If you are just starting out, Ubuntu 16.04 is the best because you can find a lot of learning materials on the internet talking about it. CentOs is for those who want to start their own web hosting business because it supports Cpanel and WHM.

For those developing with asp and .net technologies, Windows OS could be a better bet.

In addition, most people switching to VPS host do so because they want to install their favourite web server. In a linux environment, you can choose from Apache, Lightspeed and Nginx, webserver.

Apache webserver is preferred by many because it is open source and quite easy to configure.

In a shared hosting, you don’t have the choice of installing or changing an operating system and hence VPS is a winner.

VPS gives you full root access and you can setup your Virtual computer as though it was your own personal computer at home.

VPS hosting is reliable than shared hosting

If you buy vps server, you will be the only player in that hosting environment and you won’t be competing with other web masters.

Some shared hosting providers are known for overselling their servers and this makes websites extremely slow.

Also, In a shared environment, lots of web visitors are competing for resources in a single server including RAM, CPU and installed software applications like Apache and MySQL server.

However, best vps hosting gives you a guarantee on your resources allowing your sites and hosted applications to run at a lightning speed.

I once switched to VPS hosting when I realized my shared hosting provider was killing all MySQL select queries running for more than 30 seconds. VPS allows you to tweak everything according to your special needs.

VPS hosting provides better Flexibility

There are lots of affordable vps hosting provider on the market today e.g. Vultr and Digital Ocean. All of them give customers the flexibility to scale up or down according to their needs.

For instance, if you are just starting out, you can choose a VPS plan with a 5GB Solid state drive, 1 core CPU and 1GB RAM and you only get to pay around $5/mo.

You can later scale up when your websites or hosted applications gain popularity and probably choose a plan that offers more RAM, space and extra CPU cores.

In a shared environment, your applications can come to a complete halt if your site is overwhelmed by many visitors. Scaling up or down on a VPS hosting is very easy by using the control panel offered by many web hosts.

After changing a plan, the cost of the VPS is adjusted accordingly in the next billing cycle. Such flexibility is a win to any webmaster looking for a better solution to host websites.

The cost of VPS hosting has drastically dropped to the same prices as shared hosting

Cheap Linux VPS plans start from $5/month. This is so much cheaper compared to some shared hosting that goes for more than $15/month!

However, linux vps hosting  requires you to learn some basic but simple linux commands. If you like Microsoft products, you can still get best windows vps in the market including Google and Amazon.

But if you really want a Linux server provisioned within a few minutes, try Digital Ocean or Vultr, both have affordable plans starting from $5/month.

So, is VPS better than shared hosting?

The benefits of VPS hosting outweigh shared hosting with a big margin and if you need more power, control and flexibility on your server, VPS is the way to go.

One thing I like about VPS hosting is the ability to host multiple and unlimited websites using Virtual Hosts. Also, there are lots of learning materials on the web about provisioning your VPS instance for the first time.

If you are just starting out on VPS web hosting, I would advise you to buy vps server from Vultr or Digital Ocean and install a Linux distributions such as Ubuntu 16.04 because it is easy to deploy and set according to your needs.