CentOS Nginx Apache

Установка Nginx как Frontend к Apache

Устанавливаем Apache

 # yum -y install httpd httpd-devel

Добавляем httpd в автозагрузку

 # chkconfig httpd on

В конфигурационном файле /etc/httpd/conf/httpd.conf
Listen 127.0.0.1:8080

Устанавливаем php.

 # yum -y install php
# php -v
PHP 5.1.6 (cli) (built: Mar 31 2010 02:44:37)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

Обновить php 5.1 до версии 5.2

# vi /etc/yum.repos.d/CentOS-Testing.repo
  [c5-testing]
  name=CentOS-5 Testing
  baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
  enabled=1
  gpgcheck=1
  gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
  includepkgs=php*
 # yum -y update php
# php -v
PHP 5.2.10 (cli)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Обновить php 5.1 до версии 5.3

# rpm -Uvh http://rpms.famillecollet.com/el5.i386/remi-release-5-7.el5.remi.noarch.rpm
# yum  -y --enablerepo=remi update php
# php -v
PHP 5.3.3 (cli)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Устанавливаваем Nginx

# yum -y install nginx

Добавляем Nginx в автозагрузку

# chkconfig nginx on

Версия Nginx

# nginx -v
nginx version: nginx/0.6.39

Параметры с которыми был установлен Nginx

# nginx -V
nginx version: nginx/0.6.39
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
configure arguments:
--user=nginx --group=nginx
--prefix=/usr/share/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
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy
--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi
--pid-path=/var/run/nginx.pid
--lock-path=/var/lock/subsys/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_gzip_static_module
--with-http_stub_status_module
--with-http_perl_module
--with-mail
--with-mail_ssl_module
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables'
--add-module=/builddir/build/BUILD/nginx-0.6.39/nginx-upstream-fair

Пример виртуального хоста nginx.conf

 server {
   listen 192.168.0.106:80;
   access_log  /var/log/nginx/bezha.access.log  main;
   location /
{
   root   /var/www/html;
   index  index.html index.php  index.htm;
   proxy_pass http://127.0.0.1:8080;
   proxy_redirect off;
   proxy_set_header Host $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

  location ~* ^.+\.(jpg|gif|avi|mp3|zip|js)$ {
    root /var/www/html/static/;
    }
}
# nginx -t
the configuration file /etc/nginx/nginx.conf syntax is ok
the configuration file /etc/nginx/nginx.conf was tested successfully
# service nginx restart
Stopping nginx:                                           [  OK  ]
Starting nginx:                                           [  OK  ]

Установка mod_rpaf

# rpm -ihv http://centos.alt.ru/repository/centos/5/x86_64/centalt-release-5-3.noarch.rpm
# yum -y --enablerepo=CentALT install mod_rpaf

Прописываем в /etc/httpd/conf/httpd.conf

LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
RPAFsethostname Off
RPAFproxy_ips 127.0.0.1
RPAFheader X-Real-IP
# apachectl -t
Syntax OK
service httpd restart
Stopping httpd:                                           [  OK  ]
Starting httpd:                                           [  OK  ]

Server Status Nginx :

server {
listen  80;
location / {
stub_status on;
}
}

Результат: http://ip.ip.ip.ip/server-status

Active connections: 1
server accepts handled requests 1 1 4
Reading: 0 Writing: 1 Waiting: 0

Похожие записи: CentOS Nginx FastCGI