Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [DE] [gelöst] Problem mit nginx  (Read 2832 times)

Offline harley-peter

  • User
  • Posts: 1.023
[DE] [gelöst] Problem mit nginx
« on: 2015/10/29, 11:51:32 »
Hallo,
ich habe mir mal nginx lokal als Webserver installiert und versuche nun das Ding korrekt zum laufen zu bringen. Als Neuling mit dem tool habe ich mir natürlich viele Seiten der Doku durchgelesen aber ich habe im Moment ein Problem bei dem ich nicht weiterkomme und erbitte hier Expertenhilfe.
Der Server läuft und ich habe die Document Root auf meine Seite umgebogen. Da ich mit php-Dateien arbeite habe ich auch dieses in der conf-Datei auskommentiert. Leider bekomme ich beim Aufruf nur ein "file not found". Habe nach einiger Websuche auch schon einiges ausprobiert aber ohne Erfolg.
Meine nginx conf-Datei:

Code: [Select]
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /home/peter/www;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;

server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}

#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;

# With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}

nginx error.log sagt mir

Code: [Select]
2015/10/29 11:38:04 [error] 6299#6299: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost"

php5-fpm.log

Code: [Select]
[29-Oct-2015 10:17:32] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful

[29-Oct-2015 10:17:32] NOTICE: fpm is running, pid 22442
[29-Oct-2015 10:17:32] NOTICE: ready to handle connections
[29-Oct-2015 10:17:32] NOTICE: systemd monitor interval set to 10000ms

Hat jemand einen Tip?
« Last Edit: 2015/10/30, 15:36:09 by harley-peter »

Offline Geier0815

  • User
  • Posts: 588
Re: Problem mit nginx
« Reply #1 on: 2015/10/29, 14:04:55 »
Zeige bitte mal deine /etc/php5/fpm/php-fpm.conf
Dann überprüfe mal ob der socket unter /var/run auch erstellt wurde und die richtigen Berechtigungen hat. Ich persönlich bevorzuge das Ganze über localhost und einen gegebenen Port zu machen, da ich da dann sehen kann ob der Port wirklich da ist (netstat -tulpen)
Bei meinen Installationen verwende ich "include fastcgi.conf;" statt deinem "include snippets/fastcgi-php.conf" Da müßtest Du mal gucken wo die Unterschiede liegen.
Leider ist die php5-fpm.log extrem besch*** wenn es darum geht Fehler zu finden, selbst wenn man das loglevel hoch schraubt.
Wenn Windows die Lösung ist...
kann ich dann bitte das Problem zurück haben?

Offline harley-peter

  • User
  • Posts: 1.023
Re: Problem mit nginx
« Reply #2 on: 2015/10/29, 15:37:03 »
/etc/php5/fpm/php-fpm.conf:

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr otherwise
;include=/etc/php5/fpm/*.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = /run/php5-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = /var/log/php5-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been design to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
;       - The pool process will inherit the master process priority
;         unless it specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes
 
; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024
 
; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select     (any POSIX os)
; - poll       (any POSIX os)
; - epoll      (linux >= 2.5.44)
; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll  (Solaris >= 7)
; - port       (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is build with systemd integration, specify the interval,
; in second, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options.  The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5/fpm/pool.d/*.conf

Der socket ist da, hat Nutzer und Gruppe www-data mit der Berechtigung lesen und schreiben für beide.

Quote
verwende ich "include fastcgi.conf;" statt deinem "include snippets/fastcgi-php.conf
habe ich ausprobiert, keine Änderung.

Ich rufe die Seite auch über localhost auf aber der Ausdruck von netstat -tulpen sagt mir als Laie nicht wirklich ob da ein Fehler vorliegt.

Code: [Select]
netstat -tulpen | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      0          181348     6298/nginx: master 
tcp6       0      0 :::80                   :::*                    LISTEN      0          181349     6298/nginx: master

Offline melmarker

  • User
  • Posts: 2.799
    • g-com.eu
Re: Problem mit nginx
« Reply #3 on: 2015/10/29, 18:41:44 »
wie wäre es denn, sich zu Beginn der ganzen Aktion eine saubere konfigurationsdatei anzulegen?
Is nur so ne Idee, muss nicht sein.
Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. (Benjamin Franklin, November 11, 1755)
Never attribute to malice that which can be adequately explained by stupidity. (Hanlons razor)

Offline Geier0815

  • User
  • Posts: 588
Re: Problem mit nginx
« Reply #4 on: 2015/10/30, 09:39:47 »
Vielleicht hab ich ja was mit den Augen aber in deiner php-fpm.conf wird nur die pid und der Ort des error-logs definiert. Da aber /etc/php5/fpm/pool.d includiert wird, muß da eine Datei drin sein die die wichtigen Einstellungen beinhaltet. Diese Datei wäre interessant.
Und melmarkers Hinweis könnte auch hilfreich sein zumindest würde es uns die Sache deutlich erleichtern. Also die beiliegenden Beispiel-Konfigurationen kopieren, Einstellungen vornehmen und die ganzen Kommentare und ähnliches raus schmeißen. Die kannst Du ja immer noch in der Beispiel-Konfig nachgucken.

Achso, das mit netstat bezieht sich auf die Option das per Port und localhost zu machen
« Last Edit: 2015/10/30, 09:59:41 by Geier0815 »
Wenn Windows die Lösung ist...
kann ich dann bitte das Problem zurück haben?

Offline horo

  • User
  • Posts: 199
OT: warum nginx?
« Reply #5 on: 2015/10/30, 11:08:16 »
Peter,

interessehalber - was spricht gegen lighttpd, hast Du 'ne konkrete Anwendung für nginx?

Ciao, Martin
omnia vincit pecunia :(

Offline harley-peter

  • User
  • Posts: 1.023
Re: Problem mit nginx
« Reply #6 on: 2015/10/30, 15:35:44 »
Hallo Freunde,

nach nochmaligem Studium der einzelnen config-Datein hat sich das Problem gelöst. Wie so oft lag der Fehler wieder mal zwischen den Kopfhörern: es war einfach nur ein Rechteproblem.
Trotzdem vielen Dank für eure Hilfe.

@horo:
Nichts! Da ich beide nicht kannte habe ich mich einfach so für nginx entschieden.

Gruß
Peter

Offline melmarker

  • User
  • Posts: 2.799
    • g-com.eu
Re: [gelöst] Problem mit nginx
« Reply #7 on: 2015/10/30, 18:25:45 »
@Geier0815: Die haben bei debian ein paar nette code-schnipsel beigelegt, die die Integration von bestimmten Sachen wie php und so was erheblich erleichtern und ne Menge Tipperei ersparen.

@harley-peter: Wenn Du dauerhaft Freude an nginx haben willst, dann würde ich mich mal ein oder zwei Tage intensiv mit der Konfiguration beschäftigen und wie man die richtig, nachhaltig und vor allem verständlich schreibt. Der große Vorteil an nginx ist meines Erachtens, dass dieses Vorhaben wirklich möglich ist. Sollte man nutzen.
Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. (Benjamin Franklin, November 11, 1755)
Never attribute to malice that which can be adequately explained by stupidity. (Hanlons razor)