How to Set Up WordPress on an Unmanaged VPS Hosting Plan

siddhant sugan dodrai
By -
0

VPS (Virtual Private Server) hosting packages have come a long way since the days of shared plans and are now quite affordable. If you are thinking about getting VPS hosting for your next project, you have probably noticed that there are two main types of VPS solutions: Managed and unmanaged.

How to Set Up WordPress on an Unmanaged VPS Hosting Plan


Today, we are going to look at the UnManaged VPS vs. Managed VPS options for WordPress.

In a nutshell, yes, it does. Both the managed VPS packages and the unmanaged VPS packages (also known as self-managed) support WordPress websites.

WordPress is an open-source CMS that only requires a PHP and MySQL database to run smoothly.

Want to know how to install WordPress on unmanaged VPS? We've got you covered.

In today's post, we'll walk you through the process of installing WordPress on a VPS hosting plan.


Things to know before you start

A managed VPS, on the other hand, is, of course, more user-friendly. You’ll have a control panel where most of your hosting service can be managed, including your files and databases, as well as your email accounts. Most control panels also include automatic installers for popular applications like WordPress. Most of the time, you’ll be able to manage everything through a graphical user interface (GUI). Your hosting provider will configure your server and the software that’s installed by default.

Of course, your hosting provider also provides dedicated support. Whenever you need help with a technical issue, you can reach out to an expert and solve the problem.

On the other hand, an unmanaged virtual private server (VPS) is set up by the hosting provider. Typically, you are given the option to choose the operating system you would like to use during the sign-up process. The hosting provider will set up the VPS with the operating system you have chosen and provide you with full access to the operating system.

As the term self-managed implies, from this point on, you are essentially on your own.

It’s entirely up to you to set up and install everything, including the database management application (DBAs) and the content management system (CMS). You’re free to customize everything as you see fit, which is good if you have more in-depth needs.

On the other hand, you’ll need a lot more technical know-how. If you’re sure you can manage the whole server, you can confidently choose a self-managed virtual private server (VPS) and select one of several ways to install WordPress on it.

What should you prepare?

There are a few different ways to do this. For instance, you can choose to install a control panel first, which will allow you to manage your hosting service in the same way as a managed solution. The world’s two most popular control panel platforms are cPanel and Plesk, both of which have automatic WordPress installers built-in. However, setting up the control panel can be difficult, and you’ll likely have to pay licensing fees, which can eat into your budget.

There are other alternatives as well. One of them is EasyEngine. It is a command line tool that can be used to install Nginx and MySQL as well as PHP and WordPress at the same time. It is not as easy as an installer but it is still relatively simple.

If you want to install WordPress with EasyEngine, you can read our tutorial - Install Wordpress With EasyEngine. ⬅️

EasyEngine is a free, open-source platform. If you prefer to use Apache instead of Nginx, then EasyEngine will be of little use to you. It can only be used with Ubuntu and Debian and its developers do not plan to support any other distro or operating system.

Manually installing WordPress on an unmanaged VPS

What is a LAMP stack? LAMP stands for Linux, Apache, MariaDB and PHP. It is a collection of open source software that is used to host dynamic web pages and applications on the Internet. The LAMP server is the main requirement for any PHP-based applications. In this section we will show you how to set up the LAMP server on Debian 10 or 11.

Step 1. Install Apache Web Server

Apache web server is the world’s most popular web server. It’s the default web server for hosting websites. To install the Apache web server package on your server, run the following command:
# Run this Command Line to install Apache in your server 
apt-get install apache2  -y
Once the installation is complete, run the Apache service and allow it to run after restarting the system.
# Re-start and enable Apache 
systemctl start apache2
systemctl enable apache2

Step 2. Install PHP 8

The most recent version of PHP, as of the writing of this article, is the 8.0 version. The 8.0 version has a lot of improvements in performance and new features, so it is always a good idea to install 8.0 on the server. 

The 8.0 version is not available in the default repository of Debian 10 / 11, so you will have to add it to the server. To install 8.0, you can use the following command to install the necessary dependencies.

# Install Necessary Dependencies 
apt-get install gnupg2 ca-certificates apt-transport-https software-properties-common -y

Next, add PHP Sury to the APT folder and use the following command to add GPG key:

# Add PHP Sury to the APT folder 
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -

Update the repository with PHP 8.0 and install all PHP extensions required for WordPress with the following command:

apt-get update -y
apt-get install php libapache2-mod-php php-pear php-cgi php-common php-mbstring php-zip php-net-socket php-gd php-xml-util php-gettext php-mysql php-bcmath unzip wget git -y

You can now verify the PHP version by running the following command:

php -v

Sample Out is :-

