0

im stucked here about 2 days traying to figure out how to make this run, hope somebody could point what I'm doing wrong.

Trying to run Symfony2 over Nginx-CentOS 6 with this configuration file.

upstream phpfcgi {
    server 127.0.0.1:9000;
    # server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket
}
server {
    listen 80;

    server_name symfony2;
    root /var/www/project/web;

    error_log /var/log/nginx/symfony2.error.log;
    access_log /var/log/nginx/symfony2.access.log;

    # strip app.php/ prefix if it is present
    rewrite ^/app\.php/?(.*)$ /$1 permanent;

    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }

    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app)\.php(/|$) {
        include /etc/nginx/fastcgi.conf;
        fastcgi_pass phpfcgi;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;
    }
}

Obtained from here, here and here. I have been playing arround making little changes here and there, mainly based on what those links tell.

My php-fpm.d/www.conf file is like this...

[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = nginx
group = nginx
pm = dynamic
pm.max_children = 50
pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 10
pm.max_requests = 500
request_terminate_timeout = 45
request_slowlog_timeout = 45
slowlog = /var/log/php-fpm/www-slow.log
catch_workers_output = yes
security.limit_extensions = .php .php5
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/nginx/tmp/session_php

From navigator i obtain the infamous "No input file specified." error. Logs are like...

[/var/log/nginx/symfony2.error.log]
2015/03/13 12:49:59 [error] 14298#0: *1 FastCGI sent in stderr: "Unable to open  
primary script: /var/www/project/web/app.php (No such file or directory)" while  
reading response header from upstream, client: 192.168.0.132, server: symfony2,  
request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host:  
"192.168.0.199"

[/var/log/nginx/symfony2.error.log]
[13-Mar-2015 12:49:59] WARNING: [pool www] child 14279 said into stderr:  
"ERROR: Unable to open primary script: /var/www/project/web/app.php (No such  
file or directory)"

The project is in /var/www/project and with this set of permissions. Altered by what i read here.

drwxr-sr-x. 5 nginx nginx   4096 mar 10 17:00 app
drwxr-sr-x. 2 nginx nginx   4096 mar 10 17:00 bin
-rwxr-sr-x. 1 nginx nginx   2717 mar 10 17:00 composer.json
-rwxr-sr-x. 1 nginx nginx 100442 mar 10 17:00 composer.lock
drwxr-sr-x. 2 nginx nginx   4096 mar 10 17:00 lib
-rwxr-sr-x. 1 nginx nginx   1065 mar 10 17:00 LICENSE
drwxr-sr-x. 3 nginx nginx   4096 mar 10 17:00 nbproject
-rwxr-sr-x. 1 nginx nginx   5750 mar 10 17:00 README.md
drwxr-sr-x. 3 nginx nginx   4096 mar 10 17:00 src
-rwxr-sr-x. 1 nginx nginx   1308 mar 10 17:00 UPGRADE-2.2.md
-rwxr-sr-x. 1 nginx nginx   1962 mar 10 17:00 UPGRADE-2.3.md
-rwxr-sr-x. 1 nginx nginx    356 mar 10 17:00 UPGRADE-2.4.md
-rwxr-sr-x. 1 nginx nginx   8499 mar 10 17:00 UPGRADE.md
drwxr-sr-x. 3 nginx nginx   4096 mar 10 17:00 web

I already google it a lot and test very different things but none of that seems to work :S. If anyone have any idea im eager to know. Thx in advance.

Edit 1 Checking app.php is there...

stat /var/www/project/web/app.php 
  File: `/var/www/project/web/app.php'
  Size: 960         Blocks: 8          IO Block: 4096   regular file
Device: 802h/2050d  Inode: 7997857     Links: 1
Access: (2755/-rwxr-sr-x)  Uid: (  496/   nginx)   Gid: (  493/   nginx)
Access: 2015-03-11 11:10:15.246469137 +0100
Modify: 2015-03-10 17:00:33.026535520 +0100
Change: 2015-03-13 11:55:52.755828687 +0100
darofar
  • 1
  • 4

1 Answers1

0

What actually happened is still unknown, but let me update what i did so maybe it can be usefull for someone in the future.

I was thinking it was some king of permissions issue, so i tried chmod 777 and chown nobody:nobody with different configurations files but the same error persist. Finally i tried a simple nginx configuration file with no "symfony tricks", the one i had tried to verify the correct installation of LEMP before cloning the project code.

server {
    server_name default;
    access_log /var/log/nginx/default_access.log;
    error_log /var/log/nginx/default_error.log;

    #if defined in each location directive can be defined diferent root locations.
    root /var/www;

    location / {
        index index.html index.php;
    }

    error_page 404              /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504  /50x.html;
    location = /50x.html {
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

The point with this was to see the typicall wellcome page from nginx and a <?php phpinfo(); ?>test page to make sure PHP-FastCGI was properly configured. I put the files from default nginx instalation on /var/www/and voila! I got access to index.htmland to info.php with successfull results. Ok then i proceed to make a test folder to put those files there and copy them to my symfony project folder too. The thing looked like this...

[root@machine www]# tree -L 2
.
├── 404.html
├── 50x.html
├── test 
    ├── index.html      <<<<<
    └── info.php        <<<<<
├── index.html          <<<<<
├── info.php            <<<<<
└── project
    ├── app
    ├── bin
    ├── composer.json
    ├── composer.lock
    ├── index.html     <<<<<
    ├── info.php       <<<<<
    ├── lib
    ├── LICENSE
    ├── nbproject
    ├── private
    ├── README.md
    ├── src
    ├── UPGRADE-2.2.md
    ├── UPGRADE-2.3.md
    ├── UPGRADE-2.4.md
    ├── UPGRADE.md
    ├── vendor
    └── web

The result was that i could access to...
/index.html
/info.php
/test/index.html
/test/info.php
Succesfully but it give me the SAME ERROR on
/project/index.html
/project/info.php

So, i proceed to delete the entire folder and start again, cheking properly configuration for nginx on project folder, then git clone my code. And there it is... fully functionall now.

Nginx configuration file im running now...

server {
    listen 80;
    server_name symfony-project;
    access_log /var/log/nginx/symfony2_access.log;
    error_log /var/log/nginx/symfony2_error.log;

    #if defined in each location directive can be defined diferent root locations.
    root /var/www/project/web;

    # strip app.php/ prefix if it is present
    rewrite ^/app_dev\.php/?(.*)$ /$1 permanent;

    location / {
        index app_dev.php;
        try_files $uri @rewriteapp;
    }

     location @rewriteapp {
        rewrite ^(.*)$ /app_dev.php/$1 last;
    }

    error_page 404              /404.html;
    location = /404.html {
    }

    error_page 500 502 503 504  /50x.html;
    location = /50x.html {
    }

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

        fastcgi_pass  127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;   
    }
}
darofar
  • 1
  • 4