• Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / wordpress tutorials for beginners advanced complete guide to run WordPress / install wordpress on ubuntu nginx lemp command line apache debian

install wordpress on ubuntu nginx lemp command line apache debian

install wordpress on ubuntu command line for nginx and apache lamp & lemp stack.

Table of Contents

Toggle
    • prerequisites install WordPress on ubuntu
  • how to install wordpress on ubuntu  LEMP nginx
  • Creation mysql database from command line – install wordpress on ubuntu 
  • step 1 create database
    • step 2Add permission to mysql user (if necessary)
  •  Starts here install wordpress on ubuntu (Apache / nginx  Debian)
  • step 1: create new directory – install wordpress on ubuntu
    • 1.a create new directory
    • 1.b change permission to 755  (opiontal_
    • 1.c Navigate to the directory
  • step 2: Download WordPress & Unzip  – install wordpress on ubuntu 
  • step 2.a unzip tar wordpress zip on ubutu commandline
  • step 3:  Move files top directory from wordpress folder.
  • step 4: Delete folder and zip archive – install wordpress on ubuntu
  • The shortcut or Shell Script
  • If you created database already
  • rename & Edit WordPress wp-config.php ubtunu
  • rename
  • change ownership of wordpress directory root server user (imp)
  • 3rd way fast nginx shell script install wordpress on ubuntu
  • Part 2 wp & db details add
  • Part 3 server block domain to directory setup for nginx
  • incase ssl https nginx server block configuration
    • verify and reload the server
  • wordpress nginx server block sample

prerequisites install WordPress on ubuntu

installed lemp server i.e lnixu, nginx mysql, php-fpm
a.create database
part 1: use Shell script to install WordPress
Part 2: & add database details
Part 3: configure nginx server block for new website root directory
Part 4: access installation from website browser /wp-install.php or /wp-admin/
also check clone wordpress on linux command line

how to install wordpress on ubuntu  LEMP nginx

sudo apt install nginx
sudo apt install mysql-server
sudo apt install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml sudo service nginx restart
check browser and then follow wp installation
//  Take care of errors
LEMP install on ubuntu
Start here if already have live server.

Creation mysql database from command line – install wordpress on ubuntu 

step 1 create database

mysql -u username -p  u=useranme p=passowrd
mysql -u root -p enter this command and enter sql password.
Step 2 create database dbname;
 
CTRL+C to exit mysql

step 2Add permission to mysql user (if necessary)

 
For mysql root no need to assign privileges.
 
grant usage on *.* to username@localhost identified by ‘password’;
grant all privileges on dbname.* to username@localhost;

 Starts here install wordpress on ubuntu (Apache / nginx  Debian)

 

step 1: create new directory – install wordpress on ubuntu

1.a create new directory

sudo mkdir /var/www/html/yourwebsitedirectory.com

1.b change permission to 755  (opiontal_

Note By default newly created permissions will be 755
chmod -R 755 /home/pubclubindia/epf/burnbelly.in

1.c Navigate to the directory

cd /var/www/html/yourwebsitedirectory.com

step 2: Download WordPress & Unzip  – install wordpress on ubuntu 

2.1a download the WordPress from below file by command line directly
wget https://wordpress.org/latest.tar.gz

root@localhost:/var/www/html/files# wget https://wordpress.org/latest.tar.gz
–2021-07-14 10:21:12– https://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)… 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 15750424 (15M) [application/octet-stream]
Saving to: ‘latest.tar.gz’

latest.tar.gz 100%[===================>] 15.02M 5.86MB/s in 2.6s

2021-07-14 10:21:16 (5.86 MB/s) – ‘latest.tar.gz’ saved [15750424/15750424]

step 2.a unzip tar wordpress zip on ubutu commandline

tar xfz latest.tar.gz
By default WordPress extracts in WordPress folder. then you have to move top level folder

step 3:  Move files top directory from wordpress folder.

mv wordpress/* ./

step 4: Delete folder and zip archive – install wordpress on ubuntu

rmdir ./wordpress/
rm -f latest.tar.gz

The shortcut or Shell Script

sudo mkdir /var/www/html/yourwebsitedirectory.com && cd /var/www/html/yourwebsitedirectory.com && wget https://wordpress.org/latest.tar.gz && tar xfz latest.tar.gz && mv wordpress/* ./ && rmdir ./wordpress/ && rm -f latest.tar.gz
copy to notepad find and replace yourwebsitedirectory.com to yourwebsite.com

If you created database already

sudo mkdir /var/www/html/yourwebsitedirectory.com && cd /var/www/html/yourwebsitedirectory.com && wget https://wordpress.org/latest.tar.gz && tar xfz latest.tar.gz && mv wordpress/* ./ && rmdir ./wordpress/ && rm -f latest.tar.gz && mv wp-config-sample.php wp-config.php && sudo nano ./wp-config.php
 DON’T FORGET change ownership server user either nginx or www-data apche2
sudo chown www-data:www-data -R /var/www/html/yourwebsitedirectory.com
 
 ex: sudo chown www-data:www-data -R /var/www/html/stories
 

rename & Edit WordPress wp-config.php ubtunu

 

rename

mv wp-config-sample.php wp-config.php

 

 
added db details.
 
 
sudo nano ./wp-config.php
 
 
by deaflut wp-config.php not present in new install
we have added changes to wp-config-sample.php
visit the website in browser and add site tile and install. you can do it without adding DB details in wp-confing php also.
https://youtu.be/Q4uHhuwKZQQ

 

make sure change permissions before installing a plugin..

also you can copy existing plugins & themes other website in same server.

all

cp source to destination  more at CP command

cp -r /var/www/html/wordpress1.in/wp-content/themes/* /var/www/html/woprdpress2.com/wp-content/themes/

cp -r /var/www/html/wordpress1.in/wp-content/plugins/* /var/www/html/woprdpress2.com/wp-content/plugins/

to verify

ls – l /var/www/html/woprdpress2.com/wp-content/themes/

single

cp -r /var/www/html/wordpress1.in/wp-content/plugins/pluginname /var/www/html/woprdpress2.com/wp-content/plugins/pluginname

 

change ownership of wordpress directory root server user (imp)

 

 

sudo chown -R www-data:www-data /var/www/html/files/

 

sudo chown -R jagdisshanandh:jagdisshanandh /var/www/*

 

3rd way fast nginx shell script install wordpress on ubuntu

Part 1 DB creation part

1.mysql -u root -prootpass -e “create database dbname;”

user creation example below:

sudo mysql -e “CREATE USER ‘datadog’@’localhost’ IDENTIFIED BY ‘h3ub7BmyGv UL5TskBFlG9rF’;”
mysql -u root -prootpasss -e “CREATE USER ‘datadog’@’localhost’ IDENTIFIED BY ‘h3ub7BmyGv UL5TskBFlG9rF’;”

Part 2 wp & db details add

sudo mkdir /var/www/html/website.com && cd /var/www/html/website.com && wget https://wordpress.org/latest.tar.gz && tar xfz latest.tar.gz && mv wordpress/* ./ && rmdir ./wordpress/ && rm -f latest.tar.gz && mv wp-config-sample.php wp-config.php && sudo nano ./wp-config.php

b. Change database details c. save file and exit by (CTRLX+X and Then type and Press Enter)

tail /var/log/nginx/error.log

Part 3 server block domain to directory setup for nginx

cat >/etc/nginx/sites-enabled/website <<EOF
server {
listen 80;
root /var/www/html/website/;
server_name website.com www.website.com;
include /etc/nginx/conf.d/global.config; #remaining info
}
EOF

website = website directory

cat >/etc/nginx/sites-enabled/files <<EOF
server {
listen 443;
root /var/www/html/files/;
server_name file.sarkariresult.in;
include /etc/nginx/conf.d/global.config;
}
EOF

incase ssl https nginx server block configuration

cat >/etc/nginx/sites-enabled/website.com<<EOF
server {
listen 443;
root /var/www/html/website.com/;
server_name website.com www.website.com;
ssl_certificate /etc/nginx/ssl/certname.pem;
ssl_certificate_key /etc/nginx/ssl/certname.key;
location / {

try_files $uri $uri/ /index.php?$args;

}

location ~ \.php$ {

 

include snippets/fastcgi-php.conf;

#fastcgi_pass unix:/run/php/php7.2-fpm.sock;

fastcgi_pass 127.0.0.1:9000;

}
}
EOF

also nginx server block explained

verify and reload the server

nginx -t && nginx -s reload

 

etc/nginx/sites-enabled/yourdesiredname

Create or upload ssl certificates to a folder and point theme more at nginx ssl certificate configuration

above code

nano /etc/nginx/ssl/certname.pem

//add code and save

nano /etc/nginx/ssl/certname.key

global.config; need to edit o directly above for php settings

 

 

//ln -s /etc/nginx/sites-available/website.com /etc/nginx/sites-enabled/website.com

chown www-data:www-data -R /var/www/html/

Point domain IP to Server IP.

wordpress nginx server block sample

server {
            listen 80;
            root /var/www/html/wordpress/public_html;
            index index.php index.html;
            server_name SUBDOMAIN.DOMAIN.TLD;

	    access_log /var/log/nginx/SUBDOMAIN.access.log;
    	    error_log /var/log/nginx/SUBDOMAIN.error.log;

            location / {
                         try_files $uri $uri/ =404;
            }

            location ~ \.php$ {
                         include snippets/fastcgi-php.conf;
                         fastcgi_pass unix:/run/php/php7.2-fpm.sock; #8.1 php version or tcp port
            }
            
            location ~ /\.ht {
                         deny all;
            }

            location = /favicon.ico {
                         log_not_found off;
                         access_log off;
            }

            location = /robots.txt {
                         allow all;
                         log_not_found off;
                         access_log off;
           }
       
            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                         expires max;
                         log_not_found off;
           }
}


sample 2


# Redirect HTTP -> HTTPS
server {
listen 80;
server_name www.sample.com sample.com;

include snippets/letsencrypt.conf;
return 301 https://sample.com$request_uri;
}

# Redirect WWW -> NON-WWW
server {
listen 443 ssl http2;
server_name www.sample.com;

ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/sample.com/chain.pem;
include snippets/ssl.conf;

return 301 https://sample.com$request_uri;
}

server {
listen 443 ssl http2;
server_name sample.com;

root /var/www/html/sample.com;
index index.php;

# SSL parameters
ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/sample.com/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;

# log files
access_log /var/log/nginx/sample.com.access.log;
error_log /var/log/nginx/sample.com.error.log;

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
}

wordpress tutorials for beginners advanced complete guide to run WordPress

  • wordpress speed optimization Speed up wordpress Score on Google pagespeed
  • best wordpress plugins social, seo, Backup, speed up your blog
  • TOP 10 Wordpress Themes Premium/ Free & providers
  • Wordpress Adsense Plugins & Manually
  • Social share buttons for website Wordpress Blogger
  • How to bulk delete in wordpress posts, pages, Media Images, tags and categories
  • TOP 5 Best wordpress comment plugins 2020 (disable pingback, replytocom, customize form)
  • all in one seo pack vs yoast seo pressor
  • Auto post to Facebook, twitter, Google Plus Wordpress Posts 2019
  • wordpress plugins that slow down your site and its alternatives
  • How to use wordpress tags and categories
  • Wordpress duplicate thin content Issues {FIXED}
  • how to increase wordpress memory & file upload size
  • combine rss feeds wordpress
  • Reduce the impact of third-party code ,optimize JS delivery, Minify, remove unused js, pre connect, inline, lazy load etc
  • change wordpress site url internal links in mysql command phpmyadmin
  • install wordpress on ubuntu nginx lemp command line apache debian
  • Wordpress Security Plugins 2021 (Brute force, Login lockdown, Malware scanner etc)
  • website cache best caching plugins wordpress w3tc cloudflare
  • How to add adsense amp ads to wordpress
  • wordpress password reset in 3 ways mail, phpmyadmin, mysql command
  • how i recovered hacked website site 5 times ft wordpress?
  • wordpress redirection examples Rankmath seo
  • enable browser caching in wordpress apache nginx caching headers explained
  • W3TC w3 total cache plugin setup guide review comparison with wp rocket and wp super cache
  • Wordpress database optimization (don't neglect) plugins & phpmyadmin manually
  • Optimize css delivery inline critical css, remove unused css, render blocking css
  • Converting WordPress into static website speed after 1 second dynamic 3 seconds
  • Wordpress errors and fix
  • Rules to get 100/100 in Google pagespeed web core vitalsscore
  • Install xamp & wordpress on localhost windows
  • favicon ico Change / Add / Disable favicon in wordpress Ft Genesis Theme or any theme
  • increase wordpress memory limit (how to ) 40MB , 64 MB 128 MB or 512 MB maybe 1024MB
  • wp cron job check working or not disable enable change schedule
  • google analytics plugins for wordpress #sitekit #monsterinsights gadwp back as gainwp
  • Lazy Load Adsense to improve core web vitals - Vs revenue
  • xmlrpc php wordpress uses, disable without 403 error log message
  • wordpress 304 header implement using plugin
  • wordpress change post date programmatically (auto on update like blogger
  • sorry you are not allowed to access this page. admin WordPress options table
  • clone wordpress in linux ubuntu server lemp nginx
  • Cloudflare cache rules for WordPress along with page rules cache level everything
  • wordfence-waf.php fatal error fixed after migration
  • Cloudflare page rules cache level everything redirect and sub domain
  • wordpress delete all posts from database mysql query for phpmyadmin
  • php fpm oom killer problem how to dig it.. memory pool and execution time
  • nginx wordpress multisite subdirectory multiple domains
  • Helpful Content update recovery Trying to dig it
  • How to Move a Single WordPress Site into a Multisite
  • Enable multisite in wordpress in 3 steps problems datbase error
  • Seprate single site from wordpress multisite domain based
  • Error establishing a database connection wordpress multisite
  • Add single wordpress to MultiSite wordpress
  • genesis theme cateogory customization examples
  • could not insert term into the database. wordpress
  • wordpress breadcrumbs not showing full path
  • There has been a critical error on this website fed up
  • Site structure WP categories vs sub pages or multisite posts or pages
  • WordPress pyramid structure Permalinks Category vs sub pages vs multisite

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy