Jump to content
Froxlor Forum
  • 0

Ngnix vs. Apache2? Lohnt sich eine Umstellung?


Chaos234

Question

Huhu ihr lieben,

 

es gibt ja nginx nun doch recht lange und es soll ja besser als apache sein. Nun wollte ich wissen, wie ich am einfachsten von apache auf ngnix umstelle, inkl. php-fcgi oder php-fpm.

 

Zudem ist es fraglich, was aus dem support der .htaccess datein wird.

 

Eine grobe Umstellung habe ich hier gefunden: http://www.maffert.net/froxlor-von-apache2-nach-nginx-umstellen/- geht das so einfach? Brauche ich noch ein zus?tzliches Repro in der sources.list von debian 7?

 

Das sind so die Fragen, die ich zur Umstellung habe. Freue mich auf jede hilfreiche Antwort.

Und ja, Google hat einen thread hier im forum gefunden, jedoch von 2011, darum auch ein neuer thread ;)

 

LG

Chaos234

====Verfasst via Samsung Tab 10.5====

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

Zudem ist es fraglich, was aus dem support der .htaccess datein wird.

 

Nix ist damit, die werden von nginx nicht ber?cksichtigt, d.h. die schr?nkst die M?glichkeiten deiner Kunden ein (sofern sie das nutzen / nutzen wollen / darauf angewiesen sind / etc.)

 

Ansonsten ist eine Umstellung keine gro?e Sache, sind doch nur Configs die neugeschrieben werden und ein anderes Restart-Command f?r den Webserver...

Link to comment
Share on other sites

Huhu d00p,

 

also kann ich der Anleitung dort 100% vertrauen? Das w?re ja mal recht easy.

 

Wie verarbeitet dann aber z. B. Shopware dies? Es hat ja in den .htacces haufen-

weis rewrites stehen, via mod_rewrite und nun w?re ja dies so nicht mehr m?glich.

 

Klar, da sollte ich mal bei Shopware fragen, aber bis dato bin ich alt und grau,

was die Antwort angeht.

 

Wie also nun mod_rewrite aus ner .htacces umsetzen (ok, google ist dein freund,

ich frag aber dennoch, ist ja nicht so wild ^^).

 

Ach ja, kann ich apache zur Sicherheit parallel installiert lassen? Muss dennja nur aus dem "autostart" werfen per update-rc.d oder f?hrt dies dennoch zu Konflikten? M?chte halt im Notfall einen Fallback auf Apache haben;).

Link to comment
Share on other sites

Maximal die Performance soll gesteigert werden.

 

Ist nun die Frage, ob apache+fcgi+suexec (mom. config) oder apache+php5-fpm+suexec oder eben halt stattapache die nginx variationen mit fcgi oder fpm.

 

Durch die momentanen Zugriffe ist mein webserver doch recht langsam und diese kommen halt eben von international, da ich das forum zu einem projekt (spiel) hoste, welches international aktiv ist ... das zerrt nat?rlich zu den sto?zeiten am apache.

 

Wenn das kein Grund ist, dann weis ich nicht weiter ...

Link to comment
Share on other sites

hallo darf ich auch mal ein paar fragen stellen. :D

 

ist Apache2 mit mpm_itk genau so schnell? das zwinkern [;-)]von Pitbull am  ende hat mich jetzt verunsichert :D

 

habe mal ein sch?nes Benchmark gefunden was ich jetzt nat?rlich nicht mehr finde kann mit Apache nginx lighttpd usw.

 

 

wenn nginx keine .ht daten benutzt und das alles in die Vhost config stehen muss.

wie sehen dann die Configs aus f?r Verzeichnisschutz; RewriteEngine; FilesMatch deny; ip blocken; aus?

gibts da ein gutes tut diesbezuglich.

Link to comment
Share on other sites

ist Apache2 mit mpm_itk genau so schnell? das zwinkern [;-)]von Pitbull am  ende hat mich jetzt verunsichert :D

ansichtssache...

 

wenn nginx keine .ht daten benutzt und das alles in die Vhost config stehen muss.

wie sehen dann die Configs aus f?r Verzeichnisschutz; RewriteEngine; FilesMatch deny; ip blocken; aus?

gibts da ein gutes tut diesbezuglich.

