How to install wordpress using SSH on Centos 7 VPS

To install wordpress via SSH you need a VPS with –
A non-root user account
Apache installed and running
Mariadb / MySQL active and running
PHP installed (recommended version 7.x)

First install PHP modules php-gd and php-xml otherwise certain features in wordpress will not work properly.

Now restart the server for changes to take effect.

Next we need to install wget if you haven’t already. Without wget we won’t be able to download wordpress

Now go to your home directory cd ~ or cd $HOME

Download wordpress using the following command

Now we are going to extract the contents of our downloaded file latest.tar.gz to the document root or the directory in which you want to install wordpress.
I am going to install wordpress in /var/www/html/example.com where example.com is the domain specific directory about which I talked in my virtual host tutorial

After running the above command all the required wordpress files and directories will be extracted to your specified directory.
wordpress files

Now go to the directory where you extracted latest.tar.gz in the previous step and create a new directory named uploads inside the wp-content directory using the command below

Now we need to create wordpress configuration file wp-config.php with the contents
of wp-config-sample.php

So now our wordpress configuration file wp-config.php has been created its time to edit this file with database details.
If you have already created database and user for your wordpress installation then skip this step.

First log in to mariadb MySQL database management system.

After logging in create a new database with the following command. (Replace my_database with the name that you want to give to your database)

Next grant all privileges and create a new user for the database. (Replace username with the name you want to give to the database user and in place of pass enter a strong password)

Other useful commands
To view databases:
show DATABASES; To view users
SELECT User, Host FROM mysql.user;

Now that we have database name, user and password we are going to edit wp-config.php
Open the file in vi or any other editor of your choice

wp config settings
In this file you need to edit those three things which I have underlined in place of database_name_here enter your database name it should be inside single quotes
Replace username_here with the username you created in the previous step and password with the password you assigned while creating the user.
After making the necessary changes save and quit the file.

This step is optional. Create a .htaccess file in the main directory where all your wordpress files are. Sometimes .htaccess doesn’t generate on its own.

Copy and paste the following code in the .htaccess file and then save and quit the file.

The last thing you would want to do is change the ownership of wordpress files and directories.

This will change the owner and group of files and directories to apache which is an equivalent of www-data in Centos.

Now everything is done, open the url of your website in your browser and you would see wordpress installation page
wordpress install page
Every thing from here on is very self explanatory you just need to choose your language and create a wordpress admin account.

Previous Post
Configuring Virtual Host In Centos 7 VPS
Next Post
How to change SSH port on CentOs 7 VPS

Related Posts

2 Comments. Leave new

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Menu