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 LEMPStack on CentOS7.
Done!!! Now follow the further instruction to complete initial setup of WordPress.
This article describes How to Install WordPress with LEMPStack on CentOS7.
Step 1. LAMP Stack Installation: Follow
the article Howto Install the LEMP 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 php-mysqlnd -y
Loaded plugins:
fastestmirror
…………………….
Installed:
php.x86_64 0:7.3.15-1.el7.remi
php-mysqlnd.x86_64 0:7.3.15-1.el7.remi
Dependency Installed:
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 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 11
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.00 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-fpm php-opcache php-gd php-xml php-mbstring php-fpm php-curl
Loaded plugins:
fastestmirror
…………………….
Installed:
php-fpm.x86_64 0:7.3.16-1.el7.remi php-gd.x86_64 0:7.3.16-1.el7.remi php-mbstring.x86_64
0:7.3.16-1.el7.remi
php-opcache.x86_64 0:7.3.16-1.el7.remi
php-xml.x86_64 0:7.3.16-1.el7.remi
Dependency Installed:
oniguruma5.x86_64 0:6.9.4-1.el7.remi
Updated:
php-common.x86_64 0:7.3.16-1.el7.remi
Dependency Updated:
php.x86_64 0:7.3.16-1.el7.remi php-cli.x86_64 0:7.3.16-1.el7.remi php-json.x86_64
0:7.3.16-1.el7.remi
php-mysqlnd.x86_64 0:7.3.16-1.el7.remi
php-pdo.x86_64 0:7.3.16-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 613k
0 0:00:19 0:00:19 --:--:-- 695k
[root@linuxcnf tmp]#
ls -ltrh latest.tar.gz
-rw-r--r--. 1 root
root 12M Mar 15 21:18
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/widgets.php
wordpress/wp-admin/setup-config.php
wordpress/wp-admin/install.php
wordpress/wp-admin/admin-header.php
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]# 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
wordpress]#
[root@linuxcnf
wordpress]# mkdir -p
/usr/share/nginx/wordpress-data
[root@linuxcnf
wordpress]# cp -r *
/usr/share/nginx/wordpress-data/
[root@linuxcnf
wordpress]# cd
/usr/share/nginx/wordpress-data/
[root@linuxcnf
wordpress-data]# ls
index.php logs 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
license.txt readme.html
wp-admin
wp-comments-post.php wp-content wp-includes wp-load.php wp-mail.php wp-signup.php xmlrpc.php
[root@linuxcnf
wordpress-data]#
|
Step 4. WordPress Configuration: Follow
the below steps to configure WordPress:
Create
a folder on the below path to store uploaded data:
[root@linuxcnf
wordpress-data]# mkdir -p
wp-content/uploads
[root@linuxcnf
wordpress-data]#
|
Now set
the correct ownership and permission on the WordPress files and directories:
[root@linuxcnf
wordpress-data]# chown -R nginx:nginx
*
[root@linuxcnf
wordpress-data]#
|
Make a
copy of WordPress configuration and update the parameters for database
configuration as below:
[root@linuxcnf
wordpress-data]# cp -p
wp-config-sample.php wp-config.php [root@linuxcnf wordpress-data]# 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
wordpress-data]#
|
Step 4. Nginx Configuration: Open
the Nginx configuration file and modify as shown in below screen:
Add the
following configuration to the end of the file:
[root@linuxcnf
wordpress-data]# vi
/etc/php-fpm.d/www.conf
…………………….
listen =
/var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
[root@linuxcnf
wordpress-data]#
|
Restart
the following command to restart php-fpm service:
[root@linuxcnf
wordpress-data]# systemctl restart
php-fpm
[root@linuxcnf
wordpress-data]#
[root@linuxcnf
wordpress-data]# systemctl enable
php-fpm
Created symlink from
/etc/systemd/system/multi-user.target.wants/php-fpm.service to
/usr/lib/systemd/system/php-fpm.service.
[root@linuxcnf
wordpress-data]#
|
Create
a new configuration and add the following configuration to the file. Replace
server name as per environment:
[root@linuxcnf
wordpress-data]# vi /etc/nginx/conf.d/wordpress.conf
server {
listen 80;
root /usr/share/nginx/wordpress-data;
index index.php index.html index.htm;
server_name 192.168.43.47;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME
$document_root/$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
[root@linuxcnf
wordpress-data]#
|
Run the
following command to restart the nginx service to reflect all the above
changes;
[root@linuxcnf
wordpress-data]# systemctl restart
nginx
[root@linuxcnf
wordpress-data]#
[root@linuxcnf
wordpress-data]# systemctl enable
nginx
Created symlink from
/etc/systemd/system/multi-user.target.wants/nginx.service to
/usr/lib/systemd/system/nginx.service.
[root@linuxcnf
wordpress-data]#
|
Step 5. Firewall Configuration: Run the
following command to allow Nginx access from the system firewall:
[root@linuxcnf
wordpress-data]# firewall-cmd
--zone=public --permanent --add-port=80/tcp
success
[root@linuxcnf
wordpress-data]# firewall-cmd --reload
success
[root@linuxcnf
wordpress-data]#
|
Step 6. 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