How To Install WordPress on Linux/CentOS 7

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-centos-7

https://hocvps.com/cai-dat-wordpress-tren-centos-6/

https://www.digitalocean.com/community/tutorials/install-wordpress-on-ubuntu

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-22-04-with-a-lamp-stack

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-22-04

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-22-04

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-20-04

Step Two — Install WordPress

Before we download WordPress, there is one PHP module that we need to install to ensure that it works properly. Without this module, WordPress will not be able to resize images to create thumbnails. We can get that package directly from CentOS’s default repositories using yum:

sudo yum install php-gd

Now we need to restart Apache so that it recognizes the new module:

sudo service httpd restart

We are now ready to download and install WordPress from the project’s website. Luckily, the WordPress team always links the most recent stable version of their software to the same URL, so we can get the most up-to-date version of WordPress by typing this:

cd ~
wget http://wordpress.org/latest.tar.gz

This will download a compressed archive file that contains all of the WordPress files that we need. We can extract the archived files to rebuild the WordPress directory with tar:

tar xzvf latest.tar.gz

You will now have a directory called wordpress in your home directory. We can finish the installation by transferring the unpacked files to Apache’s document root, where it can be served to visitors of our website. We can transfer our WordPress files there with rsync, which will preserve the files’ default permissions:

sudo rsync -avP ~/wordpress/ /var/www/html/

rysnc will safely copy all of the contents from the directory you unpacked to the document root at /var/www/html/. However, we still need to add a folder for WordPress to store uploaded files. We can do that with the mkdir command:

mkdir /var/www/html/wp-content/uploads

Now we need to assign the correct ownership and permissions to our WordPress files and folders. This will increase security while still allowing WordPress to function as intended. To do this, we’ll use chown to grant ownership to Apache’s user and group:

sudo chown -R apache:apache /var/www/html/*

With this change, the web server will be able to create and modify WordPress files, and will also allow us to upload content to the server.

Step Three — Configure WordPress
Most of the configuration required to use WordPress will be completed through a web interface later on. However, we need to do some work from the command line to ensure that WordPress can connect to the MySQL database that we created for it.

Begin by moving into the Apache root directory where you installed WordPress:

cd /var/www/html

The main configuration file that WordPress relies on is called wp-config.php. A sample configuration file that mostly matches the settings we need is included by default. All we have to do is copy it to the default configuration file location, so that WordPress can recognize and use the file:

cp wp-config-sample.php wp-config.php

Now that we have a configuration file to work with, let’s open it in a text editor:

nano wp-config.php

The only modifications we need to make to this file are to the parameters that hold our database information. We will need to find the section titled MySQL settings and change the DB_NAME, DB_USER, and DB_PASSWORD variables in order for WordPress to correctly connect and authenticate to the database that we created.

Fill in the values of these parameters with the information for the database that you created. It should look like this:

// ** 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');

These are the only values that you need to change, so save and close the file when you are finished.

Step Four — Complete Installation Through the Web Interface
Now that you have your files in place and your software is configured, you can complete the WordPress installation through the web interface. In your web browser, navigate to your server’s domain name or public IP address:

http://server_domain_name_or_IP
First, you will need to select the language that you would like to install WordPress with. After selecting a language and clicking on Continue, you will be presented with the WordPress initial configuration page, where you will create an initial administrator account:

Fill out the information for the site and administrative account that you wish to make. When you are finished, click on the Install WordPress button at the bottom to continue.

WordPress will confirm the installation, and then ask you to log in with the account that you just created:

To continue, hit the Log in button at the bottom, then fill out your administrator account information:

After hitting Log in, you will be presented with your new WordPress dashboard:

 

 

Leave a Comment

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