LEMP: Difference between revisions
No edit summary |
|||
| Line 1: | Line 1: | ||
==Update Software Packages== | ==Update Software Packages== | ||
<syntaxhighlight lang="bash"> | |||
sudo apt update | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo apt upgrade | |||
</syntaxhighlight> | |||
==Install Nginx Web Server== | ==Install Nginx Web Server== | ||
<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. | ||
<syntaxhighlight lang="bash"> | |||
sudo systemctl enable nginx | |||
</syntaxhighlight> | |||
Then start Nginx with this command: | Then start Nginx with this command: | ||
<syntaxhighlight lang="bash"> | |||
sudo systemctl start nginx | |||
</syntaxhighlight> | |||
Now check out its status. | Now check out its status. | ||
<syntaxhighlight lang="bash"> | |||
sudo systemctl status nginx | |||
</syntaxhighlight> | |||
Check Nginx version. | Check Nginx version. | ||
<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. | ||
<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. | ||
<syntaxhighlight lang="bash"> | |||
sudo chown www-data:www-data /usr/share/nginx/html -R | |||
</syntaxhighlight> | |||
==Install MariaDB Database Server== | ==Install MariaDB Database Server== | ||
<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. | ||
<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: | ||
<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 | ||
<syntaxhighlight lang="bash"> | |||
sudo systemctl enable mariadb | |||
</syntaxhighlight> | |||
Now run the post installation security script. | Now run the post installation security script. | ||