Commands to Host WordPress in LEMP (Ubuntu 20.04)


ssh root@192.12.345.67

apt-get update

apt-get upgrade

dpkg-reconfigure tzdata


hostnamectl set-hostname classic

nano /etc/hosts

	192.12.345.67	classic
	2400:8904::f03c:92ff:fe6a:58cd/64	classic


adduser admin

adduser admin sudo


ssh-keygen -b 4096

ssh-copy-id admin@192.12.345.67

ssh admin@192.12.345.67

sudo nano /etc/ssh/sshd_config

	PermitRootLogin no
	PasswordAuthentication no

sudo service ssh restart

sudo ufw app list

sudo ufw allow OpenSSH

sudo ufw enable

sudo ufw status

sudo apt install nginx

sudo systemctl start nginx
sudo systemctl enable nginx

sudo nano /etc/nginx/nginx.conf

	server_names_hash_bucket_size 128;
	client_max_body_size 100m;
	server_tokens off;

sudo ufw app list
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status

sudo apt install mariadb-server

sudo systemctl start mariadb
sudo systemctl enable mariadb

sudo mysql_secure_installation

sudo apt install php-fpm php-mysql php-curl php-gd php-intl php-soap php-mbstring php-zip php-imagick php-xml php-xmlrpc

sudo sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/7.4/fpm/php.ini

sudo nano /etc/php/7.4/fpm/php.ini

	post_max_size = 100M
	upload_max_filesize = 100M

sudo service php7.4-fpm restart
sudo service nginx restart

sudo mkdir -p /var/www
sudo rm -rf /var/www/html
sudo wget
sudo apt install unzip
sudo unzip
sudo cp -R wordpress/* /var/www/
sudo rm
sudo rm -rf wordpress

sudo mysqldump -u root wbxpress > wbxpress.sql

sudo scp -v -r admin@ /home/admin/
sudo scp -v -r admin@ /var/www/
sudo scp -v -r admin@ /var/www/
sudo scp -v -r admin@* /var/www/wp-content/

sudo chown -R www-data:www-data /var/www
sudo find /var/www -type d -exec chmod 755 {} \;
sudo find /var/www -type f -exec chmod 664 {} \;
sudo chmod 444 /var/www/wp-config.php
sudo chown admin:admin /var/www/wp-config.php

sudo nano /etc/nginx/sites-available/default

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/

sudo nano /etc/nginx/sites-available/

	location / { try_files $uri $uri/ /index.php$is_args$args; }
	location ~ \.php$ { include snippets/fastcgi-php.conf;
	fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; }

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

sudo rm /etc/nginx/sites-enabled/default

sudo service nginx restart

sudo mysql -u root

show databases;

GRANT ALL ON wbxpress.* TO 'wbUser1'@'localhost' IDENTIFIED BY 'wbPass2';
flush privileges;

sudo mysql -u root wbxpress < wbxpress.sql

sudo nano /var/www/wp-config.php

sudo apt install certbot python3-certbot-nginx

sudo certbot --nginx -d -d

sudo crontab -e

	15 3 * * * /usr/bin/certbot renew --quiet

Leave a Reply

Your email address will not be published. Required fields are marked *