Switching your WordPress Website from shared hosting to a Virtual Private server is a complex task which may need some sort of technical knowledge of Linux server administration and setting up the WordPress blog in VPS. 

if you’re new to the world of VPS hosting or WordPress installation, the process can be daunting. Fear not! In this post, we’ll explain what you need to know to successfully install WordPress on your VPS and set yourself up for success. 

I. Introduction of WordPress VPS Hosting

Installing WordPress on Cpanel is simple and easy which dont need any technical skill for setting up WordPress Website but deploying WordPress on VPS which is completely CLI need some basic technical knowledge of server management and in this blog we have provided the stepwise process which can be beneficial to anyone looking for WordPress Website setup on VPS. With a VPS, you have complete control over your server resources, ensuring faster loading times, increased uptime, and the ability to handle high levels of traffic. 

Additionally, a VPS server provides a dedicated environment for your WordPress site, reducing the risk of security breaches. By installing WordPress on a VPS, you can harness the full power of this popular CMS and take your website to the next level. 

Having a VPS server for your WordPress site is crucial for several reasons. Firstly, with a VPS server, you have dedicated resources that are not shared with other websites, ensuring optimal performance and speed. This is especially important if you have a high-traffic or resource-intensive website. 

Secondly, a VPS server provides scalability, allowing you to easily upgrade your resources as your site grows and attracts more traffic. This ensures that your site can handle increased demand without any downtime or performance issues. 

Finally, a VPS server offers better security as you have full control over your server environment, reducing the risk of your site being compromised. Overall, having a VPS server for your WordPress site ensures better performance, scalability, and security, making it a valuable investment.

II. Selecting the right OS and VPS server

When it comes to choosing the right operating system for your VPS server, there are a few factors to consider. Firstly, you’ll want to ensure compatibility with the software and applications you plan to use on your server. 

Additionally, consider the level of technical expertise required to manage the operating system. Some operating systems, like Ubuntu Server 20.04, are known for their user-friendly interfaces and extensive documentation, making them a popular choice for beginners. 

On the other hand, more advanced users may opt for operating systems like CentOS or Debian, which offer greater flexibility and customization options. 

Ultimately, choosing the right operating system for your VPS server depends on your specific needs and preferences. 

III. Install LAMP stack & WordPress

The LAMP stack, which stands for Linux, Apache, MySQL, and PHP, is a popular software bundle often used for web application development and hosting. Each component plays a crucial role in the overall functionality of the stack. Linux serves as the operating system, providing a stable and secure platform.

Apache is the web server software that handles incoming requests and serves webpages. MySQL is the relational database management system used to store and retrieve data. Lastly, PHP is the scripting language used to process dynamic content and interact with the database. Together, these components create a powerful and flexible environment for hosting websites, particularly those built with WordPress. 

Steps to install LAMP stack on your VPS Ubuntu server.

When it comes to installing a LAMP stack on your VPS server, there are a few important steps to follow. First, make sure you have a root sudo user and that your server is set up according to the initial server setup guide for your specific OS. Once you have that in place, you can proceed with the installation. 

Start by updating and upgrading your package list, then install Apache, PHP, and MySQL using the appropriate commands. Configure Apache and PHP to ensure they are working together seamlessly, and create a MySQL database for your WordPress site. 

Finally, download and install WordPress on your VPS server, and configure it for your website’s needs. 

By following these steps, you’ll have a fully functional LAMP stack ready to support your WordPress installation on your Ubuntu server. 

/** Update the pacakage **/

apt install sudo nano -y 

Configuring Apache and PHP

Configuring Apache and PHP is an essential step in the process of setting up a WordPress site on a VPS server. Apache is a widely used web server that provides the foundation for hosting websites, while PHP is the scripting language that powers dynamic content on those websites. To configure Apache and PHP, you need to install and enable the necessary modules and extensions. This includes setting up the Apache virtual host for your WordPress site, adjusting the php.ini file to optimize PHP performance, and ensuring that the necessary PHP extensions are installed. Proper configuration of Apache and PHP is crucial for the smooth functioning of your WordPress site and ensuring optimal performance.

/**  PHP Repository **/
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 -y 


echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list 


wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add - 


apt update && apt upgrade –y 

Installing PHP8.2

Installing PHP8.2 is an essential step in configuring a robust and efficient WordPress site on your VPS server. PHP is a server-side scripting language that powers dynamic web pages, and version 8.2 offers various features and improvements for enhanced performance and security. To install PHP8.2, you need to ensure that you have a LAMP stack set up on your server, which includes Linux, Apache, MySQL, and PHP. This will enable your website to run smoothly and efficiently, delivering a superior user experience. 

/** Installation of PHP8.2 **/

apt install php8.2 -y

Adjusting the php.ini

Adjusting the php.ini file is an important step in configuring your WordPress installation on a VPS server. The php.ini file is a configuration file that controls various aspects of how PHP functions on your server. It allows you to adjust settings such as memory limits, file upload sizes, and error reporting. By modifying the php.ini file, you can optimize the performance and functionality of your WordPress site. It’s important to understand the impact of each change and to make adjustments based on the specific needs of your site. This ensures that your WordPress installation runs smoothly and efficiently, providing an optimal user experience. 

nano /etc/php/8.2/apache2/php.ini 

  • memory_limit = 1024M 
  • upload_max_filesize = 16G  
  • post_max_size = 16G  
  • date.timezone = <YourTimezone>

Setting up MySQL database and user

Setting up a MySQL database and user is an essential step in installing WordPress on your VPS server. By creating a dedicated database and user, you can ensure better management and security for your WordPress site. To begin, log into the MySQL root account and create a database specifically for WordPress. Choose a name that is relevant to your site. Next, create a separate MySQL user account and set a strong password for added security. Grant this user complete access to the database you just created. Lastly, remember to flush the privileges so that MySQL registers the changes. With these steps completed, you can proceed with the installation process confidently. 

/** Installation of Database **/
apt install apache2 unzip wget curl mariadb-client mariadb-server

mysql –u root –p

create database wordpress;

create user 'wordpress'@'localhost' identified by 'PASSWORD';

grant all privileges on wordpress.* to ‘wordpress’@’localhost’;

flush privileges;

Downloading and Installing WordPress

To download and install WordPress on your VPS server, you’ll first need to navigate to the official WordPress website and download the latest installation files. Once you have the files, you can place them in the default web server root directory on your VPS, which is usually “/var/www/html”. After extracting the files, you’ll need to ensure that the correct permissions are set, so that your web server has ownership of the WordPress files. This is typically done by running a command to change the owner to the web server user, such as “chown -R www-data:www-data /var/www/html“. With these steps complete, you’re now ready to proceed with setting up and configuring WordPress for your website.

/** Installation of Default index file **/

cd /var/www/html && rm index.html

/** Download latest WordPress **/

cd /home && wget https://wordpress.org/latest.zip

unzip latest.zip
rm latest.zip

cp -R /home/wordpress/* /var/www/html

/** Change Ownership **/

chown -R www-data:www-data /var/www/html

sudo find /var/www/html -type d -exec chmod 755 {} \; 

sudo find /var/www/html -type f -exec chmod 644 {} \;

Setting up a Reverse-Proxy

 /** Edit the File and paste the code **/

nano /etc/apache2/sites-available/wordpress.conf

<VirtualHost *:80> ServerAdmin <YourEmail> DocumentRoot /var/www/html/ ServerName <Your(Sub)Domain> <Directory /var/www/html/> Options +FollowSymlinks AllowOverride All Require all granted <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/html SetEnv HTTP_HOME /var/www/html </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>


a2ensite wordpress.conf

systemctl restart apache2

Installing an SSL Certificate via Certbot

You can configure your website’s security measures, such as enabling HTTPS with an SSL certificate via Certbot. By taking the time to properly configure WordPress, you can ensure that your website runs smoothly and provides an excellent user experience. 

apt install certbot python3-certbot-apache -y

certbot --apache

Finish the WordPress Setup through Browser

You can directly visit the domain name in browser and you will get screen :


Click on Lets go! >>

Provide the wordpress database and username as desired:

Provide the details for admin access and WordPress Website title:


In this way, you have successfully installed WordPress on your VPS and you can also add the additional .htaccess rule to redirect HTTP traffic to HTTPS protocol which also gives a padlock on browser.


 /** From Terminal **/

nano /var/www/html/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]