Install Nginx and PHP-FPM
sudo apt install nginx
sudo ufw app info "Nginx Full"
sudo ufw allow in "Nginx Full"
Code language: JavaScript (javascript)
PHP 7.2 FPM
sudo apt install php-fpm php-mysql php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-iconv php-imagick php-json php-mbstring php-posix php-sockets php-tokenizer php7.2-cli
sudo systemctl reload php7.2-fpm
sudo nano /etc/php/7.2/fpm/php.ini
; Maximum allowed size for uploaded files.
; http:
upload_max_filesize = 256M
post_max_size = 256M
upload_max_filesize = 256M
memory_limit = 256M
max_execution_time = 360
date.timezone = Asia/Kolkata
cgi.fix_pathinfo = 0
file_uploads = On
allow_url_fopen = On
short_open_tag = On
sudo systemctl status php7.2-fpm.service
sudo systemctl restart php7.2-fpm
sudo systemctl status php7.2-fpm.service
Code language: PHP (php)
Install WordPress
cd /tmp
curl -O https:
tar xzvf latest.tar.gz
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
mkdir /tmp/wordpress/wp-content/upgrade
sudo cp -a /tmp/wordpress/. /var/www/html/wordpress
sudo chown -R www-data:www-data /var/www/html/wordpress
curl -s https:
sudo nano /var/www/html/wordpress/wp-config.php
$_SERVER['HTTPS'] = 'on';
define('FS_METHOD', 'direct');
Code language: PHP (php)
Configure NGINX
sudo cp /etc/nginx/sites-enabled/default /etc/nginx/sites-available/wordpress
sudo nano /etc/nginx/sites-available/wordpress
server {
listen 80;
listen [::]:80;
server_name example.com;
root /var/www/html/wordpress;
access_log /var/log/nginx/wordpress.access.log;
error_log /var/log/nginx/wordpress.error.log;
client_max_body_size 256M;
autoindex off;
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
rewrite /faq/wp-admin$ $scheme:
location / {
try_files $uri $uri/ /index.php?$args;
}
index index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
}
}
gzip on;
gzip_vary on;
gzip_min_length 1000;
gzip_comp_level 5;
gzip_types application/json text/css application/x-javascript application/javascript image/svg+xml;
gzip_proxied any;
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~ /\.ht {
access_log off;
log_not_found off;
deny all;
}
location = /favicon.ico {
try_files $uri =204;
}
location ~* \.(atom|bmp|bz2|css|doc|docx|eot|gif|gz|ico|jpeg|jpg|js|mid|midi|mp4|ogg|ogv|otf|png|ppt|rar|rss|rtf|svg|svgz|tar|tgz|ttf|wav|woff|xls|zip)$ {
expires max;
}
location ~ \.(eot|ttf|ttc|otf|woff|woff2|svg|css|js)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
}
location ~* /(?:wp-includes|wp-content|mu-plugins|uploads)/.*\.php$ {
deny all;
}
location ~* (license|licence|readme)\.(htm|html|txt) {
deny all;
}
location = /wp-config*.php {
deny all;
}
location = /xmlrpc.php {
deny all;
}
location = /wp-mail.php {
deny all;
}
location = /wp-links-opml.php {
deny all;
}
location = /wp-trackback.php {
deny all;
}
location ~ /wp-content/debug\.log {
deny all;
}
location = /wp-login.php {
limit_req zone=one burst=1 nodelay;
include /etc/nginx/fastcgi.conf;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 300;
fastcgi_index index.php;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 200 301 404 @CACHEVALID;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
}
}
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
sudo unlink /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl status nginx
Code language: PHP (php)
Complete WordPress Installation
http:
Code language: JavaScript (javascript)