Set up WordPress in Linux instance

WordPress is an open-source content management system(CMS) that allows you to host and build websites and helps create, manage, and host the website. WordPress provides pre-designing plugins, themes, templates.

Prerequisites:-

**It works on all Linux distributions.

Centos 7

Install Lamp stack

Install Apache and update the firewall

Install Mysql/MariaDB Database

Install PHP

Setup Virtual Webhost

Test PHP Processing

Test Database connection

  • Setup a WordPress in CENTOS:-

Update and Upgrade all the packages :

sudo yum update & yum upgrade -y

Configure Selinux settings :

sudo setenforce 0
sudo sed -i 's/enforcing/disabled/g' /etc/selinux/config
sudo systemctl stop firewalld

Install HTTP service and MySQL database:-


sudo yum install httpd php php-common php-mysqlnd php=mbstring php-gd mariadb-server mod_ssl -y
sudo systemctl start httpd && systemctl start mariadb
sudo systemctl enable httpd && systemctl enable mariadb 

Create a MySQL Database and user for WordPress

sudo mysql -u root -p

Creating a New WordPress Database

To get started with WordPress, the first step is to set up a new database that WordPress will manage. This database will store all your website's necessary information, from user data to content posts. Follow the steps below to create your new database:

To create a new account, use the username user_name and assign it the password

CREATE USER 'username'@'host' IDENTIFIED BY 'password';

Granting Database Access to the WordPress User

Now that you have created a dedicated database and user for WordPress, the next step is to grant the user access to the database. This is crucial for enabling the WordPress installation to interact with its database. Follow these steps to establish the necessary permissions:

  1. Log in to your database management interface, such as phpMyAdmin.

  2. Select the database you created for WordPress from the list on the left-hand side.

  3. Click on the "Privileges" or "Users" tab, depending on your interface.

  4. Find and click on the "Add user to database" option.

  5. In the drop-down menus, select the WordPress user and the WordPress database.

  6. Grant all privileges to the user for this database by checking the option "ALL PRIVILEGES".

  7. Click on the "Make changes" or "Save" button to apply the permissions.

With these steps, your WordPress user now has full access to its database, allowing for a smooth WordPress installation and operation.

GRANT ALL PRIVILEGES ON database.* TO 'username'@'host' IDENTIFIED BY 'Password@123$#@' WITH GRANT OPTION;

To ensure MySQL recognizes the recent changes to privileges, it's necessary to flush the privileges.

FLUSH PRIVILEGES;

Download WordPress through the internet:-

curl -O https://wordpress.org/latest.tar.gz
tar zxvf latest.tar.gz
mv wordpress/* /var/www/html/ 
chown -R apache:apache /var/www/html/
  • Downloading and Installing PHP

To download and install PHP, follow these steps:

To install PHP, first download the package. You can acquire the package directly from CentOS default repositories using the yum command.

yum install epel-release yum-utils -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php74

After downloading the necessary PHP package:

Install PHP:

yum install php php-mysql -y
php -v
systemctl restart httpd
systemctl restart mariadb 

Complete installation Through the web Interface:

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.

Configure WordPress

Select the Language:

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, click the login button at the bottom:-

You will be presented with your new WordPress dashboard:

Last updated