Install Wordpress 5, Nginx, MariaDB 10, and PHP 7 on CentOS or Redhat
WordPress 5 was released recently with some fundamental changes, such as the Gutenberg editor, which is wonderful. In this article we are going to set up WordPress 5 with NGINX, MariaDB 10 and PHP 7 on CentOS
If you want to have a blog or even a website, Wordpress is the ideal choice. And version 5 improved a lot.
In this article we will discuss the installation of Wordpress 5 on a fresh Linux CentOS (with nothing installed).
As a web server, we will install NGINX, which is an excellent web server, much lighter than Apache, ideal for virtual machines.
We will also install PHP 7, which is undoubtedly the best option for Wordpress, since it is capable of running 5x faster than its predecessor, PHP 5.
As a database, we will install the Mysql Open Source FORK, which is MARIA DB version 10, which is also very robust and powerful.
CentOS update
The first step is to update CentOS to make sure you have the latest updates and fixes:
Sudo Yum Update
Nginx Web Server Installation
Now let’s install Nginx, start the service and then enable it to start when the system boots:
Sudo yum install nginx sudo systemctl start nginx.service sudo systemctl enable nginx.service
If you want to delve deeper into Nginx, we have a 3-hour course aimed at making Nginx tinky!
Configuring Nginx for Wordpress
Now let’s configure Nginx to work with Wordpress, creating the site configuration file. To do this, we will edit the file with vim. You can use another editor if you prefer.
sudo vim /etc/nginx/conf.d/wordpress.conf
Now paste the content below into the file:
server {
listen 80;
listen [: :]:80;
root /var/www/html/wordpress;
index index.php index.html index.htm;
server_name _ meusite.com.br www.meusite.com.br;& nbsp; client_max_body_size 100M;
location/{
try_files $uri $uri/ /index.php? $args;
}location ~ .php$ {
includes fastcgi.conf;
fastcgi_pass unix: /run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script _name;
}
} Don’t forget to change mysite.com.br and www.mysite.com.br. If you want to learn more about DNS, we have a DNS Bind 9 course.
Now edit the /etc/nginx.conf file
sudo vi /etc/nginx/nginx.conf
And delete the lines below:
server {
listen 80 default_server;
listen [: :]:80 default_server;
server_name _;
root & nbsp; /var/www/html/wordpress;
# Load configuration files for the default server block.
includes /etc/nginx/default.d/ *.conf;
location/{
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Sudo Systemctl Reload Nginx
Install MariaDB
Now let’s install MariaDB version 10. After installation, we will start the service and then set it to start at boot.
If you want to make your standard MySQL database super oiled up, check out our Mysql tunning course.
Sudo yum install mariadb-server mariadb-client sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
Now, we recommend that you run the MySQL security script. Basically you will set a root password, disable anonymous access, and remove the test database.
Sudo mysql_secure_installation
Create the Wordpress database and login user
Now let’s access the database with the root password that you defined in the previous step, create the database and also create the WordPress user.
Sudo mysql -u root -p
Now, inside the MySQL shell, enter the following commands. Don’t forget to change the password:
The user will be: wp_user and the password you define.
CREATE WORDPRESS DATABASE; CREATE USER ‘wp_user’@‘localhost’ IDENTIFIED BY’ change_to_password ’; GRANT ALL ON wordpress.* TO’ wp_user’@‘localhost’; FLUSH PRIVILEGES; EXIT;
Install PHP 7
In some distributions, PHP 7 may not be available in the standard repository. To do this, let’s enable the PHP 7 repository:
wget https://mirror.webtatic.com/yum/el6/latest.rpm
sudo yum install latest.rpm
Now let’s install PHP 7 on the server. Soon after, we will enable the service and also set it to start when the system boots.
Sudo yum install php-fpm php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysqlnd php-mysqlnd php-cli php-ldap php-zip php-curl php-opcache sudo systemctl start php-fpm sudo systemctl enable php-fpm
You may have to change the suffix of the PHP 7 packages depending on your Redhat. With the command below you can see which php package names are available:
Sudo yum list php*
If you use an Amazon CentOS instance, you can use the following command to install php7:
Sudo amazon-linux-extras install php7.3
sudo yum install php-fpm php-common php-mbstring php-xmlrpc php-soap php-soap php-gd php-xml php-intl php-mysqlnd php-cli php-ldap php-zip php-curl php-opcache
Finally, install Wordpress 5
Now let’s download the latest version of Wordpress 5.
cd /tmp && wget http://wordpress.org/latest.tar.gz
sudo mkdir -p /var/www/html sudo tar -xvzf latest.tar.gz -C /var/www/html sudo chown apache: /var/www/html/wordpress/ -R sudo service nginx reload
Setting up Wordpress for the first time
Now that Wordpress is installed, it’s time to set up access. To do this, you must access the server through your preferred browser.
Enter your server address or its IP. If everything worked out you will see a screen like this:
Choose Brazilian Portuguese and click ahead to set up the database. Change the user to wp_user and enter the password you chose when creating the wp_user user user.
Once this is done, the next step is to configure the Name of Your Site and your user to log in to WordPress.
Now it’s time to log into your Wordpress:
Voila. Your Wordpress 5 with MariaDB 10, Nginx and PHP 7 is ready to use:
Learn much more about Linux in our online course. You can enroll here with a free 7-day trial. If you already have an account, you can log in here.