Word Press Installation and configuration on Linux using NGINX

Spread the love

First update Linux ,
# yum update

Installing Linux, nginx, MySQL, PHP (LEMP)

# yum install pcre pcre-devel openssl-devel perl gcc make -y
# yum install mysql mysql-server


Download is complete, restart MySQL
# /etc/init.d/mysqld restart
You can set a root MySQL password:
sudo /usr/bin/mysql_secure_installation

—————————————-

Installing PHP-FPM

Visit : http://magazie.co.in/installing-php-fpm-on-centos-linux/

——————————————

Installing NGINX

To download and unpack source files for the latest stable version, type-in the commands:
$ wget http://nginx.org/download/nginx-1.12.0.tar.gz
$ tar zxf nginx-1.12.0.tar.gz
$ cd nginx-1.12.0
Or
Install using YUM
Install nginx repo
For centos 7.x
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
or
For centos 6.x
rpm –Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
Install Nginx using the following command.
yum -y install nginx

……………………………………………………………………………
Loaded plugins: product-id, rhnplugin, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
nginx | 1.3 kB 00:00
nginx/primary | 4.8 kB 00:00
nginx 33/33
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package nginx.x86_64 0:1.2.6-1.el6.ngx will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
nginx x86_64 1.2.6-1.el6.ngx nginx 361 k

Transaction Summary
================================================================================
Install 1 Package(s)

Total download size: 361 k
Installed size: 835 k
Is this ok [y/N]: y
Downloading Packages:
nginx-1.2.6-1.el6.ngx.x86_64.rpm | 361 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : nginx-1.2.6-1.el6.ngx.x86_64 1/1
———————————————————————-

Thanks for using NGINX!

Check out our community web site:
* http:// nginx.org/en/support.html

If you have questions about commercial support for NGINX please visit:
* http://www.nginx.com/support.html

———————————————————————-
Installed products updated.
Verifying : nginx-1.2.6-1.el6.ngx.x86_64 1/1

Installed:
nginx.x86_64 0:1.2.6-1.el6.ngx

Complete!
………………………………………………………………………………………………………..

Auto starting NGINX
Off the httpd if installed
# chkconfig httpd off
# chkconfig nginx on
Turn On nginx service
# service nginx start
# service nginx stop
# service nginx restart
# service nginx status
# service nginx reload

Configuration files
Default configuration directory: /etc/nginx/
Default SSL and host config directory: /etc/nginx/conf.d/
Default log file directory: /var/log/nginx/
Default document root directory: /usr/share/nginx/html
Default configuration file: /etc/nginx/nginx.conf
Default server access log file: /var/log/nginx/access.log
Default server access log file: /var/log/nginx/error.log

Configure IP Address and Server name

# vi /etc/nginx/conf.d/default.conf
Flie should be like this :-
………………………………………………………
server {
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
listen 443 ssl;
root /usr/share/nginx/html;
index index.html index.htm index.php;
server_name sufiblog;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /.ht {
# deny all;
#}
}
………………………………………………………..

Check on web http://localhost

NGINX installation path
/usr/share/nginx/html

Now , Install Word Press in this directory
Download the latest version
https://wordpress.org/latest.tar.gz
Tar file will be download untar using following command.

# tar -xzvf latest.tar.gz
#ls
# cd wordpress
# mv * /usr/share/nginx/html
Copy the wp-config-sample.php file to wp-config.php
# cd /usr/share/nginx/html
# cp wp-config-sample.php wp-config.php
Recommended to make the document root and the WordPress file in it writeable by the nginx
# chown –R nginx:nginx /usr/share/nginx/html/

Now , create MySQL database for wordpress , you can do the following steps

# mysql -u root -p
# CREATE DATABASE wordpress;
# CREATE USER wordpress@localhost;
# GRANT ALL PRIVILEGES ON wordpress.* TO ‘wordpress@’localhost’ IDENTIFIED BY ‘Password’;
Query OK, 0 rows affected (0.00 sec)
# FLUSH PRIVILEGES;

Open wp-config.php and fill the correct the database details as :-
………………………………………………………………………………..
[…] // ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress’);
/** MySQL database username */
define(‘DB_USER’, ‘wordpress’);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘Password’);
/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);
[…] …………………………………………………………………………………………

Now , launch the web WordPress by http://localhost/wp-admin/install.php

 

Leave a Reply

Your email address will not be published. Required fields are marked *