Created
March 8, 2020 10:33
-
-
Save LinuxDevOpsGirl/15b1569ba64bfce192e29d33a20a962c to your computer and use it in GitHub Desktop.
Install WordPress with LEMP Stack Nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update & Install Nginx | |
sudo apt update && apt upgrade | |
sudo apt-get install nginx | |
sudo systemctl start nginx | |
sudo systemctl enable nginx | |
sudo systemctl restart nginx | |
sudo systemctl status nginx | |
# Install MySQL & check | |
sudo apt install mysql-server | |
sudo mysql_secure_installation | |
mysql --version | |
sudo service mysql start | |
sudo service mysql enable | |
sudo service mysql stop | |
sudo service mysql start | |
sudo service mysql restart | |
# Create MySQL DB, User | |
sudo mysql -u root -p | |
CREATE DATABASE wpdata DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; | |
GRANT ALL ON wpdata.* TO 'wpuser'@'localhost' IDENTIFIED BY 'Hira2019#@'; | |
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-enabled/default | |
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 ataur.conf | |
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/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', 'wpdata'); | |
define('DB_USER', 'wpuser'); | |
define('DB_PASSWORD', 'Hira2019#@'); | |
... | |
define('AUTH_KEY', '6jeuY77q/n77JOYerR21^i/b|>U/(f_i|PNGH{Cd(ny+lzc+qy}b+gam=K3}.m X'); | |
define('SECURE_AUTH_KEY', '}O4 7m1*%w^Fj-9,PN}Nf+ ~Zl7 |!l>#@|@.0ZWzqE=/h8%Uw:-Xnkc=FUtK1!-'); | |
define('LOGGED_IN_KEY', '}=0EMM2m4jr6Ir(6Q1a;2-zYG=dr[d-[Tc+(RI-jN`l8=U=`w GR/CO=l{N+nwBc'); | |
define('NONCE_KEY', 'E5|w;VQf8gvp,+F*6f:|0M0EKh1]) HcXwN./>$V,!X),5Sc:XcS;7XY,z,q0xF!'); | |
define('AUTH_SALT', 'bnpYA[@IA( 3n)+VUL|-2w4T85eKzV|!4KvN_R/&J|&)Pvnh-I=e%.5rz1M%UezU'); | |
define('SECURE_AUTH_SALT', 'dB*;$RO-y_U(?8Cp&r!aB4?.tzbJ~Og kFyF$Qk.v ;k-.E{us=LgN-k!js]T5 8'); | |
define('LOGGED_IN_SALT', '-gM=_=6>a~PXI%*vnyLeC;w,Pm{.Pg(rDTP3V%X -KkKaJE^n;l:- fwRGC|)m%['); | |
define('NONCE_SALT', '=Ry`8xAr9{)o_O|}xSs|9MH^Kw;#i5I0qdw:_q-Y`x:|f.=YHZA0e#c:;b7%zm.J'); | |
sudo systemctl reload nginx | |
# Visit http://localhost/wp-admin/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment