I recently posted an entry related to the installation and basic configuration of Nginx web server. In this chapter we will add the configuration of our website to server. This time we will no longer have to install any additional packages in the system or use additional external repositories. Everything is limited to editing existing files and optionally creating new ones – just as in Apache, which includes the configuration of each website. Of course, I’m assuming that you have already installed the Nginx server in accordance with the instructions from the previous chapter. This entry does not concern PHP configuration – this aspect will be discussed in the next chapter.
I have already created a series of entries related to the configuration of the Nginx server, PHP-FPM and MariaDB database few years ago but all of them were in the Polish and also are currently outdated. I decided to create this series again, this time in English and with all fresh information about this modules and nice “tricks”. This post is first one with Nginx installation and global, standard configuration of this web server. I based on Ubuntu Server (16.04) and repositories for this distrubution. Installation may look different on other systems, but configuration is the same, independent of platform.
In the old, polish version of this blog, there are several posts about nginx server and PHP configuration. These entries are outdated now, but I will be writing them again in english soon. Meanwhile, today I would like to briefly share information on the ondemand mode in PHP-FPM. I have to used it and think it’s the best solution for most configurations.
If you use OS X you can disover strange issue while connecting other machines through SSH (ex. Ubuntu Servers). It’s information about problems with load locales: perl: warning: Setting locale failed. It isn’t your server fault, but OS X default settings used in user session and profile. You can easily fix that issue editing profile file or for example ZSH config file.
Just edit ~/.profile and add that lines on the end:
After that close terminal and open it again (ZSH) or just re-login to system. You can of course use other locales, specific to your system language and region settings.
If you use Ubuntu Server and decided to install some firewall or log monitoring (UFW, LFD etc.), you can receive strange mails about SYSLOG check failed. The example content of such mails is:
Error: Failed to detect code [BlaBlaBla1234BlaBlaBla1234] in SYSLOG_LOG [/var/log/messages]
SYSLOG may not be running correctly on mymachine
You must first check rsyslog service status (service rsyslog status) – Ubuntu uses rsyslog by default and if there is no such service, you should install it. This may not be enough, becuase default rsyslog configuration doesn’t ceate messages log files. To change that, you should edit file /etc/rsyslog.d/50-default.conf (file may be called differently!) and uncomment that section:
It is responsible for saving logs to /var/logmessages file. You can also uncomment or comment other settings in that file – rsyslog provides many informations about mails, kernel, user actions or debug info. After that just restart service. Firewalls and monitoring services should work fine now.