Verzeichnisschutz regelt Froxlor via Kunden-Panel. Was Rewrite-Rules etc. angeht, verweise ich auf Google.

Link to comment
Share on other sites

So, anbei mal die Info, dass ich nun auf Nginx umgestiegen bin und alles l?uft, bis auf Shopware ^^.

 

Grund ist daf?r, dass der erstellte vHost nur auf "index.*" verweist, aber bei Shopware lediglich die shopware.php alles weitere regelt.

Nun habe ich nat?rlich Google bem?ht und das hier gfeunden: https://github.com/bcremer/shopware-with-nginx

 

Wenn ich aber in der Domain beim eigenen vHost Container den Include auf die global/shopware.conf setze, erhalte ich folgende

Meldung:

2015/03/18 15:32:57 [emerg] 812#0: duplicate location "/" in /etc/nginx/global/shopware.conf:69

Es ist also hier die Frage, warum dies passiert und wie ich das nun so anpassen kann, dass auch beim Index auf die shopware.php "gelauscht" wird.

Eventuell hat ja Froxlor daf?r, im Bezug auf nginx, eine kleine Fehlprogrammierung, denn wenn ich den Inhalt aus global/shopware.conf kopiere

und in das Eingabefeld knalle, erhalte ich einen anderen Fehler, der die Funktionalit?t auch nicht erm?glicht.

 

Ansonsten ist die kiste flotter als zuvor mit Apache und das die .htaccess's nimmer gehen ... wayne :).

Link to comment
Share on other sites

naja, du inkludierst anscheinend die /etc/nginx/global/shopware.conf in den "eigene vhost settings" einstellungen der domain. Das geht zwar grunds?tzlich, aber doppelt-vorkommende location-blocks mag nginx nicht.

 

Froxlor kann grunds?tzlich location-bl?cke zusammenf?hren. Am besten versuchst du mal die entsprechenden Anweisungen aus der /etc/nginx/global/shopware.conf in die eigenen vhost einstellungen zu kopieren, statt des includes. Garantieren kann ich da allerdings f?r nichts.

 

Ich habe dir gleich gesagt, nginx ist speziell und froxlor kann das einfach nicht alles abbilden was da manche scripts so wollen...

Link to comment
Share on other sites

Nabend,

 

anbei mal der Fehler bei folgender Config:

## Author: Benjamin Cremer
## Shopware 4 nginx rules.
## Heavily Inspired by https://github.com/perusio/drupal-with-nginx/
## Designed to be included in any server {} block.
## Please note that a upstream called "php-fpm" must be configured in the http context (nginx.conf).
## https://github.com/bcremer/shopware-with-nginx

location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /templates/_default/backend/_resources/resources/css/icon-set.css {
    gzip off;
}

## Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
}

## Deny all attems to access possible configuration files
location ~ \.(tpl|yml|ini|log)$ {
    deny all;
}

## Deny access to media upload folder
location ^~ /media/temp/ {
    deny all;
}

location ^~ /cache/ {
    deny all;
}

location ^~ /files/documents/ {
    deny all;
}

# Block direct access to ESDs, but allow the follwing download options:
#  * 'PHP' (slow)
#  * 'X-Accel' (optimized)
# Also see http://wiki.shopware.com/ESD_detail_1116.html#Ab_Shopware_4.2.2
location ^~ /files/552211cce724117c3178e3d22bec532ec/ {
    internal;
}

# Breaks backend/media/ rewrite
#
#location ~ /(engine|files|templates|media)/ {
#    location ~ \.php$ {
#        return 403;
#    }
#}

# Shopware >= 4.3 unstall / update
location /recovery/install {
    index index.php;
    try_files $uri /recovery/install/index.php?$args;
}

location /recovery/update {
    index index.php;
    try_files $uri /recovery/update/index.php?$args;
}

location / {
    ## All static files will be served directly.
    location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|html|xml)$ {
        ## Defining rewrite rules
        rewrite files/documents/.* /engine last;
        rewrite backend/media/(.*) /media/$1 last;

        expires 1w;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";

        access_log off;
        # The directive enables or disables messages in error_log about files not found on disk.
        log_not_found off;

        tcp_nodelay off;
        ## Set the OS file cache.
        open_file_cache max=3000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;

        ## Fallback to shopware
        ## comment in if needed
        #try_files $uri @shopware;
    }

    index shopware.php index.php;
    try_files $uri $uri/ /shopware.php?$args;
}

