Инсталляция Nginx как web сервера на Centos 6.5 (PHP 6.5, PHP-FPM)
При необходимости отключить firewall и Selinux.
### NGINX REPO
# rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
### EPEL REPO (Нужно для REMI)
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
### REMI REPO
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# yum --enablerepo=remi,remi-php56 install -y nginx php-fpm php-common
===========================
# yum --enablerepo=remi,remi-php56 install -y \
php-opcache \
php-pecl-apcu \
php-cli \
php-pear \
php-pdo \
php-mysqlnd \
php-pgsql \
php-pecl-mongo \
php-pecl-sqlite \
php-pecl-memcache \
php-pecl-memcached \
php-gd \
php-mbstring \
php-mcrypt \
php-xml
# chkconfig --level 345 nginx on
# service nginx restart
# chkconfig --level 345 php-fpm on
# service php-fpm restart
========================
Configure Nginx and PHP-FPM
Note: I use apache user and group here, because PHP-FPM runs as apache default (apache choosed to be able to access some dir as httpd). If you use some other user on your php-fpm conf then change this accordingly.
## public_html directory and logs directory ##
# mkdir -p /srv/www/testsite.local/public_html
# mkdir -p /var/log/nginx/testsite.local
# chown -R apache:apache /srv/www/testsite.local
# chown -R nginx:nginx /var/log/nginx
// Create and configure virtual host directories under /etc/nginx
# mkdir /etc/nginx/sites-available
# mkdir /etc/nginx/sites-enabled
# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
# vi /etc/nginx/nginx.conf
Add following lines to /etc/nginx/nginx.conf file, after “include /etc/nginx/conf.d/*.conf” line (inside http block).
## Load virtual host conf files. ##
include /etc/nginx/sites-enabled/*;
# vi /etc/nginx/sites-available/testsite.local
server {
server_name testsite.local;
access_log /var/log/nginx/testsite.local/access.log;
error_log /var/log/nginx/testsite.local/error.log;
root /srv/www/testsite.local/public_html;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/testsite.local/public_html$fastcgi_script_name;
}
}
### Link your virtual host to /etc/nginx/sites-enabled
# cd /etc/nginx/sites-enabled/
# ln -s /etc/nginx/sites-available/testsite.local
# service nginx restart
# vi /srv/www/testsite.local/public_html/index.php
<?php
phpinfo();
?>
# service nginx restart
Остается в hosts машины, с которой планируется подключаться добавить информацию, что testsite.local это наш nginx.
# vi /etc/hosts
192.168.1.21 testsite.local
Введя в бразуере http://testsite.local/ получим информацию о PHP и библиотеках.
На основе документа:
http://www.if-not-true-then-false.com/2011/install-nginx-php-fpm-on-fedora-centos-red-hat-rhel/