1. https://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-install-linux-nginx-mariadb-php-lemp-stack-in-rhel-8.html
2. https://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-install-wordpress-with-nginx-on-centos-8-rhel-8.html
—————————————————————–
1. Install Nginx
————————————————————–
# yum -y install nginx
# systemctl start nginx
# systemctl status nginx
Firewall
# firewall-cmd –permanent –add-service=http
# firewall-cmd –reload
Verify Nginx Installation
http://your-ip-address
# systemctl enable nginx
———————————————————————
2. Install MariaDB Pass: zafar123!
———————————————————————
# yum -y install mariadb mariadb-server
# systemctl start mariadb
# systemctl enable mariadb
# mysql_secure_installation
N.B.Pass: zafar123!
N.B. Use all “Y” option
———————————————————————-
3. Install PHP
———————————————————————-
# yum -y install php-fpm php-mysqlnd php-cli
# vi /etc/php.ini
[set cgi.fix_pathinfo to 0.]
cgi.fix_pathinfo=0
# vi /etc/php-fpm.d/www.conf
—————————————————————————–
Make sure the following values are UN-commented.
[.More.]
pm.min_spare_servers = 5
[.More.]
pm.max_spare_servers = 35
[.More.]
—————————————————————————————-
Change the Listen parameter.
FROM
listen = /run/php-fpm/www.sock
TO
listen = 127.0.0.1:9000
—- :wq
# systemctl start php-fpm
# systemctl enable php-fpm
Enable PHP-FPM Support on Virtual Host
# vi /etc/nginx/conf.d/zafims.conf
server {
server_name zafims;
root /usr/share/nginx/html/zafims;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
# mkdir /usr/share/nginx/html/zafims
# echo “<?php phpinfo(); ?>” > /usr/share/nginx/html/zafims/index.php
# systemctl restart nginx
# systemctl restart php-fpm
Test LEMP Stack
Create host entry for your web server domain (zafims) in the /etc/hosts
192.168.1.10 zafims.info
———————————————————————-
4. Install PHP Extensions
———————————————————————-
# yum install -y php-mysqlnd php-dom php-simplexml php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-iconv php-json php-mbstring php-posix php-sockets php-tokenizer
Configure Nginx Server block for WordPress
# vi /etc/nginx/conf.d/www.zafims.conf
server {
listen 80;
server_name www.zafims.info;
root /sites/www.zafims.info/public_html/;
index index.html index.php;
access_log /sites/www.zafims.info/logs/access.log;
error_log /sites/www.zafims.info/logs/error.log;
# Don’t allow pages to be rendered in an iframe on external domains.
add_header X-Frame-Options “SAMEORIGIN”;
# MIME sniffing prevention
add_header X-Content-Type-Options “nosniff”;
# Enable cross-site scripting filter in supported browsers.
add_header X-Xss-Protection “1; mode=block”;
# Prevent access to hidden files
location ~* /\.(?!well-known\/) {
deny all;
}
# Prevent access to certain file extensions
location ~\.(ini|log|conf)$ {
deny all;
}
# Enable WordPress Permananent Links
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
————————————————————–
Create document root and logs directory.
# sudo mkdir -p /sites/www.zafims.info/public_html/
# sudo mkdir -p /sites/www.zafims.info/logs/
Verify the configuration files.
# nginx -t
The below output confirms that there is no syntax error in the server block.
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart the services.
# systemctl restart nginx
# systemctl restart php-fpm
Create Database for WordPress
# mysql -u root -p
CREATE DATABASE zafims;
CREATE USER ‘zafar’@’localhost’ IDENTIFIED BY ‘zafar123!’;
GRANT ALL PRIVILEGES ON zafims.* TO ‘zafar’@’localhost’;
exit
———————————————————————-
4. Install WordPress
———————————————————————-
# curl -O https://wordpress.org/latest.tar.gz
# tar -zxvf latest.tar.gz
# mv wordpress/* /sites/www.zafims.info/public_html/
# cp /sites/www.zafims.info/public_html/wp-config-sample.php /sites/www.zafims.info/public_html/wp-config.php
vi /sites/www.zafims.info/public_html/wp-config.php
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define( ‘DB_NAME’, ‘zafims’ );
/** MySQL database username */
define( ‘DB_USER’, ‘zafar’ );
/** MySQL database password */
define( ‘DB_PASSWORD’, ‘zafar123!’ );
/** MySQL hostname */
define( ‘DB_HOST’, ‘localhost’ );
# chown -R apache:apache /sites/www.zafims.info/public_html/
Install WordPress
http://your-web-site-url