How To Install Wordpress with nginx on CentOS 6
How To Install Wordpress with nginx on CentOS 6. In this posts, the tutorial to install and configure mysql, wordpress and nginx on centos 6 step by step. I'm running account huupv as "root" privilege.
Links to below you maybe likes:
How to install php7 on centos 6
How to install and configure redmine on centos 6
How to owncloud 9 install ssl certificate centos 7
How To Install the BIND DNS Server on CentOS 6
KeepAlived IP Failover on CentOS & Red Hat
To release version on your server
The solve problem "403 Forbidden nginx (13) permission denied". Due to, www.huuphan.com in /home/huupv folder with permission account huupv.
To used namei command view perminssion www.huuphan.com
Links to below you maybe likes:
How to install php7 on centos 6
How to install and configure redmine on centos 6
How to owncloud 9 install ssl certificate centos 7
How To Install the BIND DNS Server on CentOS 6
KeepAlived IP Failover on CentOS & Red Hat
To release version on your server
cat /etc/redhat-releaseThe output as bellow
CentOS release 6.9 (Final)To update server
sudo yum updateTo install epel-release
sudo yum install epel-releaseTo install nginx
sudo yum install nginxTo install and configure mysql
sudo /etc/init.d/nginx start
sudo yum install php-fpm php-mysql php-gd
sudo yum install mysql-serverTo add user and database for WP_HuuPV on Mysql
sudo /etc/init.d/mysqld restart
sudo /usr/bin/mysql_secure_installation
mysql -u root -p'password123' -e 'show databases;'To download wordpress
mysql -u root -p'password123' -e 'create database WP_HuuPV;'
mysql -u root -p'password123' -e "grant all privileges on WP_HuuPV.* to wpuser@'localhost' identified by 'password123';"
mysql -u root -p'password123' -e 'flush privileges;'
mysql -u root -p'password123' -e 'show databases;'
wget http://wordpress.org/latest.tar.gzTo configure wordpress
gunzip -c latest.tar.gz | tar xvf -
sudo cp wordpress/wp-config-sample.php wordpress/wp-config.phpThe content as bellow
sudo vim wordpress/wp-config.php
/** The name of the database for WordPress */To create and permission on www.huuphan.com folder
define('DB_NAME', 'WP_HuuPV');
/** MySQL database username */
define('DB_USER', 'wpuser');
/** MySQL database password */
define('DB_PASSWORD', 'password123');
/** MySQL hostname */
define('DB_HOST', 'localhost');
sudo mkdir -p /home/huupv/www.huuphan.comThe startup services nginx,php-fpm and mysql on system
sudo cp -r wordpress/* /home/huupv/www.huuphan.com
cd /home/huupv/
sudo chown -R nginx: www.huuphan.com
sudo usermod -a -G nginx huupv
sudo chkconfig --levels 235 nginx onTo configure file nginx for wordpress
sudo chkconfig --levels 235 php-fpm on
sudo chkconfig --levels 235 mysqld on
sudo vim /etc/nginx/conf.d/www.huuphan.com.confThe content as bellow
server {
listen 80;
#listen [::]:80;
server_name huuphan.com www.huuphan.com;
##Redirect HTTP Traffic to HTTPS
#return 301 https://$server_name$request_uri;
#access_log off;
access_log /home/huupv/www.huuphan.com/access.log;
error_log /home/huupv/www.huuphan.com/error.log;
root /home/huupv/www.huuphan.com;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
###
# Retrict bad bot and bad referer
###
# Block HTTP method not include GET,HEAD,POST
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 444;
}
# Block bad http_referer (link contain bad word)
if ( $http_referer ~* (adult|babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|webcam|zippo|replica|onload\.pw) ) {
return 444;
}
## Block download agents ##
if ($http_user_agent ~* (LWP::Simple|BBBike|wget) ) {
return 444;
}
## Block bad bots ##
if ($http_user_agent ~* (httrack|htmlparser|libwww|aihitbot|plukkie|sistrix|ezooms|exabot|wget|Morfeus|larbin|ZmEu|Toata|Huawei|talktalk|MJ12bot|Baiduspider|AhrefsBot|spbot|bot-pge\.chlooe\.com|bot\.wsowner\.com|SEOstats|msnbot-media|Mail\.RU_Bot) ) {
return 444;
}
if ($http_user_agent ~* 'verifying pingback') {
set $pingbackcheck 1;
}
if ($uri = /) {
set $pingbackcheck "${pingbackcheck}2";
}
if ($pingbackcheck = 12) {
return 403;
}
location ~ \.php$ {
root /home/huupv/www.huuphan.com;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Fastcgi timeout settings
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 512k;
fastcgi_buffers 512 16k;
fastcgi_busy_buffers_size 512k;
fastcgi_temp_file_write_size 512k;
fastcgi_intercept_errors on;
}
location = /robots.txt { access_log off; log_not_found off; allow all; }
location = /favicon.ico { access_log off; log_not_found off; expires 30d; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
location ~ /\.git { access_log off; log_not_found off; deny all; }
location = /nginx.conf { access_log off; log_not_found off; deny all; }
location ~* /(?:uploads|files)/.*\.php$ { access_log off; log_not_found off; deny all; }
#location ~* .(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(.php)?|xtmpl)$|^(..*|Entries.*|Repository|Root|Tag|Template)$|.php_ { return 444; }
#location ~* .(pl|cgi|py|sh|lua)$ { return 444; }
location ~ /(wp-config.php|wp-comments-post.php|readme.html|license.txt) { deny all; }
# location ~* \.(ogg|ogv|3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|eot|svg|svgz|ttf|woff|otf|rss|atom|ppt|midi|bmp|rtf)$ {
# gzip_static off;
# add_header Cache-Control "public, must-revalidate, proxy-revalidate";
# access_log off;
# log_not_found off;
# expires max;
# break;
# }
# location ~* \.(css|js)$ {
# add_header Cache-Control "public, must-revalidate, proxy-revalidate";
# access_log off;
# log_not_found off;
# expires 30d;
# break;
# }
}
The solve problem "403 Forbidden nginx (13) permission denied". Due to, www.huuphan.com in /home/huupv folder with permission account huupv.
To used namei command view perminssion www.huuphan.com
namei -l /home/huupv/www.huuphan.comThe output as bellow
f: /home/huupv/www.huuphan.comFixed: "403 Forbidden nginx (13) permission denied"
dr-xr-xr-x root root /
drwxr-xr-x root root home
drwx------ huupv huupv huupv
drwxr-xr-x nginx nginx www.huuphan.com
chmod o+x /home/huupv
namei -l /home/huupv/www.huuphan.comThe output as bellow
f: /home/huupv/www.huuphan.comTo finish "How To Install Wordpress with nginx on CentOS 6"
dr-xr-xr-x root root /
drwxr-xr-x root root home
drwx-----x huupv huupv huupv
drwxr-xr-x nginx nginx www.huuphan.com
Comments
Post a Comment