├── README.md ├── cf.png ├── db.png ├── kloudboy ├── general.conf ├── php_fastcgi.conf ├── security.conf └── wordpress.conf ├── nginx.conf ├── of.gif ├── pg.png ├── sites-available ├── example.com.conf └── sub.example.com.conf ├── sites-enabled └── example.com.conf ├── sub-domain-install.sh ├── tr.png ├── wordpress.jpg ├── wp-install.sh └── wp.png /README.md: -------------------------------------------------------------------------------- 1 | # High Traffic wordpress server configuration 2 | > This LEMP stack is that fastest way to start running WordPress on your server. Using Nginx, PHP 7.4, Mariadb. 3 | 4 | ![](wordpress.jpg) 5 | 6 | ## Installation & Usage 7 | 8 | ## (1st Step) CloudFlare settings 9 | 10 | Add your droplet(vps) ip address to CloudFlare A record. 11 | 12 | ![](cf.png) 13 | 14 | ## (2nd Step) Login to ssh console 15 | 16 | run below script. it'll ask your domain name just add "yoursite.com" format next your database name add "examplewp" 17 | 18 | ![](tr.png) 19 | 20 | ###### Ubuntu-18.04 and Ubuntu-20.04 Support. 21 | 22 | Linux Only: 23 | 24 | ```sh 25 | wget -qO htw run.kloudboy.com/htw && sudo bash htw 26 | ``` 27 | 28 | ## Features 29 | 30 | > Nginx (Lastest) 31 | 32 | > PHP 8.2 33 | 34 | > PHP-fpm 35 | 36 | > Mariadb (Lastest) 37 | 38 | > Wordpress (Lastest) 39 | 40 | > WP-CLI (Lastest) 41 | 42 | > Memcached (Lastest) 43 | 44 | > Cloudflare Full SSL 45 | 46 | ## Activate Memcached 47 | 48 | >Install W3 Total Cache and Activate 49 | 50 | In the main menu, go to Performance then click on General Settings 51 | ###### Activate Memcached for the following options: 52 | 53 | Page Cache Method 54 | ![](pg.png) 55 | 56 | Database cache method 57 | ![](db.png) 58 | 59 | Save the settings 60 | 61 | ## KloudBoy Recommended Plugins to Get Google / GTmatrix 100% Pagespeed. 62 | 63 | 1. reSmush.it 64 | The FREE Image Optimizer which will compress your pictures and improve your SEO & performances… 65 | [Install Now](https://wordpress.org/plugins/resmushit-image-optimizer/) 66 | 67 | 2. WP Cloudflare Super Page Cache 68 | Speed up a WordPress website by caching your webpages onto global CDN using any Cloudflare 69 | [Install Now](https://wordpress.org/plugins/wp-cloudflare-page-cache/) 70 | 71 | ## Gtmetrix Performance Report 72 | 73 | ![](wp.png) 74 | 75 | ## Try DigitalOcean for Free with a $100 Credit 76 | 77 | ![](of.gif) 78 | 79 | Offer Link:- https://offer.kloudboy.com/100USD-credit-coupon 80 | 81 | ## Contributing 82 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 83 | 84 | Please make sure to update tests as appropriate. 85 | 86 | ## Author 87 | 88 | Bajpan Gosh – [@bajpangosh](https://twitter.com/bajpangosh) – bajpan@kloudboy.com 89 | 90 | 91 | ## NEED HELP? 92 | 93 | We are a team of dedicated Cloud Server Administrators assures 24/7 availability of experts for all levels of your server management requirements. 94 | 95 | I'd be glad to help you if you have any questions relating to this script. No guarantees, but I'll do my best to assist. 96 | 97 | Support via Facebook, Twitter, Email, Ticket 98 | 99 | email :-support@kloudboy.com 100 | 101 | facebook :- https://m.me/TeamKloudBoy 102 | 103 | twitter :- https://twitter.com/TeamKloudBoy 104 | 105 | ticket :-https://kloudboy.freshdesk.com/support/home 106 | 107 | Made By <3 https://www.kloudboy.com/ 108 | 109 | 110 | DigitalOcean Referral Badge 111 | -------------------------------------------------------------------------------- /cf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajpangosh/High-Traffic-wordpress-server-configuration/48253e9a046feddff182858ee7ef43cf1085d57a/cf.png -------------------------------------------------------------------------------- /db.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajpangosh/High-Traffic-wordpress-server-configuration/48253e9a046feddff182858ee7ef43cf1085d57a/db.png -------------------------------------------------------------------------------- /kloudboy/general.conf: -------------------------------------------------------------------------------- 1 | # favicon.ico 2 | location = /favicon.ico { 3 | log_not_found off; 4 | access_log off; 5 | } 6 | 7 | # robots.txt 8 | location = /robots.txt { 9 | log_not_found off; 10 | access_log off; 11 | } 12 | 13 | # assets, media 14 | location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { 15 | expires 7d; 16 | access_log off; 17 | } 18 | 19 | # svg, fonts 20 | location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ { 21 | add_header Access-Control-Allow-Origin "*"; 22 | expires 7d; 23 | access_log off; 24 | } 25 | 26 | # gzip 27 | gzip on; 28 | gzip_vary on; 29 | gzip_proxied any; 30 | gzip_comp_level 6; 31 | gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; 32 | -------------------------------------------------------------------------------- /kloudboy/php_fastcgi.conf: -------------------------------------------------------------------------------- 1 | # 404 2 | try_files $fastcgi_script_name =404; 3 | 4 | # default fastcgi_params 5 | include fastcgi_params; 6 | 7 | # fastcgi settings 8 | fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; 9 | fastcgi_index index.php; 10 | fastcgi_buffers 8 16k; 11 | fastcgi_buffer_size 32k; 12 | 13 | # fastcgi params 14 | fastcgi_param DOCUMENT_ROOT $realpath_root; 15 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 16 | fastcgi_param PHP_ADMIN_VALUE "open_basedir=$base/:/usr/lib/php/:/tmp/"; 17 | -------------------------------------------------------------------------------- /kloudboy/security.conf: -------------------------------------------------------------------------------- 1 | # security headers 2 | add_header X-XSS-Protection "1; mode=block" always; 3 | add_header X-Content-Type-Options "nosniff" always; 4 | add_header Referrer-Policy "no-referrer-when-downgrade" always; 5 | add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'; frame-ancestors 'self';" always; 6 | add_header Permissions-Policy "interest-cohort=()" always; 7 | add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; 8 | 9 | # . files 10 | location ~ /\.(?!well-known) { 11 | deny all; 12 | } 13 | -------------------------------------------------------------------------------- /kloudboy/wordpress.conf: -------------------------------------------------------------------------------- 1 | # WordPress: allow TinyMCE 2 | location = /wp-includes/js/tinymce/wp-tinymce.php { 3 | include kloudboy/php_fastcgi.conf; 4 | } 5 | 6 | # WordPress: deny wp-content, wp-includes php files 7 | location ~* ^/(?:wp-content|wp-includes)/.*\.php$ { 8 | deny all; 9 | } 10 | 11 | # WordPress: deny wp-content/uploads nasty stuff 12 | location ~* ^/wp-content/uploads/.*\.(?:s?html?|php|js|swf)$ { 13 | deny all; 14 | } 15 | 16 | # WordPress: SEO plugin 17 | location ~* ^/wp-content/plugins/wordpress-seo(?:-premium)?/css/main-sitemap\.xsl$ {} 18 | 19 | # WordPress: deny wp-content/plugins (except earlier rules) 20 | location ~ ^/wp-content/plugins { 21 | deny all; 22 | } 23 | 24 | # WordPress: deny scripts and styles concat 25 | location ~* \/wp-admin\/load-(?:scripts|styles)\.php { 26 | deny all; 27 | } 28 | 29 | # WordPress: deny general stuff 30 | location ~* ^/(?:xmlrpc\.php|wp-links-opml\.php|wp-config\.php|wp-config-sample\.php|wp-comments-post\.php|readme\.html|license\.txt)$ { 31 | deny all; 32 | } 33 | 34 | # START Nginx Rewrites for Rank Math Sitemaps 35 | rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last; 36 | rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; 37 | # END Nginx Rewrites for Rank Math Sitemaps 38 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | pid /run/nginx.pid; 3 | worker_processes auto; 4 | worker_rlimit_nofile 65535; 5 | 6 | events { 7 | multi_accept on; 8 | worker_connections 65535; 9 | } 10 | 11 | http { 12 | charset utf-8; 13 | sendfile on; 14 | tcp_nopush on; 15 | tcp_nodelay on; 16 | server_tokens off; 17 | log_not_found off; 18 | types_hash_max_size 2048; 19 | types_hash_bucket_size 64; 20 | client_max_body_size 100M; 21 | 22 | # MIME 23 | include mime.types; 24 | default_type application/octet-stream; 25 | 26 | # Logging 27 | access_log /var/log/nginx/access.log; 28 | error_log /var/log/nginx/error.log warn; 29 | 30 | # SSL 31 | ssl_session_timeout 1d; 32 | ssl_session_cache shared:SSL:10m; 33 | ssl_session_tickets off; 34 | 35 | # Diffie-Hellman parameter for DHE ciphersuites 36 | ssl_dhparam /etc/nginx/ssl/dhparam.pem; 37 | 38 | # Mozilla Intermediate configuration 39 | ssl_protocols TLSv1.2 TLSv1.3; 40 | ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; 41 | 42 | # OCSP Stapling 43 | ssl_stapling on; 44 | ssl_stapling_verify on; 45 | resolver 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001] 8.8.8.8 8.8.4.4 [2001:4860:4860::8888] [2001:4860:4860::8844] 208.67.222.222 208.67.220.220 [2620:119:35::35] [2620:119:53::53] valid=60s; 46 | resolver_timeout 2s; 47 | 48 | # Load configs 49 | include /etc/nginx/conf.d/*.conf; 50 | include /etc/nginx/sites-enabled/*; 51 | } 52 | -------------------------------------------------------------------------------- /of.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajpangosh/High-Traffic-wordpress-server-configuration/48253e9a046feddff182858ee7ef43cf1085d57a/of.gif -------------------------------------------------------------------------------- /pg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajpangosh/High-Traffic-wordpress-server-configuration/48253e9a046feddff182858ee7ef43cf1085d57a/pg.png -------------------------------------------------------------------------------- /sites-available/example.com.conf: -------------------------------------------------------------------------------- 1 | server { 2 | 3 | listen 443 ssl http2; 4 | listen [::]:443 ssl http2; 5 | 6 | server_name www.example.com; 7 | set $base /var/www/example.com; 8 | root $base/public; 9 | 10 | # SSL 11 | ssl_certificate /etc/nginx/ssl/nginx.crt; 12 | ssl_certificate_key /etc/nginx/ssl/nginx.key; 13 | 14 | # index.php 15 | index index.html index.htm index.php; 16 | 17 | # index.php fallback 18 | location / { 19 | 20 | try_files $uri $uri/ /index.php?$query_string; 21 | } 22 | 23 | # handle .php 24 | location ~ \.php$ { 25 | 26 | include kloudboy/php_fastcgi.conf; 27 | } 28 | 29 | include kloudboy/general.conf; 30 | include kloudboy/wordpress.conf; 31 | include kloudboy/security.conf; 32 | } 33 | 34 | # non-www, subdomains redirect 35 | server { 36 | 37 | listen 443 ssl http2; 38 | listen [::]:443 ssl http2; 39 | 40 | server_name .example.com; 41 | 42 | # SSL 43 | ssl_certificate /etc/nginx/ssl/nginx.crt; 44 | ssl_certificate_key /etc/nginx/ssl/nginx.key; 45 | 46 | return 301 https://www.example.com$request_uri; 47 | } 48 | 49 | # HTTP redirect 50 | server { 51 | 52 | listen 80; 53 | listen [::]:80; 54 | 55 | server_name .example.com; 56 | 57 | return 301 https://www.example.com$request_uri; 58 | } 59 | -------------------------------------------------------------------------------- /sites-available/sub.example.com.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 443 ssl http2; 3 | listen [::]:443 ssl http2; 4 | 5 | server_name sub.example.com; 6 | set $base /var/www/sub.example.com; 7 | root $base/public; 8 | 9 | # SSL 10 | ssl_certificate /etc/nginx/ssl/nginx.crt; 11 | ssl_certificate_key /etc/nginx/ssl/nginx.key; 12 | 13 | # security 14 | include kloudboy/security.conf; 15 | 16 | # index.php 17 | index index.php; 18 | 19 | # index.php fallback 20 | location / { 21 | try_files $uri $uri/ /index.php?$query_string; 22 | } 23 | 24 | # handle .php 25 | location ~ \.php$ { 26 | include kloudboy/php_fastcgi.conf; 27 | } 28 | 29 | # additional config 30 | include kloudboy/general.conf; 31 | include kloudboy/wordpress.conf; 32 | } 33 | 34 | # subdomains redirect 35 | server { 36 | listen 443 ssl http2; 37 | listen [::]:443 ssl http2; 38 | 39 | server_name *.sub.example.com; 40 | 41 | # SSL 42 | ssl_certificate /etc/nginx/ssl/nginx.crt; 43 | ssl_certificate_key /etc/nginx/ssl/nginx.key; 44 | 45 | return 301 https://sub.example.com$request_uri; 46 | } 47 | 48 | # HTTP redirect 49 | server { 50 | listen 80; 51 | listen [::]:80; 52 | 53 | server_name .sub.example.com; 54 | 55 | return 301 https://sub.example.com$request_uri; 56 | } 57 | -------------------------------------------------------------------------------- /sites-enabled/example.com.conf: -------------------------------------------------------------------------------- 1 | ../sites-available/example.com.conf -------------------------------------------------------------------------------- /sub-domain-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # GET ALL USER INPUT 3 | tput setaf 2; echo "Domain Name (eg. sub.example.com)?" 4 | read DOMAIN 5 | tput setaf 2; echo "Username (eg. database name)?" 6 | read USERNAME 7 | tput setaf 2; echo "Updating OS................." 8 | sleep 2; 9 | tput sgr0 10 | sudo apt-get update 11 | tput setaf 2; echo "Sit back and relax :) ......" 12 | sleep 1; 13 | tput sgr0 14 | cd /etc/nginx/sites-available/ 15 | sudo wget -qO "$DOMAIN" https://raw.githubusercontent.com/bajpangosh/High-Traffic-wordpress-server-configuration/master/sites-available/example.com.conf 16 | sudo sed -i -e "s/example.com/$DOMAIN/" "$DOMAIN" 17 | sudo sed -i -e "s/www.example.com/www.$DOMAIN/" "$DOMAIN" 18 | sudo ln -s /etc/nginx/sites-available/"$DOMAIN" /etc/nginx/sites-enabled/ 19 | sudo mkdir -p /var/www/"$DOMAIN"/public 20 | cd /var/www/"$DOMAIN/public" 21 | cd ~ 22 | tput setaf 2; echo "Downloading Latest Wordpress...." 23 | sleep 2; 24 | tput sgr0 25 | sudo wget -q wordpress.org/latest.zip 26 | sudo unzip latest.zip 27 | sudo mv wordpress/* /var/www/"$DOMAIN"/public/ 28 | sudo rm -rf wordpress latest.zip 29 | cd ~ 30 | sudo chown www-data:www-data -R /var/www/"$DOMAIN"/public 31 | sudo systemctl restart nginx.service 32 | 33 | PASS=`pwgen -s 14 1` 34 | 35 | sudo mysql -uroot <