Installing free Let's Encrypt SSL certificate
First, make sure the domain name points to your server through A records.
Then, execute the following commands, making sure to substitute your real email address and domain names.
Repeat -d DOMAIN as many times as necessary.
sudo certbot --nginx --agree-tos --no-eff-email --keep --redirect \
-m [email protected] -d example.org -d www.example.org
You will see a success or failure message, depending on how it went. If it worked, your certificate will be automatically renewed every 60 days.
How to modify php.ini
In case you want to modify some settings in php.ini, you can find them in /etc/php/8.1/fpm/php.ini.
You can edit the file using nano or any other editor by typing:
sudo mcedit /etc/php/8.1/fpm/php.ini
Then to apply changes, you want to restart php8.1-fpm:
sudo systemctl restart php8.1-fpm
Blocking access to directories
Sometimes you may want to deny public access to sensitive directories that are located in your public directory.
You may be tempted to type "deny from all" in a .htaccess files but that does not work on nginx!
Nginx is used in place of Apache on your server because of its superior performance.
The easiest solution is to modify the chmod (permissions) on the file or directory. Simply omit access to "others" using PuTTY or WinSCP. The command to do it over SSH:
chmod o-rwx /path/to/directory/or/file
I see "PHP Notices" and or "PHP Warnings"
Sometimes your website may show a lot of notices and warnings generated by PHP. This is only because of errors in your PHP code. Those are programmers errors and are in no way caused by the server. You can, however, hide those errors to prevent your visitors from seeing them. This is NOT a proper way of fixing the problem as it may hide some serious issues.
In order to hide PHP warnings and notices, you have to modify your php.ini file.
Set the following php.ini value:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING & ~E_NOTICE