## XML Sitemap support.
location = /sitemap.xml {
    log_not_found off;
    access_log off;
    try_files $uri @shopware;
}

## robots.txt support.
location = /robots.txt {
    log_not_found off;
    access_log off;
}

location @shopware {
    rewrite / /shopware.php;
}

location ~ \.php$ {
    try_files $uri $uri/ =404;

    ## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    ## required for upstream keepalive
    # disabled due to failed connections
    #fastcgi_keep_conn on;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SHOPWARE_ENV    $shopware_env if_not_empty;
    fastcgi_param ENV             $shopware_env if_not_empty; # BC for older SW versions

    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;

    client_max_body_size 24M;
    client_body_buffer_size 128k;

    ## upstream "php-fpm" must be configured in http context
    fastcgi_pass php-fpm;
}

Fehler:

2015/03/18 21:54:28 [emerg] 23931#0: "try_files" directive is duplicate in /etc/nginx/sites-enabled/22_froxlor_ssl_vhost_deltanet-production.de.conf:39

Einstellung im eigenem vHost:

## Author: Benjamin Cremer
## Shopware 4 nginx rules.
## Heavily Inspired by https://github.com/perusio/drupal-with-nginx/
## Designed to be included in any server {} block.
## Please note that a upstream called "php-fpm" must be configured in the http context (nginx.conf).
## https://github.com/bcremer/shopware-with-nginx

location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /templates/_default/backend/_resources/resources/css/icon-set.css {
    gzip off;
}

## Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
}

## Deny all attems to access possible configuration files
location ~ \.(tpl|yml|ini|log)$ {
    deny all;
}

## Deny access to media upload folder
location ^~ /media/temp/ {
    deny all;
}

location ^~ /cache/ {
    deny all;
}

location ^~ /files/documents/ {
    deny all;
}

# Block direct access to ESDs, but allow the follwing download options:
#  * 'PHP' (slow)
#  * 'X-Accel' (optimized)
# Also see http://wiki.shopware.com/ESD_detail_1116.html#Ab_Shopware_4.2.2
location ^~ /files/552211cce724117c3178e3d22bec532ec/ {
    internal;
}

# Breaks backend/media/ rewrite
#
#location ~ /(engine|files|templates|media)/ {
#    location ~ \.php$ {
#        return 403;
#    }
#}

# Shopware >= 4.3 unstall / update
location /recovery/install {
    index index.php;
    try_files $uri /recovery/install/index.php?$args;
}

location /recovery/update {
    index index.php;
    try_files $uri /recovery/update/index.php?$args;
}

location / {
    ## All static files will be served directly.
    location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|html|xml)$ {
        ## Defining rewrite rules
        rewrite files/documents/.* /engine last;
        rewrite backend/media/(.*) /media/$1 last;

        expires 1w;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";

        access_log off;
        # The directive enables or disables messages in error_log about files not found on disk.
        log_not_found off;

        tcp_nodelay off;
        ## Set the OS file cache.
        open_file_cache max=3000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;

        ## Fallback to shopware
        ## comment in if needed
        #try_files $uri @shopware;
    }

    index shopware.php index.php;
    try_files $uri $uri/ /shopware.php?$args;
}

## XML Sitemap support.
location = /sitemap.xml {
    log_not_found off;
    access_log off;
    try_files $uri @shopware;
}

## robots.txt support.
location = /robots.txt {
    log_not_found off;
    access_log off;
}

location @shopware {
    rewrite / /shopware.php;
}

location ~ \.php$ {
    try_files $uri $uri/ =404;

    ## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    ## required for upstream keepalive
    # disabled due to failed connections
    #fastcgi_keep_conn on;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SHOPWARE_ENV    $shopware_env if_not_empty;
    fastcgi_param ENV             $shopware_env if_not_empty; # BC for older SW versions

    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;

    client_max_body_size 24M;
    client_body_buffer_size 128k;

    ## upstream "php-fpm" must be configured in http context
    fastcgi_pass php-fpm;
}

Rest ist Standarthost via froxlor.

Problem ist, dass auf die shopware.php gelauscht werden muss, wie auch immer.

 

Nebenbeit habe ich noch ein anderes Problem:

 

