Они оба - http серверы. Зачем устанавливать сервер на сервер? Чего Вам не хватило в своем Апаче?
Наверное затем же, зачем его ставят практически все хостеры в мире? Почитайте сначала про nginx. Апач медленный и дырявый. Это если в двух словах. А вообще с такими вопросами и в Support Team...
По теме. Давайте вернемся к стандартным мануалам с 8080 портом.
В
/etc/apache2/httpd.conf должна быть одна строка:
В
/etc/apache2/ports.confNameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080
Создаем конфигурационный файл /etc/apache2/sites-available/site.ru:
Header always unset "X-Powered-By"
ServerSignature Off
ServerTokens Prod
<VirtualHost 127.0.0.1:8080>
ServerAdmin server@site.ru
ServerName site.ru
DocumentRoot /var/www/site.ru/public/
ErrorLog /var/www/site.ru/logs/apache.error.log
CustomLog /var/www/site.ru/logs/apache.access.log combined
UseCanonicalName Off
<IfModule mod_fastcgi.c>
AddHandler php-fastcgi .php
Action php-fastcgi /usr/sbin/php-fpm.fcgi
ScriptAlias /usr/sbin/php-fpm.fcgi /usr/sbin/php-fpm
<Directory /usr/sbin>
Options ExecCGI FollowSymLinks
SetHandler fastcgi-script
Order allow,deny
Allow from all
</Directory>
</IfModule>
</VirtualHost>
Врубаем сайт:
NGINXСоздаём конфигурационный файл для нашего сайта /etc/nginx/sites-available/site.ru:
server {
listen 80;
server_name www.site.ru;
rewrite ^(.*) http://site.ru$1 permanent;
}
server {
listen 80;
server_name site.ru;
access_log /var/www/site.ru/logs/nginx.access.log;
error_log /var/www/site.ru/logs/nginx.error.log;
root /var/www/site.ru/public/;
# Static Contents
location ~* ^.+.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires 1y;
}
# CSS and JS
location ~* ^.+.(css|js)$ {
access_log off;
log_not_found off;
}
# this will prevent files like .htaccess .htpassword .secret etc from being served
# You can remove the log directives if you wish to
# log any attempts at a client trying to access a hidden file
location ~ /\. { deny all; access_log off; log_not_found off; }
location ~ \.(tpl|log)$ {deny all; access_log off; log_not_found off; }
location = /apc.php {
auth_basic "Super LS";
auth_basic_user_file /etc/nginx/sites-enabled/.htpasswd;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location = /memcache.php {
auth_basic "Super LS";
auth_basic_user_file /etc/nginx/sites-enabled/.htpasswd;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
# Dydamic Content forward to Apache
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
}
Активируем сайт:
ln -s /etc/nginx/sites-available/site.ru /etc/nginx/sites-enabled/site.ru
Рестартуем апач и nginx
Должно работать..
P.S. конфиги брал готовые, подгоните под себя...