1.Установка зависимостей
1 |
# yum install gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools-devel |
2.Загрузка,распаковка и сборка с исходников Nginx
1 |
# cd /tmp |
1 |
# sudo wget http://nginx.org/download/nginx-1.6.2.tar.gz |
1 |
# sudo tar xvfz nginx-1.6.2.tar.gz |
1 |
# cd nginx-1.6.2 |
1 |
sudo ./configure --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 --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --with-debug --add-module=/opt/echo-nginx-module/echo-nginx-module-0.56 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Configuration summary + using system PCRE library + using system OpenSSL library + md5: using OpenSSL library + sha1: using OpenSSL library + using system zlib library nginx path prefix: "/usr/share/nginx" nginx binary file: "/usr/sbin/nginx" nginx configuration prefix: "/etc/nginx" nginx configuration file: "/etc/nginx/nginx.conf" nginx pid file: "/var/run/nginx.pid" nginx error log file: "/var/log/nginx/error.log" nginx http access log file: "/var/log/nginx/access.log" nginx http client request body temporary files: "/var/lib/nginx/tmp/client_body" nginx http proxy temporary files: "/var/lib/nginx/tmp/proxy" nginx http fastcgi temporary files: "/var/lib/nginx/tmp/fastcgi" nginx http uwsgi temporary files: "/var/lib/nginx/tmp/uwsgi" nginx http scgi temporary files: "/var/lib/nginx/tmp/scgi" |
1 |
# make |
1 |
# make install |
3.Создание пользователя nginx
1 |
# useradd -r nginx |
4.Создаем скрипт запуска Nginx http://wiki.nginx.org/InitScripts Для Centos http://wiki.nginx.org/RedHatNginxInitScript
1 |
# nano /etc/init.d/nginx |
1 |
# /etc/init.d/nginx start |
5.Настройка GeoIP в Nginx
1 |
# mkdir /etc/nginx/geoip |
1 |
# cd /etc/nginx/geoip |
1 |
# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz |
1 |
# gunzip GeoIP.dat.gz |
1 |
# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz |
1 |
# gunzip GeoLiteCity.dat.gz |
1 |
# nano /etc/nginx/nginx.conf |
1 2 3 4 5 6 |
http { .................... geoip_country /etc/nginx/geoip/GeoIP.dat; # the country IP database geoip_city /etc/nginx/geoip/GeoLiteCity.dat; # the city IP database …. } |
1 |
# nano /etc/nginx/fastcgi_params |
(для связки Nginx+PHP-FPM)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
### SET GEOIP Variables ### fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code; fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3; fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name; fastcgi_param GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code; fastcgi_param GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3; fastcgi_param GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name; fastcgi_param GEOIP_REGION $geoip_region; fastcgi_param GEOIP_CITY $geoip_city; fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code; fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code; fastcgi_param GEOIP_LATITUDE $geoip_latitude; fastcgi_param GEOIP_LONGITUDE $geoip_longitude; |
[…]