Skip to content

Instantly share code, notes, and snippets.

@alokraj68
Created May 30, 2020 18:43
Show Gist options
  • Select an option

  • Save alokraj68/d0929e8c4120f1993a48eb0f90697670 to your computer and use it in GitHub Desktop.

Select an option

Save alokraj68/d0929e8c4120f1993a48eb0f90697670 to your computer and use it in GitHub Desktop.
LEMP Install Ubuntu
#!/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 -u root -p
CREATE DATABASE school DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON school.* TO 'trainee'@'localhost' IDENTIFIED BY 'D@y-7869';
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/rakibulinux.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-available
# cat rakibulinux.conf
cd /etc/nginx/sites-enabled
ln -s ../sites-available/rakibulinux.conf .
sudo systemctl reload nginx
#Configure NGINX for WordPress
sudo mkdir -p /var/www/html/wordpress/public_html
#Download and Configure WordPress
cd /var/www/html/wordpress/public_html
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/public_html
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:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
sudo nano wp-config.php
...
...
define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wpuser');
define('DB_PASSWORD', 'Passw0rd!');
...
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