LEMP: Difference between revisions
No edit summary |
No edit summary |
||
| Line 76: | Line 76: | ||
Now run the post installation security script. | Now run the post installation security script. | ||
<syntaxhighlight lang="bash"> | |||
sudo mysql_secure_installation | |||
</syntaxhighlight> | |||
So you can run the following command to login without providing MariaDB root password. | So you can run the following command to login without providing MariaDB root password. | ||
<syntaxhighlight lang="bash"> | |||
sudo mariadb -u root | |||
</syntaxhighlight> | |||
To exit, run | To exit, run | ||
<syntaxhighlight lang="bash"> | |||
exit; | |||
</syntaxhighlight> | |||
Check MariaDB server version information. | Check MariaDB server version information. | ||
<syntaxhighlight lang="bash"> | |||
mariadb --version | |||
</syntaxhighlight> | |||
==Install PHP7.4== | ==Install PHP7.4== | ||
<syntaxhighlight lang="bash"> | |||
sudo apt install php7.4 php7.4-fpm php7.4-mysql php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline php7.4-mbstring php7.4-xml php7.4-gd php7.4-curl | |||
</syntaxhighlight> | |||
Installing these PHP extensions ensures that your CMS runs smoothly. Now start php7.4-fpm. | Installing these PHP extensions ensures that your CMS runs smoothly. Now start php7.4-fpm. | ||
<syntaxhighlight lang="bash"> | |||
sudo systemctl start php7.4-fpm | |||
</syntaxhighlight> | |||
Enable auto-start at boot time. | Enable auto-start at boot time. | ||
<syntaxhighlight lang="bash"> | |||
sudo systemctl enable php7.4-fpm | |||
</syntaxhighlight> | |||
Check status: | Check status: | ||
<syntaxhighlight lang="bash"> | |||
systemctl status php7.4-fpm | |||
</syntaxhighlight> | |||
==Create an Nginx Server Block== | ==Create an Nginx Server Block== | ||
An Nginx server block is like a virtual host in Apache. We will not use the default server block because it’s inadequate to run PHP code and if we modify it, it becomes a mess. So remove the default symlink in sites-enabled directory by running the following command. (It’s still available as <code>/etc/nginx/sites-available/default</code>.) | An Nginx server block is like a virtual host in Apache. We will not use the default server block because it’s inadequate to run PHP code and if we modify it, it becomes a mess. So remove the default symlink in sites-enabled directory by running the following command. (It’s still available as <code>/etc/nginx/sites-available/default</code>.) | ||
<syntaxhighlight lang="bash"> | |||
sudo rm /etc/nginx/sites-enabled/default | |||
</syntaxhighlight> | |||
Then use a command-line text editor like Nano to create a brand new server block file under /etc/nginx/conf.d/ directory. | Then use a command-line text editor like Nano to create a brand new server block file under /etc/nginx/conf.d/ directory. | ||
<syntaxhighlight lang="bash"> | |||
sudo nano /etc/nginx/conf.d/default.conf | |||
</syntaxhighlight> | |||
Paste the following text into the file. The following snippet will make Nginx listen on IPv4 port 80 and IPv6 port 80 with a catch-all server name. | Paste the following text into the file. The following snippet will make Nginx listen on IPv4 port 80 and IPv6 port 80 with a catch-all server name. | ||
<syntaxhighlight lang="bash"> | |||
server { | |||
listen 80; | listen 80; | ||
listen [::]:80; | listen [::]:80; | ||
| Line 140: | Line 170: | ||
} | } | ||
} | } | ||
</syntaxhighlight> | |||
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) | Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) | ||
Then test Nginx configurations. | Then test Nginx configurations. | ||
<syntaxhighlight lang="bash"> | |||
sudo nginx -t | |||
</syntaxhighlight> | |||
If the test is successful, reload Nginx. | If the test is successful, reload Nginx. | ||
<syntaxhighlight lang="bash"> | |||
sudo systemctl reload nginx | |||
</syntaxhighlight> | |||
==Source== | ==Source== | ||