Last active
December 11, 2019 18:27
-
-
Save linuxoracledev/20ac03b797dadc807953390d03a05ea0 to your computer and use it in GitHub Desktop.
How to Install WordPress with LEMP Stack on Ubuntu 18.04
This file contains 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
##Install NGINX | |
#Update the system | |
sudo apt update | |
#Install nginx | |
sudo apt install nginx | |
#Allow connections to Nginx on firewall | |
sudo ufw allow 'Nginx HTTP' | |
#verify the change | |
sudo ufw status | |
# | |
#Enable ufw firewall | |
#sudo ufw enable | |
# | |
##Install the MySQL Database server | |
sudo apt-get install mysql-server -y | |
#Configure MySQL Security | |
sudo mysql_secure_installation | |
#Check, Start, Enable MySql service to automatically start upon boot | |
sudo service mysql status | |
sudo systemctl start mysql | |
sudo systemctl enable mysql | |
#Chek MySql Version | |
sudo mysqladmin -p -u root version | |
###################Optional################################ | |
#Open up the MySQL prompt | |
sudo mysql | |
#Check authentication method for database user | |
# SELECT user,authentication_string,plugin,host FROM mysql.user; | |
#Configure the root account to authenticate with a password | |
# ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; | |
#Reload the grant tables and put changes into effect | |
FLUSH PRIVILEGES; | |
#After configuring root user to authenticate with a password, it is not possible to access MySQL with the sudo mysql command, Instead, use mysql -u root -p | |
exit | |
########################################################################### | |
##Installing PHP and Configuring Nginx to Use the PHP | |
# Install Ubuntu’s universe repository | |
sudo add-apt-repository universe | |
#Install fastCGI process manager- php-fpm along with php-mysql module | |
sudo apt install php-fpm php-mysql | |
#And some more module | |
apt install -y php-common php-mbstring php-gd php-intl php-xml php-mcrypt | |
#Check PHP Version | |
php --version | |
#open the PHP configuration file, funcomment the ‘cgi.fix_pathinfo’ line | |
nano /etc/php/7.3/fpm/php.ini | |
#restart the PHP-FPM service | |
systemctl restart php7.3-fpm.service | |
#create a new MySQL user and database | |
sudo mysql -u root -p | |
#CREATE DATABASE wordpress; | |
#GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost' IDENTIFIED BY 'PASSWORD'; | |
#FLUSH PRIVILEGES; | |
#exit; | |
#Download and Install WordPress and unzip and change right | |
wget https://wordpress.org/latest.zip | |
unzip latest.zip -d /var/www/html/ | |
chown -R www-data:www-data /var/www/html/wordpress | |
#List the contents for the directory /var/run/php/ | |
ls /var/run/php/ | |
#.sock file should be there this .sock file will be in location section in server block file | |
##server block By default located in /etc/nginx/sites-available/default. Open a new server block configuration file within the /etc/nginx/sites-available/ directory name the config file mylemp.com | |
sudo nano /etc/nginx/sites-available/mylemp.com | |
#Add the following content in mylemp.com file | |
# | |
#server { | |
# listen 80; | |
# root /var/www/html/wordpress; | |
# index index.php index.html index.htm index.nginx-debian.html; | |
# server_name mylemp.com; | |
# | |
# location / { | |
# try_files $uri $uri/ =404; | |
# } | |
# | |
# location ~ \.php$ { | |
# include snippets/fastcgi-php.conf; | |
# fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; | |
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
# include fastcgi_params; | |
# | |
# } | |
# | |
# location ~ /\.ht { | |
# deny all; | |
# } | |
#} | |
#After adding this content, save and close the file | |
#Enable new server block file by creating a symbolic link from (/etc/nginx/sites-available/ directory) to (/etc/nginx/sites-enabled/) | |
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ | |
#Unlink the default configuration file from the /sites-enabled/ directory | |
sudo unlink /etc/nginx/sites-enabled/default | |
sudo unlink /etc/nginx/sites-available/default | |
#Edit the file in nano. | |
#sudo nano /etc/nginx/sites-available/default | |
#Test your new configuration file for syntax errors | |
sudo nginx -t | |
#If any errors are reported, go back and recheck your file before continuing | |
#Reload Nginx to make the necessary changes | |
sudo systemctl reload nginx | |
#Test if PHP is working properly place a file called info.php inside nginx web server root directory (/var/www/html/) | |
sudo nano /var/www/html/info.php | |
#Enter the following content inside the file and save it | |
############### | |
# <?php # | |
# phpinfo(); # | |
# ?> # | |
############### | |
#Reload Nginx to make the necessary changes | |
sudo systemctl reload nginx | |
#Visit page: http://your_server_ip_address/info.php or http://localhost/info.php | |
#To install Wordpress visit http://wplemp.com and follow on screen instruction | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
View on Youtube: part 1 https://www.youtube.com/watch?v=xK2V4QDeLFw&t=5s
part 2 https://www.youtube.com/watch?v=y5oRuthWiu0