Nginx for Drupal and for Redis

Recently, I compiled nginx on CentOS 6 for a Drupal 7 installation and for a Redis installation. So, I thought that I would share my steps.

Whenever I compile nginx, I always use the nginx_syslog_patch to enable syslog logging. The only module that is required for Drupal 7 is nginx-upload-progress-module. Here is my configuration for Drupal 7.

First, I added two repositories to get the latest PHP binaries.
rpm -Uhv epel-release-6-8.noarch.rpm
rpm -Uhv remi-release-6.rpm
cd /etc/yum.repos.d/
Enable the remi repository.

yum install git vim openssl php php-fpm php-common php-pear php-pdo php-mysql php-gd php-mbstring php-mcryp mysql gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel make patch readline-devel pcre-devel openssl-devel

Second, get the modules:
git clone
git clone

Download the latest stable release of the nginx source code.
tar -zxvf nginx-1.2.7.tar.gz
cd nginx-1.2.7
patch -p1 < /root/nginx_syslog_patch/syslog_1.2.7.patch After nginx has been patch, you can compile and install. ./configure --add-module=/root/nginx_syslog_patch --add-module=/root/nginx-upload-progress-module --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g' make; make install Next, you can get the latest stable release of drupal: wget You will need to configure php-fpm and nginx. I recommend starting with the following configuration bundle. This will enable you to get up and running with drupal in a short period of time. I also decided to configure nginx for connecting to Redis. For me the best module for connected to Redis is lua-resty-redis. I recommend it. Download and compile it. OpenResty is nginx with a bunch of nginx modules bundled in. After compiling openresty, you will have an nginx binary with many nice lua modules installed. Below is my openresty configuration. wget tar -xzvf ngx_openresty- cd ngx_openresty- ./configure --add-module=/root/nginx_syslog_patch --add-module=/root/nginx-upload-progress-module --without-lua_resty_memcached --without-lua_resty_mysql --with-luajit --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --user=apache --group=apache --with-http_realip_module --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --without-http_memcached_module --without-http_auth_basic_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-cc-opt='-O2 -g' Some good resources for nginx and lua are as follows:

Leave a Reply