Skip to content

Instantly share code, notes, and snippets.

@ThinkLikeLinux
Last active Dec 22, 2020
Embed
What would you like to do?
#!/bin/sh
sudo apt-get update
sudo apt-get upgrade
lsb_release -a
#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
CREATE DATABASE mydb;
CREATE USER 'sumaiya'localhost' IDENTIFIED WITH mysql_native_password BY 'S2020*';
ALTER USER 'sumaiya'@'localhost' IDENTIFIED WITH mysql_native_password BY 'S2020*';
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT on *.* TO 'sumaiya'@'localhost' WITH GRANT OPTIONS
use mydb;
FLUSH PRIVILEGES;
exit
sudo service mysql restart
#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 add configuration file for NGINX server block and edit it like below.
sudo nano /etc/nginx/sites-available/default
server {
listen 80;
root /var/www/html/wordpress;
index index.php index.html;
server_name domain.com;
access_log /var/log/nginx/domain.access.log;
error_log /var/log/nginx/domain.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/default .
sudo systemctl reload nginx
#Configure NGINX for WordPress
sudo mkdir -p /var/www/html/wordpress/
#Download and Configure WordPress
cd /var/www/html/
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -zxvf latest.tar.gz
#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/
sudo mv wp-config-sample.php wp-config.php
#To grab secure values from the WordPress secret key generator, type:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
sudo nano wp-config.php
...
...
define('DB_NAME', 'mydb');
define('DB_USER', 'sumaiya');
define('DB_PASSWORD', 'S2020*');
...
define('AUTH_KEY', '0Y!mj@93D!Gya@(1[gfI(dBa,CKSRRb=v/-3-lrCd F{]+^#Pl?}5rl!:~V=B=Iu');
define('SECURE_AUTH_KEY', '_-38&Oo>LcMfDo|X4aQui_R5ooWo{o&}(~,+0#-LolN0pWC 1*}T?/)|Xh(0Chd');
define('LOGGED_IN_KEY', 'A]4U[iLX%+-4Z<p(8!7x_fg1%U,zR(RoET?~S2Qg?c A05WnW#jH7--5MOo}%3r_');
define('NONCE_KEY', '%hj;+dj8Ko=Z ~;ldqb)yVfIG?l!HHh S0sP57M|uofJ_`_aR8g(}ZypQC|fCm<U');
define('AUTH_SALT', 'a<|J&Im]I$mcIsnhnu/SiFRw`Zw3<7}kGCx-yw)7;.dj-6l9w31p2a+,>tUntOO[');
define('SECURE_AUTH_SALT', 'Gag)&RM<*jNL#f<z?5EF?wP1@GObe ms xLKcz@eHRA`C~M7V|4 oalH[JC*7Xo#');
define('LOGGED_IN_SALT', 'w]39a8;>oJY&[%_xX!2+?dr#_<yZmXgL(?p2E@vr|#Ne5yFvFhHiUgX%6k3& c$B');
define('NONCE_SALT', 'SV&En_aHD9!^(9{B3B#&XY&.yCkA.^Iuu bEWY;z.X|s?Zrm&T!8s]y&c0a^r%9[');
...
#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