There are a few steps that must be completed before you begin to Install WordPress on CentOS 7.

You’ll need a CentOS 7 server with a non-root user with sudo rights installed and configured. On your CentOS 7 server, you’ll also need a LAMP (Linux, Apache, MySQL, and PHP) stack installed.

Install LAMP:

sudo yum update
sudo yum install httpd
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb

sudo mysql_secure_installation
Set root password? [y/n] Y
New password: Type in a password you would like to use
Re-enter new password: Retype the password from the previous field
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

sudo systemctl enable mariadb.service
sudo yum install php php-mysql
sudo systemctl restart httpd.service
sudo systemctl restart apache2

Step 1 – Create a MySQL database and a WordPress user on CentOS 7

To begin, use the following command to log into MySQL’s root (administrator) account:

mysql -u root -p

The password is the one that you have set when you have installed MySQL.

We’ll start by creating a new database that WordPress can manage. You can call it whatever you like, but for the sake of this example, I’ll call it wordpress.

CREATE DATABASE wordpress;

Next, we’ll create a new MySQL user account that will only be used to work with WordPress’s new database. I’m going to give the new account the name wordpressuser and a password of password. Because these samples are not particularly secure, you should absolutely use a separate username and password.

CREATE USER wordpressuser@localhost IDENTIFIED BY ‘password’;

At this point, you have a database and user account that are each specifically made for WordPress. The user, on the other hand, does not have access to the database. We need to connect the two components by allowing our user database access.

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY ‘password’;

We need to flush the privileges now that the user has access to the database, so MySQL is aware of the recent privilege changes:

FLUSH PRIVILEGES;

After we’ve run all of these commands, we may quit the MySQL command line by typing:

exit

Step 2 – Install WordPress on CentOS 7

We’ll need to install one PHP module to make sure everything works properly. WordPress will not be able to resize photos to make thumbnails without this module.

sudo yum install php-gd

We must now restart Apache in order for it to recognize the new module:

sudo service httpd restart

WordPress can be downloaded and installed directly from the project’s website.

cd /var/www/html
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
mkdir /var/www/html/wp-content/uploads
sudo chown -R apache:apache /var/www/html/*

Step 3 – Set up WordPress on CentOS 7

cd /var/www/html
cp wp-config-sample.php wp-config.php

Let’s connect our wp-config.php file with the MySQL database that we have create:

nano wp-config.php

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress’);

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

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password’);

Change the DB_NAME, DB_USER, DB_PASSWORD with the ones that you have created at Step 1

Step 4 – Complete the setup using the web interface.

Navigate to your IP or domain through your browser: http://IP-OR-DOMAIN-NAME

Set your WordPress website a title, description and chose an administrator username and password for the WordPress dashboard login, then hit Install WordPress.

Set your WordPress website a title, description and user

Login to your WordPress Dashboard with the user and password you have chosen.

Login WordPress Dashboard

You may also like to Create a WordPress Website with Elementor Builder Video Tutorial and secure it with this PHP Secure Plugin.

Related Posts

Leave a Reply

Your email address will not be published.