The Perfect Server - CentOS 6.3 x86_64 (nginx, Dovecot, ISPConfig 3) - Page 4
11 Install Dovecot
Dovecot can be installed as follows:
yum install dovecot dovecot-mysql
Now create the system startup links and start Dovecot:
chkconfig --levels 235 dovecot on
12 Install Postfix
Postfix can be installed as follows:
yum install postfix
Then turn off Sendmail and start Postfix:
chkconfig --levels 235 sendmail off
13 Install Getmail
Getmail can be installed as follows:
yum install getmail
14 Install Amavisd-new, SpamAssassin, And ClamAV
To install amavisd-new, spamassassin and clamav, run the following command:
yum install amavisd-new spamassassin clamav clamd unzip bzip2 unrar perl-DBD-mysql
Then we start freshclam, amavisd, and clamd.amavisd:
15 Install Nginx, PHP5 (PHP-FPM), And Fcgiwrap
Nginx is available as a package for CentOS 6.3 (from EPEL) which we can install as follows:
yum install nginx
If Apache2 is already installed on the system, stop it now...
... and remove Apache's system startup links:
chkconfig --del httpd
Then we create the system startup links for nginx and start it:
chkconfig --levels 235 nginx on
(If both Apache2 and nginx are installed, the ISPConfig 3 installer will ask you which one you want to use - answer nginx in this case. If only one of these both is installed, ISPConfig will do the necessary configuration automatically.)
We can make PHP5 work in nginx through PHP-FPM (PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites). We can install php-fpm together with php-cli and some PHP5 modules like php-mysql which you need if you want to use MySQL from your PHP scripts as follows:
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
Next we open /etc/php.ini...
... and change the error reporting (so that notices aren't shown any longer):
Also set cgi.fix_pathinfo=0:
(Please read http://wiki.nginx.org/Pitfalls to find out why you should do this.)
In addition to that, in order to avoid errors like
[08-Aug-2011 18:07:08] PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /usr/share/nginx/html/info.php on line 2
... in /var/log/php-fpm/www-error.log when you call a PHP script in your browser, you should set date.timezone in /etc/php.ini:
You can find out the correct timezone for your system by running:
[root@server1 tmp]# cat /etc/sysconfig/clock
Next create the system startup links for php-fpm and start it:
chkconfig --levels 235 php-fpm on
PHP-FPM is a daemon process (with the init script /etc/init.d/php-fpm) that runs a FastCGI server on port 9000.
To get CGI support in nginx, we install Fcgiwrap.
Fcgiwrap is a CGI wrapper that should work also for complex CGI scripts and can be used for shared hosting environments because it allows each vhost to use its own cgi-bin directory.
As there's no fcgiwrap package for CentOS 6.3, we must build it ourselves. First we install some prerequisites:
yum install fcgi-devel
Now we can build fcgiwrap as follows:
This installs fcgiwrap to /usr/local/sbin/fcgiwrap.
Next we install the spawn-fcgi package which allows us to run fcgiwrap as a daemon:
yum install spawn-fcgi
... and modify the file as follows:
Now add the user nginx to the group apache:
usermod -a -G apache nginx
Create the system startup links for spawn-fcgi...
chkconfig --levels 235 spawn-fcgi on
... and start it as follows:
You should now find the fcgiwrap socket in /var/run/fcgiwrap.socket, owned by the user and group apache (some scripts, e.g. Mailman, expect to be run by the user/group apache, that's why we don't run spawn-fcgi as user/group nginx, but instead add nginx to the apache group).