Friday 28 February 2020

How to Install WordPress with LAMP on CentOS 7



WordPress is an open source and most widely used software for blogging, content management software, websites etc. It’s written in PHP and used MySQL/MariaDB for database.
This article describes How to Install WordPress with LAMP on CentOS7.

Step 1. LAMP Stack Installation: Follow the article Howto Install the LAMP (Linux, Apache, MySQL/MariaDB and PHP) Stack on CentOS 7. Due to WordPress recommendation php 5.6.x or higher version is required, follow the article Howto Install PHP 7.3 Latest Version on CentOS 7.

[root@linuxcnf ~]# yum install --enablerepo=remi-php73 php
Loaded plugins: fastestmirror
…………………….
Installed:
  php.x86_64 0:7.3.15-1.el7.remi

Dependency Installed:
  libargon2.x86_64 0:20161029-3.el7       php-cli.x86_64 0:7.3.15-1.el7.remi       php-common.x86_64 0:7.3.15-1.el7.remi       php-json.x86_64 0:7.3.15-1.el7.remi

Complete!
[root@linuxcnf ~]#

[root@linuxcnf ~]# yum install --enablerepo=remi-php73 php-mysqlnd
Loaded plugins: fastestmirror
…………………….
Installed:
  php-mysqlnd.x86_64 0:7.3.15-1.el7.remi

Dependency Installed:
  php-pdo.x86_64 0:7.3.15-1.el7.remi

Complete!
[root@linuxcnf ~]#

Step 2. Database Configuration: Create a database and a user for WordPress to access that database:

Run the following commands to create a database:

[root@linuxcnf ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.64-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]>

Create a User and grant all privileges on wordpress database:

MariaDB [(none)]> grant all privileges on wordpress.* to wordpress@localhost identified by 'w0rdpr$55';
Query OK, 0 rows affected (0.03 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye
[root@linuxcnf ~]#

Step 3. WordPress Installation: Download the WordPress from the official site and copy it the web server document directory:

Run the following command to install php-gd wordpress prerequisites:

[root@linuxcnf ~]# yum install --enablerepo=remi-php73 php-gd
Loaded plugins: fastestmirror
…………………….
Installed:
  php-gd.x86_64 0:7.3.15-1.el7.remi

Dependency Installed:
  dejavu-fonts-common.noarch 0:2.33-6.el7   dejavu-sans-fonts.noarch 0:2.33-6.el7   fontconfig.x86_64 0:2.13.0-4.3.el7   fontpackages-filesystem.noarch 0:1.44-8.el7
  gd-last.x86_64 0:2.2.5-10.el7.remi        jbigkit-libs.x86_64 0:2.0-11.el7        libtiff.x86_64 0:4.0.3-32.el7        libwebp7.x86_64 0:1.0.3-1.el7.remi

Complete!
[root@linuxcnf ~]#

Download WordPress from it official site:

[root@linuxcnf ~]# cd /tmp
[root@linuxcnf tmp]# curl -O https://wordpress.org/latest.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11.8M  100 11.8M    0     0   384k      0  0:00:31  0:00:31 --:--:--  591k
 [root@linuxcnf tmp]# ls -ltrh latest.tar.gz
-rw-r--r--. 1 root root 12M Feb 27 22:10 latest.tar.gz
[root@linuxcnf tmp]#

Unzip the file and copy the contents to the web document root directory:

[root@linuxcnf tmp]# tar -xzvf latest.tar.gz
……………………….
wordpress/wp-admin/post-new.php
wordpress/wp-admin/themes.php
wordpress/wp-admin/options-reading.php
wordpress/wp-trackback.php
wordpress/wp-comments-post.php
[root@linuxcnf tmp]# cd wordpress/
[root@linuxcnf wordpress]# cp -r * /var/www/html/
[root@linuxcnf wordpress]# cd /var/www/html/
[root@linuxcnf html]# ls
index.php    readme.html      wp-admin            wp-comments-post.php  wp-content   wp-includes        wp-load.php   wp-mail.php      wp-signup.php     xmlrpc.php
license.txt  wp-activate.php  wp-blog-header.php  wp-config-sample.php  wp-cron.php  wp-links-opml.php  wp-login.php  wp-settings.php  wp-trackback.php
[root@linuxcnf html]#

Step 4. WordPress Configuration: Follow the below steps to configure WordPress:

Create a folder on the below path to store uploaded data:

[root@linuxcnf html]# mkdir -p wp-content/uploads
[root@linuxcnf html]#

Now set the correct ownership and permission on the WordPress files and directories:

[root@linuxcnf html]# chown -R apache:apache *
[root@linuxcnf html]#

Make a copy of WordPress configuration and update the parameters for database configuration as below:

[root@linuxcnf html]# cp -p wp-config-sample.php wp-config.php
[root@linuxcnf html]# vi wp-config.php
<?php
………………………..
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress');

/** MySQL database username */
define( 'DB_USER', 'wordpress' );

/** MySQL database password */
define( 'DB_PASSWORD', 'w0rdpr$55' );
……………………….
[root@linuxcnf html]#

Run the following command to restart the httpd service to reflect all the above changes;

[root@linuxcnf html]# systemctl restart httpd
[root@linuxcnf html]#

Step 5. Verify the Installation: Finally, browse the URL http://<Server IP Address/Hostname> to access the WordPress configuration page and further configuration as shown in below screen shot:



















Done!!! Now follow the further instruction to complete initial setup of WordPress.

No comments:

Post a Comment