LEMP: Difference between revisions

No edit summary
Line 1: Line 1:
==Update Software Packages==
==Update Software Packages==
sudo apt update


sudo apt upgrade
<syntaxhighlight lang="bash">
sudo apt update
</syntaxhighlight>
 
<syntaxhighlight lang="bash">
sudo apt upgrade
</syntaxhighlight>


==Install Nginx Web Server==
==Install Nginx Web Server==
sudo apt install nginx
 
<syntaxhighlight lang="bash">
sudo apt install nginx
</syntaxhighlight>


After it’s installed, we can enable Nginx to auto-start at boot time by running the following command.
After it’s installed, we can enable Nginx to auto-start at boot time by running the following command.
sudo systemctl enable nginx
 
<syntaxhighlight lang="bash">
sudo systemctl enable nginx
</syntaxhighlight>


Then start Nginx with this command:
Then start Nginx with this command:
sudo systemctl start nginx
 
<syntaxhighlight lang="bash">
sudo systemctl start nginx
</syntaxhighlight>


Now check out its status.
Now check out its status.
sudo systemctl status nginx
 
<syntaxhighlight lang="bash">
sudo systemctl status nginx
</syntaxhighlight>


Check Nginx version.
Check Nginx version.
nginx -v
 
<syntaxhighlight lang="bash">
nginx -v
</syntaxhighlight>


If you are using UFW firewall, then run this command to open TCP port 80.
If you are using UFW firewall, then run this command to open TCP port 80.
sudo ufw allow http
 
<syntaxhighlight lang="bash">
sudo ufw allow http
</syntaxhighlight>


Finally, we need to make www-data (Nginx user) as the owner of web directory. By default, it’s owned by the root user.
Finally, we need to make www-data (Nginx user) as the owner of web directory. By default, it’s owned by the root user.
sudo chown www-data:www-data /usr/share/nginx/html -R
 
<syntaxhighlight lang="bash">
sudo chown www-data:www-data /usr/share/nginx/html -R
</syntaxhighlight>


==Install MariaDB Database Server==
==Install MariaDB Database Server==
sudo apt install mariadb-server mariadb-client
 
<syntaxhighlight lang="bash">
sudo apt install mariadb-server mariadb-client
</syntaxhighlight>


After it’s installed, MariaDB server should be automatically stared. Use systemctl to check its status.
After it’s installed, MariaDB server should be automatically stared. Use systemctl to check its status.
systemctl status mariadb
 
<syntaxhighlight lang="bash">
systemctl status mariadb
</syntaxhighlight>


If it’s not running, start it with this command:
If it’s not running, start it with this command:
sudo systemctl start mariadb
 
<syntaxhighlight lang="bash">
sudo systemctl start mariadb
</syntaxhighlight>


To enable MariaDB to automatically start at boot time, run
To enable MariaDB to automatically start at boot time, run
sudo systemctl enable mariadb
 
<syntaxhighlight lang="bash">
sudo systemctl enable mariadb
</syntaxhighlight>


Now run the post installation security script.
Now run the post installation security script.