Ich habe PHP5-FPM nachgezogen, was einige Probleme l?ste und u. a. nun auch die "Custom PHP-Configs" reaktivierte, welche mit der PHP-Binary /usr/bin/php-cgi verbunden sind.

Allerdings werden diese total ignoriert, wie hier zu sehen ist: https://deltanet-production.de/phpinfo.phpund http://forum.ygopro.de/phpinfo.php

 

Ist nun die Frage, ob das nen Fehler ist, oder ob hier nur eine globale PHP-INI benutzt werden kann.

Immerhin fehlen mir da atm so sachen wie ionCube, smarty3 und ... naja gut, Zend ist aktiv :) .

 

Das wars dann erstmal von meiner Seit aus :)

Link to comment
Share on other sites

Das Ding ist einfach nicht vorgesehen f?r sowas, am einfachsten ist es, du legst f?r die shopware domain manuell eine vhost-config an (mit anderem namen damit froxlor sie nicht ?berschreibt). Das erspart dir viel ?rger.

 

Froxlor kann einfach nicht alle spezialf?lle von nginx abbilden. F?r den "normal" user ist das kein problem aber bei solchen Anforderungen wie bei dem Shopteil klappts halt nicht.

 

Und die php.ini werden pro domain doch via php-config festgelegt, und die kommt aus froxlor (siehe PHP Konfigurationen) - beachte auch das nicht alle direktiven frei setzbar sind, siehe https://github.com/Froxlor/Froxlor/blob/master/lib/classes/phpinterface/class.phpinterface_fpm.php#L42und folgende

Link to comment
Share on other sites

Huhu d00p,

 

ja, das dachte ich eigentlich auch, aber wie du selbst sehen kannst, wird die php-config nicht angewand, was ich doch recht komisch finde.

Kann ich das ?ndern, in dem ich in den vHost-Einstellung zu der php-config verweise? Wenn ja, wie muss das bei nginx hei?en?

 

Ok, nen eigenen vHost f?r die Domain anzulegen ist kein Problem. Bin mal gespannt, ob er die dann auch so versteht :).

 

EDIT: Der vHost-Container steht nun. Problem ist allerdings, dass dieser nicht erkannt werden m?chte, trotz "service nginx restart".

 

Leider kann ich die Domain auch nicht so einfach aus dem System von Froxlor entfernen, da sonst meine Mails nicht mehr funktionieren :/

 

EDIT 2: Hab einfach meine vHosts mit 000_ am anfang geschoben - es gibt jetzt zwar brav nen error wegen "duplicate server_name" aber jut,

das ist mir jetzt mal latte.

 

