Nginx php actief in subdirectory

Pagina: 1
Acties:

Acties:
  • 0 Henk 'm!

  • PyBo
  • Registratie: April 2013
  • Niet online
Beste tweakers,

Ik ben sinds gisteren ochtend al bezig met het actief krijgen van een Nginx servertje. Een kennis draaide zijn website al op Nginx, alleen door een totaal nieuwe website heeft hij php in een subdir nodig.

Nu heb ik op internet al gezocht, helaas kwam ik hier niets tegen wat nu echt werkt. Ik vroeg me af of tweeakters hier misschien de oplossing hebben of tegen hetzelfde aan lopen.

Ik heb nu een testserver (Ubuntu 12.04 LTS) met onderstaande config staan, nu heb ik al het een en ander uitgeprobeerd maar hij blijft de error page of default home page geven. Het is in deze test de bedoeling dat de map portal "gewoon" een php pagina laat zien.

Graag hoor ik jullie mening.


Nginx configuration file: code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
server {
        listen   80;

        root /usr/share/nginx/www;
        index index.php index.html index.htm;

        server_name 192.168.5.11;

        location / {
                try_files $uri $uri/ /index.html;
        }

        location /portal/ {
                autoindex on;
        }

        location ~ /portal/.*\.php$ {
                root /usr/share/nginx/www/portal;

                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

                try_files $uri = 404;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;

        location = /50x.html {
                root /usr/share/nginx/www;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

                try_files $uri = 404;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}

Acties:
  • 0 Henk 'm!

  • Xatom
  • Registratie: Augustus 2011
  • Laatst online: 05:24

Xatom

Met deze configuratie heb ik gewoon PHP op example.com en example.com/portal:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
server {
        listen 80;

        server_name example.com;

        index index.php;
        root /var/www/example.com;

        location ~ \.php$ {
            try_files $uri =404;
            include fastcgi_params;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
        }

        location /portal {
                autoindex on;
        }
}

Acties:
  • 0 Henk 'm!

  • PyBo
  • Registratie: April 2013
  • Niet online
Naxiz schreef op zaterdag 01 maart 2014 @ 13:37:
Met deze configuratie heb ik gewoon PHP op example.com en example.com/portal:
Wanneer ik de aangegeven configuratie plaats dan krijg ik "502 bad gateway using" helaas.
Wanneer ik de aangegeven logica toepas kom ik uit op "The page you are looking for is temporarily unavailable. Please try again later."

[ Voor 34% gewijzigd door PyBo op 01-03-2014 15:14 ]


Acties:
  • 0 Henk 'm!

  • Xatom
  • Registratie: Augustus 2011
  • Laatst online: 05:24

Xatom

Wat staat er in /var/log/nginx/error.log nadat je die foutmelding krijgt? En welke versie van nginx en PHP gebruik je?

Acties:
  • 0 Henk 'm!

  • PyBo
  • Registratie: April 2013
  • Niet online
Mijn hele log is leeg van Nginx (heel raar denk ik?). In mijn log is de volgende regel te vinden:

code:
1
2014/03/01 16:38:33 [crit] 1115#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.5.10, server: boertje.myds.me, request: "GET /portal/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "192.168.5.11"


Ik maak gebruik van: php5-fpm en Nginx 1.1.19.

[ Voor 66% gewijzigd door PyBo op 01-03-2014 16:51 ]


Acties:
  • 0 Henk 'm!

  • Xatom
  • Registratie: Augustus 2011
  • Laatst online: 05:24

Xatom

Heb je php5-fpm wel gestart en geeft /etc/init.d/php5-fpm status ook aan dat php5-fpm gestart is?

Anders moet je even controleren of php5-fpm wel de Unix Socket gebruikt. Open /etc/php5/fpm/pool.d/www.conf en kijk wat er achter listen staat. Hier moet listen = /var/run/php5-fpm.sock staan.

Acties:
  • 0 Henk 'm!

  • PyBo
  • Registratie: April 2013
  • Niet online
Hello world! het werkt. In mijn www.conf bestand stond /var/ru ipv /var/run.
Typfoutje :X Dankjewel Naxiz!!
Naxiz schreef op zaterdag 01 maart 2014 @ 17:06:
Heb je php5-fpm wel gestart en geeft /etc/init.d/php5-fpm status ook aan dat php5-fpm gestart is?

Anders moet je even controleren of php5-fpm wel de Unix Socket gebruikt. Open /etc/php5/fpm/pool.d/www.conf en kijk wat er achter listen staat. Hier moet listen = /var/run/php5-fpm.sock staan.
Pagina: 1