0

I'm trying to setup a server with Nginx and PHP FPM and I ran into some trouble.

I've set up an Nginx virtual host and a fpm pool for each website. The problem is that all domains are showing the same website, even though it's not the default one.

Below you have some example configuration (I have stripped parts I didn't change from the config):

This is the config for the domain that gets all other domains redirected to:

server {
        listen 80;
        listen [::]:80;
        root /var/www/site1;
        server_name sitename.com www.sitename.com;

        location ~ \.php$ {
               try_files $uri =404;
                fastcgi_keep_conn on;
                fastcgi_pass unix:/var/run/php5-fpm.site1.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                fastcgi_read_timeout 36000;
    }
    }

This is the site1.conf file in /etc/php5/fpm/pool.d:

[android]
user = site1
listen = /var/run/php5-fpm.site1.sock
listen.owner = www-data //I also tried with site1

I have created the user with useradd -M site1.

The /var/www/site1 folder has the right permissions and is owned by site1.

All the other virtual hosts in Nginx are identical to this one, except for the server_name, root and factcgi_pass. They all have a fpm pool, user, folder owned by the user.

I even have a default virtual host with listen 80 default and server_name as the server's IP, but even the server ip redirects to site1.

P.S. If I delete site1 from /etc/nginx/sites-enabled none of the websites work anymore.

What am I missing here?

  • 1
    Did you remember to activate the other sites and reload nginx afterwards? – Frederik Nielsen Dec 3 '15 at 19:05
  • 1
    Can you show at least one other virtual host from sites-enabled? – Nikita Kipriyanov Dec 3 '15 at 19:24
  • Please do not cross post. – Richard Smith Dec 4 '15 at 9:16
  • @FrederikNielsen I did activate them, but it seems I had a typo in my ln -s command :) – Alex Dumitru Dec 4 '15 at 22:11
  • @NikitaKipriyanov Yeah, the problem was in sites-enabled, as I must have used the ln -s command wrong and the other virtual host files were empty there. – Alex Dumitru Dec 4 '15 at 22:12
0

I have found the problem.

I did the symlink wrong from sites-available to sites-enabled and only site1 worked, while the other files were empty.

  • For me is was a mysql service needing a restart – Adeerlike Mar 7 '18 at 13:45

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.