2

Disclaimer: Just to clarify, I'm completely new to Linux, but I've configured everything via google searches and personal research.

I've got a Debian Wheezy server with LEMP stack that I intend to use as the host of a domain.

I got the DNS working so that when I enter the domain I get the "welcome to nginx" page. The trouble arises because I have already created the directory that will host the site and populated it with the files of the site (index.php is the main page), and I have also configured the server block (/etc/nginx/sites-available/example.com) like so:

UPDATED Server block
server {
        listen   80;
        server_name example.com www.example.com;
        root /var/www/example.com;
        index index.php index.html index.htm;
        location / {
                try_files $uri $uri/ /index.html;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /var/www/example.com;
        }

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
}

with a symbolic link to the sites-enabled directory. But even after restarting the service and/or restarting the machine the domain still displays the "welcome to nginx" message. I've tried out editing other lines with the answers of similar problems in the site and so far there's been no change, and the error logs show nothing. What could be causing the fault in the configuration?

Thanks in advance for the answers

UPDATE: Here's the nginx.conf file. In between experimenting while commenting and uncommenting some lines in the sites-available and trying to copy the file to the "sites-enabled" directory the domain now just plain refuses to load giving a "No data received" error

UPDATED nginx.conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

     server_names_hash_bucket_size 64;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";
    text/javascript;


    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

UPDATE 2: After rechecking my configurations I noted that the permissions were set incorrectly, and that the default was somehow overriding the site even when it was not on the sites-enabled directory. I backed up and deleted the default and just for good measure changed the working directory in the server block, moving the files of the site to the one I captured. It worked and now the site loads. Now I don't know if I should just add this to the update or put it in another question, but here goes: The problem now is that the site loads the html and CSS, but for some reason not the PHP, any ideas with that?. I'll update according to what I find or if you guys require more info, Thanks!

FINAL UPDATE: It took a bit, but I managed to know where the php error lied, I started digging through the logs and found out I needed to install php5-curl, the problem got fixed after that and now the site completely works.

0

Are you using php CGI or FPM? You only need one fastcgi_pass directive, but both are uncommented.

Try making the index file index.html, and put such a file in the server root. Reload nginx and see if it serves it. Adding PHP complicates things, so make sure nginx itself works first. service nginx configtest is very helpful too.

Update: It sounds like you are using PHP-FPM on port 9000. I would leave the unix socket line commented out, and make sure that the server can talk to its own port 9000 (TCP). As far as nginx is concerned, it sounds like it is working, but PHP may not be. By default, it will have it's own log file for the FPM daemon and one for the PHP script (probably in /var/log/ somewhere). Dive into /etc/php5/fpm and start looking through the .ini files.

  • I got the code for the site from a friend, so I don't really know what he's using, but if I comment fastcgi_pass 127.0.0.1:9000; leaving the other line uncommented and try to connect to the page it gives me a "No data received" error. This doesn't happen if I comment the line fastcgi_pass unix:/var/run/php5-fpm.sock; though. – Aldax Oct 30 '14 at 23:38
  • Updated answer to say that it sounds like a PHP problem now. – IslandUsurper Oct 31 '14 at 20:23
  • After triple checking my files found the error and the page now loads, the problem is that it now loads without php. The html frames work as intended, but I can't seem to get the php sections of the page to work. I'll update the question with the updated nginx.conf and server block – Aldax Nov 3 '14 at 21:06
  • Just managed to solve it, I was missing php5-curl, now the complete site loads – Aldax Nov 3 '14 at 23:17
0

Given the part :

with a symbolic link to the sites-enabled directory

I think that's where you are wrong.

In sites-enabled you should have symbolic links towards sites-available configurations and not the opposite because that's where nginx will lookup by default (see nginx.conf).

Sharing your nginx.conf could be helpful there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.