Skip to content

Instantly share code, notes, and snippets.

@linuxbiekaisar
Last active March 12, 2020 05:35
Show Gist options
  • Save linuxbiekaisar/9bb26aaeb258c8cbc14ecfe4715034f0 to your computer and use it in GitHub Desktop.
Save linuxbiekaisar/9bb26aaeb258c8cbc14ecfe4715034f0 to your computer and use it in GitHub Desktop.
Wordpress Installation using LEMP stack server (Nginx, Mariadb & PHP)
Youtube: https://www.youtube.com/watch?v=sZNeeynK-ZU&t=1708s
#!/bin/sh
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get autoremove
#Install NGINX
sudo apt-get install nginx
#Install MariaDB
sudo apt-get install mariadb-server
sudo systemctl enable mariadb.service
sudo mysql_secure_installation
#The default password for MariaDB root user is blank. To update the password of the root user, get the MySQL prompt and update the password by issuing following command from MySQL shell.
sudo mysql -u root -p
CREATE DATABASE khamid DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON khamid.* TO 'ukhamid'@'localhost' IDENTIFIED BY '$%ka*&Sd@#bs001@';
FLUSH PRIVILEGES;
EXIT;
#Install PHP
sudo apt-get install php7.2 php7.2-cli php7.2-fpm php7.2-mysql php7.2-json php7.2-opcache php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl
#Add this
sudo nano /etc/nginx/nginx.conf
# set client body size to 2M #
client_max_body_size 2M;
# Use your favorite editor to create a configuration file for NGINX server block and edit it like below.
sudo nano /etc/nginx/sites-available/default.conf
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 / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
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;
}
}
#save & Exit
cd /etc/nginx/sites-enabled
ln -s ../sites-available/
sudo systemctl reload nginx
# Download and Configure WordPress
cd /var/www/html/wordpress
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -zxvf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf wordpress
# Change the ownership and apply correct permissions to the extracted WordPress files and folders. To do that, use the following command from the terminal.
cd /var/www/html/wordpress/
sudo chown -R www-data:www-data *
sudo chmod -R 755 *
#Now provide the database name, database user and the password in the WordPress config file.
cd /var/www/html/wordpress/public_html
sudo mv wp-config-sample.php wp-config.php
# To grab secure values from the WordPress secret key generator, type:
sudo apt install curl
curl -s https://api.wordpress.org/secret-key/1.1/salt/
sudo nano wp-config.php
...
define('DB_NAME', 'khamid');
define('DB_USER', 'ukhamid');
define('DB_PASSWORD', '$%ka*&Sd@#bs001@');
....
define('AUTH_KEY', 'V&0;dMO]TmQx%#B^|4EfKN@7|F*lM<@Ti-t%YMu>i.tAHSg.*/ib<!=S9m<JKH;g');
define('SECURE_AUTH_KEY', 'Dt^9C51]<d[aBGw>~gc- u1!u:GtbD=~DKsQa 9a%{zqtAoy_A5K94P0sGwT0T=|');
define('LOGGED_IN_KEY', ',zG]s6DhlP5!%.A%4<ng[!3e]%|_<2v#tdb7hZwfPvc#Dw$C!^xdo-cAHdRn);}}');
define('NONCE_KEY', '>MY+w%0%u3| +`.- Xn@5T!Dw]lhlx{E*CW2S%G{P3<9H|7otH!T5D4?J/SJhl.Q');
define('AUTH_SALT', '3l<o;p(K:ZcR/Eg66|b0hlq,DB[=(<+@i$;mMWiKZ(AZzr@8&4wRs*#W#[edw/8b');
define('SECURE_AUTH_SALT', 'fI(t>tPen]VS@Jqjb]4*EEB98Tq4B5Op(].5f`-5lbSue&/R;X-Z0aVXz;|6Ac/g');
define('LOGGED_IN_SALT', '#Vi!aZ{7-F#49xUIlyI^}m7c)aAJNR:{N$;xev(Vv**U~n] $sjYpRMOvO+=(Tw-');
define('NONCE_SALT', '2<j.NLGQ_@Q|j)yJi=@l)C}C|aY]h+-V1P#f;#.[$5d(-Joi66^N<oEIq]nuLzxl');
...
# Install WordPress To complete the installation of WordPress, point your favorite web browser to SUBDOMAIN.DOMAIN.TLD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment