Install WordPress in CentOs 9 Stream

siddhant sugan dodrai
By -
0

WordPress is one of the most popular PHP-based Content Management Systems (CMSs) in the world. If you are looking for a CMS for your small business, personal blogs and websites, then you should definitely check out WordPress. 

Install WordPress in CentOs 9 Stream


In this article, you will learn about installing WordPress on the CentOS Stream 9 operating system. Let’s begin.

Pre-requisite

✔️ A system with CentOS Stream 9 installed and running.

✔️ root access to the system.

✔️ LEMP Stack installed and running, on Your CentOS 9 Stream 


Install LEMP Stack in Your CentOs 9 Stream

It’s one of the most popular Software Stacks used to build your web applications and is also referred to as LEMP stack (Linux, nginx, MySQL/ MariaDB, PHP/ Perl/Python).

First, we are going to install Nginx. To install Nginx, run the following command:
# Install Nginx server in CentOS 9
yum install nginx -y
Once the installation is done, run Nginx (it will automatically start when the system boots), run the web server, and check the status using the following commands:

# After Nginx server installed in CentOS 9 run following Command one by one
systemctl start nginx
systemctl enable nginx
systemctl status nginx
To publish your pages to the Web, you’ll need to modify your firewall policies to enable HTTP on your Web server using the following command:

# Run this Command to enable https and http
firewall-cmd --permanent --zone=public--add-service=http 
firewall-cmd --permanent --zone=public --add-service=https 
firewall-cmd --reload
If this Command not Work. Install firewall in your CentOS 9 by following Command

# Install firewalld server in CentOS 9
yum install firewalld -y
# Start and enable firewalld
systemctl start firewalld
systemctl enable firewalld 
Then again run the Command to enable https and http .



Check that the web server is up and running by accessing the IP address of your web server from your browser.
http://your-ip-address
CentOs 9 Access your ip address


we need to make user Nginx the owner of the web directory.  By default, it's owned by the root user.
chown nginx:nginx /usr/share/nginx/html -R

Install Mariadb Server

MariaDB is one of the most widely used database servers. The installation of MariaDB is straightforward and only takes a few clicks as shown below.

yum install mariadb-server mariadb -y
Once installation is done, set MariaDB (automatically start MariaDB when the system boots), run mariaDB, and check the status with the following commands:
systemctl start mariadb

systemctl enable mariadb 

systemctl status mariadb
Finally, you’ll need to close your MariaDB by executing the following:

mysql_secure_installation
Once you are all set up, you can use the following command to access MySQL and check your existing databases on the database server.
[root@server ~]# mysql -e "SHOW DATABASES;" -p
Enter password:
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
[root@server ~]#

Install PHP

To Install PHP-FPM on CentOS Stream 9

yum install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring -y
Output:
Install PHP in CentOs

Once the installation is done, run the following commands:

Enable PHP-fpm (automatically startup PHP-fpm) ,Run PHP-fpm, Run the following commands to check the status:
systemctl start php-fpm

systemctl enable php-fpm

systemctl status php-fpm
PHP-FPM is set to run as apache user by default. Since we are running on Nginx, we need to update the following line:
vi /etc/php-fpm.d/www.conf 
user = apache 
group = apache
Change them
user = nginx
group = nginx
Once changed, need to reload php-fpm

systemctl reload php-fpm
To test your PHP, you will need to create a file named info.php with the PHPinfo() function. This file should be located in the root directory of your web server. In this case, it will be in the directory name of the web server. For example, the directory name of your web server will be /usr / share/nginx / html/ info.php.
echo "<?php phpinfo() ?>" > /usr/share/nginx/html/info.php
Restart the Nginx and PHP-FPM.
systemctl restart nginx php-fpm
To do this again, go to the following URLs: 

Your Server-IP-Address / info.php 
Your IP Address / info.php You should now see a page like the one below.
Check phpini info in CentOs 9

You have successfully installed LEMP Stack in Centos 9.  Next we'll see how you install WordPress.
Other Way to Install WordPress in Your VPS Click to the Tutorial


Install WordPress in CentOs 9

WordPress is currently one of the most widely used CMS (Content Management System) on the internet. It allows you to create flexible blogs and websites by using a MySQL backend as well as PHP processing. At present, WordPress is being used at a very high rate by new and experienced engineers alike. It is one of the best CMS for quick website setup. After first setting up WordPress, almost all website administration can be done through the graphical interface. These and many other features make WordPress an ideal CMS for websites that are built to grow.

What is LEMP stack?
The LEMP stack is a collection of free software used to initialize and run web servers. LEMP stands for “Linux”, “Nginx,” “MySQL,” and “PHP”.
Arch Linux is already installed on the server.

1. Setup the MySQL database for WordPress

WordPress uses a relational database to store information about your site and its users. You may already have MariaDB (a MySQL derivative) installed, but we still need to build a database and create a user for it to work with.
# mysql -u root -p 
# Create a Database and User in your CentOs

> CREATE DATABASE wordpressdb;

> CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';

> GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost IDENTIFIED BY 'password';

> Flush Privilege;

> Exit;

2. Download and install the WordPress

Before we download WordPress, we need to install one PHP module. Without this module, WordPress cannot resize photos to create thumbnails. We can use yum to get the package directly from the CentOS's default repositories.

# yum install php-gd
Now we need to restart nginx service so that it recognizes the new module:

# systemctl restart nginx 
Now use the wget command to download the most recent version of WordPress and tar command to extract the newly downloaded version of WordPress.

# wget http://wordpress.org/latest.tar.gz
Extract it,
# tar -zxvf latest.tar.gz
After you have extracted the last.tar.gz from the tarball, you will now see a new directory called wordpress. You can either move the content from this directory to your site directory, or you can move it to your server's default page directory.

# mv wordpress/* /usr/share/nginx/html/  
Please note that, in some case, nginx uses the same root directory of your website same as apache/ httpd which /var/www/html. You can ensure this by looking at the keyword 'root' in /etc/nginx/nginx.conf.

3. Configure the WordPress.

Later, we’ll use a web interface to complete most of the WordPress configuration. To ensure that WordPress can access the MySQL database we’ve configured for it, there are a few things we’ll need to do on the command line:
WordPress’s main configuration file is wp- configure.php. By default, the installation comes with a sample configuration file that most of the time matches what we’re looking for. To get WordPress to recognize and use this file, we just need to copy it to where it’s supposed to go:
cd /usr/share/nginx/html
cp wp-config-sample.php wp-config.php
The only thing that needs to be changed in this file are the parameters that contain the data stored in our database. In the MySQL settings, you will need to change the DB NAME variables (Database Name), DB USER variables (Database User Name), and DB PASS WORD variables in order for WordPress to authenticate and connect to the database we created.

Using the data stored in the database you created, enter the values of the following parameters:
Setup Database, user, wp-config.php

4. Complete the installation of WordPress

Now goto your favourite browser and hit your server ip.

http://serverip_or_domain-name
Here, fill in your database information, which you created for your wordpress in Step 1, and click on Submit button.

Here, on this screen, click on 'Installing now'.
Install wordpress in CentOs


And that’s all! You’ve successfully installed WordPress on your CentOS with LEMP. Login to your Wordpress dashboard. Start blogging.







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!