PHP 8.0.9 (cli) (built: Jul 30 2021 13:09:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies

Step 3. Install MariaDB Database Server

MariaDB is a database backend used by WordPress to store and maintain a site and its user information. In this post, we will be installing and using MariaDB.

MariaDB is the default database backend for WordPress. It is also included in the default repository of Debian 10 / 11. To install MariaDB, you can run the following command:
apt-get install mariadb-server mariadb-client -y

Once MariaDB is installed, run MariaDB and allow MariaDB to run at system startup.

systemctl start mariadb
systemctl enable mariadb

MariaDB installation is unsecured by default. To unsecured MariaDB installation, use the following script:

mysql_secure_installation

You’ll be asked to: Set a root password for MariaDB, Remove anonymous users, Disallow root login remotely, Disallow test database as described below.

Enter current password for root (enter for none):
Change the root password? [Y/n] Y
New password:
Re-enter new password:
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

Step 4. Create a WordPress Database

Next, you’ll need to set up your WordPress database and user interface on MariaDB. The first step is to connect to MariaDB using the following command:

mysql -u root -p

Enter the root password for MariaDB and then run the following command to create the database and user:

CREATE DATABASE wordpressdb;
GRANT ALL PRIVILEGES ON wordpressdb.* to wordpressuser@localhost identified by 'strongpassword';

Next, clear the permissions to execute the changes and close MariaDB with the following command:

FLUSH PRIVILEGES;
QUIT;

Step 5. Download and install WordPress in Your VPS

Now, you’ll need to install WordPress on your site. The best way to do this is to download WordPress from its official website. To do this, go to your server’s web root directory and type:
cd /var/www/html

Then use wget to get download the most recent version of WordPress.

wget https://wordpress.org/latest.zip

Next, open the downloaded file and use the unzip command to unzip it:

unzip latest.zip

Then, change the name of the directory to your chosen domain name.

mv wordpress yourdomain.com

Next, go to yourdomain.com directory and make a copy of the sample configuration file.

cd yourdomain.com
cp wp-config-sample.php wp-config.php

Next, go to your WordPress configuration file and set up your database settings:

nano wp-config.php

Change the following lines that match your database settings:

/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpressdb' );

/** MySQL database username */
define( 'DB_USER', 'wordpressuser' );

/** MySQL database password */
define( 'DB_PASSWORD', 'strongpassword' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

define('FS_METHOD', 'direct');

Once you are done, save the file. Then, modify the domain.com ownership to www-data.

chown -R www-data:www-data /var/www/html/yourdomain.com

Step 6. Create Apache Virtual Host for WordPress

The next step is to set up an Apache Virtual Host configuration file (AVH file) for WordPress. To set up an AVH file, you can use the following command:
nano /etc/apache2/sites-available/yourdomain.conf

Add the following Lines

<VirtualHost *:80>
ServerAdmin user@yourdomain.com
        ServerName yourdomain.com
        DocumentRoot /var/www/html/yourdomain.com

        <Directory "/var/www/html/yourdomain.com">
             AllowOverride All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/yourdomain.error.log
        CustomLog ${APACHE_LOG_DIR}/yourdomain.access.log combined
</VirtualHost>

After saving and closing the file, check the configuration file to see if there are any syntax errors.

apache2ctl configtest

Out put

Syntax OK

Next, run the following command to run the rewrite module on your Apache virtual host:

a2ensite yourdomain
a2enmod rewrite

Finally, run the Apache service again to execute the configuration changes.

systemctl restart apache2

Step 7. Enable https or SSL Certificate in Your Website

To encrypt the HTTP traffic on your WordPress website, we always recommend enabling the HTTPS. To enable the HTTPS, you must install and configure Let's Encrypt free SSL.

To install the Let's Encrypt client package, run the following command:
apt-get install certbot python3-certbot-apache -y

Now, go to your WordPress site and execute the following command to get and install the LETS Encrypt certificate.

certbot --apache --agree-tos --redirect --hsts --uir --staple-ocsp --email user@yourdomain.com -d yourdomain.com,www.yourdomain.com

This command downloads the Let's Encrypt SSL certificates and configures your Apache server to use them.

The next step is to create a cron task to automatically renew the Let's Encrypt certificate. To create the cron task, modify the following command:

crontab -e

Add here following Lines

@daily certbot renew --quiet &amp;&amp; systemctl reload apache2

Once you are done saving and closing the file, run the above cron job on a daily basis and automatically renew SSL certificates when they expire.

Step 8. Access Your WordPress Website

Open your web browser and navigate to the WordPress installation wizard by using the following URL: https://Yourdomain.com
You will be taken to the language screen:
WordPress language Settings

Choose the language you want to use and click Continue. You should now be in the WordPress site settings screen.

WordPress site Configuration

Enter your site details and click Install WordPress.

Once the installation is complete, you’ll see the following:

WordPress wp login page

Click on the 'Login' button. You'll be taken to the WordPress login page.

WordPress Dashboard

Conclusion

In the above-mentioned guide, we have shown you how to install the wordpress on the apt-get platform. We have also shown you how to enable the HTTPS on the wordpress site using the let’s encrypt free SSL.

Now you can begin writing your first blog using the wordpress platform on Debian 10 / 11.
There are a lot of different ways to set up WordPress, and for some users, the idea of manually setting up the CMS may seem daunting. However, if you take the time to understand the process outlined above, you shouldn’t have any issues setting up the CMS and enjoying the benefits of your self managed VPS.

If you want to Setup Your WordPress in Other installation Process. Click the below article to learn more Tutorial Guide.

👉 Self managed VPS install WordPress With Webionly.

👉 Self managed VPS install WordPress With EasyEngine.

👉 Self managed VPS install WordPress With WordOps.

👉 Self managed VPS install WordPress With Cyberpanal.

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!