Bliebe nur noch der Punkt mit der php.ini, die nicht einmal im froxlor-vhost verankert ist :( ...

Link to comment
Share on other sites

Ok, die habe ich gefunden, in dem pool.d/ - aber da sehe ich schon ein Problem, da ich folgende custom-php.ini habe:

allow_url_fopen = On
asp_tags = On
disable_classes =
disable_functions =
display_errors = On
display_startup_errors = On
default_socket_timeout = 300
enable_dl = On
error_reporting = E_ALL & ~E_NOTICE
expose_php = On
file_uploads = On
cgi.force_redirect = 1
track_errors = on
gpc_order = "GPC"
html_errors = On
ignore_repeated_errors = On
ignore_repeated_source = Off
include_path = ".:{PEAR_DIR}:/usr/share/php/smarty3"
log_errors = On
log_errors_max_len = 1024
max_execution_time = 6000000
max_input_time = 6000000
memory_limit = 128M
{OPEN_BASEDIR_C}open_basedir = "{OPEN_BASEDIR}"
output_buffering = 4096
post_max_size = 1024M
;precision = 14
register_argc_argv = Off
register_globals = Off
report_memleaks = On
sendmail_path = "/usr/sbin/sendmail -t -i -f {CUSTOMER_EMAIL}"
suhosin.get.max_value_length = 10000
suhosin.post.max_vars = 5000
suhosin.get.max_vars = 5000
suhosin.request.max_vars = 5000
session.auto_start = 0
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.cache_expire = 180
session.cache_limiter = nocache
session.cookie_domain =
session.cookie_lifetime = 0
session.cookie_path = /
session.entropy_file = /dev/urandom
session.entropy_length = 16
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.gc_probability = 1
session.name = PHPSESSID
session.referer_check =
session.save_handler = files
session.save_path = "{TMP_DIR}"
session.serialize_handler = php
session.use_cookies = 1
session.use_trans_sid = 0
short_open_tag = On
track_errors = On
upload_max_filesize = 1024M
upload_tmp_dir = "{TMP_DIR}"
variables_order = "GPCS"
LimitRequestBody 262144000
ConnectionTimeout = 300
IldeTimeout = 300
IOTimeout = 300
MaxProcesses = 5
MaxProcessLifeTime = 300
MaxRequestsPerProcess = 100
MinProcesses = 2
[Zend]
zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.4.so
zend_extension=/usr/local/Zend/lib/php54/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=1
[Date]
; Defines the default timezone used by the date functions
date.timezone= "Europe/Berlin"
date.default_latitude = 51.248532
date.default_longitude = 6.704677

Es werden sicherlich nicht alle Einstellungen funktionieren, aber die f?r Zend sollte er schon erkennen, hat er aber rnicht:

;PHP-FPM configuration for "deltanet-production.de" created on 2015.03.18 22:51:53
[deltanet-production.de]
listen = /var/lib/nginx/fastcgi/Chaos234-deltanet-production.de-php-fpm.socket
listen.owner = Chaos234
listen.group = Chaos234
listen.mode = 0660
user = Chaos234
group = Chaos234
pm = dynamic
pm.max_children = 100
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 10
pm.max_requests = 0
request_terminate_timeout = 60s
request_slowlog_timeout = 5s
slowlog = /var/customers/logs/Chaos234-php-slow.log
catch_workers_output = yes
;chroot = /var/customers/webs/Chaos234/
env[TMP] = /var/customers/tmp/Chaos234/
env[TMPDIR] = /var/customers/tmp/Chaos234/
env[TEMP] = /var/customers/tmp/Chaos234/
php_admin_value[session.save_path] = /var/customers/tmp/Chaos234/
php_admin_value[upload_tmp_dir] = /var/customers/tmp/Chaos234/


php_admin_flag[allow_url_fopen] = On
php_flag[asp_tags] = Off
php_admin_value[disable_classes] = 
php_admin_value[disable_functions] = 
php_flag[display_errors] = On
php_flag[display_startup_errors] = Off
php_admin_flag[enable_dl] = Off
php_value[error_reporting] = E_ALL & ~E_NOTICE
php_admin_flag[expose_php] = Off
php_admin_flag[file_uploads] = On
php_admin_flag[cgi.force_redirect] = 1
php_admin_value[gpc_order] = "GPC"
php_flag[html_errors] = On
php_admin_flag[ignore_repeated_errors] = Off
php_admin_flag[ignore_repeated_source] = Off
php_value[include_path] = ".:/usr/share/php/:/usr/share/php5/:/usr/share/php/smarty3"
php_flag[log_errors] = On
php_admin_flag[log_errors] = On
php_value[log_errors_max_len] = 1024
php_value[max_execution_time] = 6000000
php_admin_value[max_input_time] = 6000000
php_admin_value[memory_limit] = 128M
php_admin_value[output_buffering] = 4096
php_admin_value[post_max_size] = 1024M
php_admin_value[precision] = 14
php_admin_flag[register_argc_argv] = Off
php_admin_flag[report_memleaks] = On
php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i -f gifsucher@hotmail.de"
php_value[session.auto_start] = 0
php_value[session.cookie_domain] = 
php_value[session.cookie_lifetime] = 0
php_value[session.cookie_path] = /
php_admin_value[session.gc_divisor] = 1000
php_admin_value[session.gc_probability] = 1
php_value[session.name] = PHPSESSID
php_value[session.serialize_handler] = php
php_flag[session.use_cookies] = 1
php_flag[short_open_tag] = On
php_flag[track_errors] = Off
php_value[upload_max_filesize] = 1024M
php_admin_value[variables_order] = "GPCS"
php_value[date.timezone] = "Europe/Berlin"
php_admin_value[date.timezone] = "Europe/Berlin"

Denn u. a. ben?tige ich ZendGuar f?r GSales und ionCube f?r Shopware - der Rest ist erst einmal schnuppe ^^.

 

Vielleicht dies einfach mal mit in das von dir gepostete File ?bernehmen, da sonst die Zend-Flags nie funktionieren w?rden.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...