На примере CentOS / Fedora, nginx можно установить из Epel (как подключить Epel в CentOS), либо подключить репу nginx с офф. сайта, после подключения реп:
yum install nginx
Перенастраиваем Apache изменивпорт в директиве Listen, к примеру на 81:
nano /etc/httpd/conf/httpd.conf
...
Listen 81
Далее устанавливаем mod_rpaf, как это сделать написано здесь и настраиваем nginx, указываем разрешения на папку с логами:
chown -R nginx:nginx /var/log/nginx
Далее, открываем конфиг nginx:
nano /etc/nginx/nginx.conf
По умолчанию он выглядел у меня так:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
index index.html index.htm;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
server_name localhost;
root /usr/share/nginx/html;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
Так, как устанавливал его на локальный сервер разработки, с тестовой папкой /var/www/html, то настроил так, изменив лишь директиву location и указав localhost вместо реального IP:
....
location / {
proxy_pass http://localhost:81/;
include /etc/nginx/uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
....
Далее перезапускаем все web сервисы:
systemctl restart httpd.service && systemctl restart nginx.service
Смотрим (в моем случае) localhost:
http://localhost/