HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   HOWTO-Related Questions (http://www.howtoforge.com/forums/forumdisplay.php?f=2)
-   -   Ubuntu 11.10 & nginx configuration (http://www.howtoforge.com/forums/showthread.php?t=56152)

nikal 12th February 2012 18:24

Ubuntu 11.10 & nginx configuration
 
Hello , noob here!

I am setting up my first server folowing this 2 howto's first and second

i do own a domain name (who serves my wordpress in an ISP)and i want my brand new nginx server (an old pc somewhere in my home) as a owncloud service .

I went to my domains cp and add a new DNS record , let's say server.mydomain.com with the right static ip of my router .
then i open the right ports to the router 80&22 (ssh)
and finished my owncloud setup like here

But im getting a 502 bad gateway error
My problem I quess is in my vhost configuration (noob here :) )
because i use a subdomain !
I try some configurations but i have to admit i don't understund them!
for examble i use

server {
listen server.mydomain.com;
server_name server.mydomain.com;
root /var/www/server.mydomain.com/web;

if ($http_host != "server.mydomain.com") {
rewrite ^ http://server.mydomain.com$request_uri permanent;
}

configuration and i get "Welcome to nginx!" and the info.php works under server.mydomain.com/info.php but the owncloud instalation not!
when i change the listen to 80 i get 502 bad gateway

can someone point me (or better show me) the right configuration?

Thanks :)

falko 13th February 2012 13:25

Please restart PHP-FPM:

Code:

/etc/init.d/php5-fpm restart

nikal 13th February 2012 13:36

Quote:

Originally Posted by falko (Post 273477)
Please restart PHP-FPM:

Code:

/etc/init.d/php5-fpm restart

Thank you Falco for your answer but i all ready did that every time i change my vhost configuration .Also reload nginx , clear browser cache but the resault is the same .

I try all the possible configuration i find on nginx foroum and wiki but nothing seems to work for me .

I am pretty sure i miss something in that vhost but as I say i am new in all that stuff so the 3 day heading is normal for a newbee like me :D

falko 14th February 2012 14:57

Can you post your vhost configuration and the output of
Code:

netstat -tapn
?

nikal 14th February 2012 19:31

Hello again Falco and thank you for your reply!

The netstat -ntap
Code:

tcp                0        0        127.0.0.1:3306        0.0.0.0:*        LISTEN                667/mysqld
tcp                0        0        0.0.0.0:80        0.0.0.0:*        LISTEN                717/nginx
tcp                0        0        0.0.0.0:22        0.0.0.0:*        LISTEN                447/sshd
tcp                0        0        0.0.0.0:25        0.0.0.0:*        LISTEN                847/master
tcp6                0        0        :::22                :::*                LISTEN                447/sshd

and the vhost config
Code:

server {
      listen 80;
      server_name server.mydomain.com;
      root /var/www/server.mydomain.com/web;

      if ($http_host != "server.mydomain.com") {
                rewrite ^ http://server.mydomain.com$request_uri permanent;
      }

      # This is to avoid a "Request Entity Too Large" error
      client_max_body_size 1000M;
      index index.php index.html index.htm;

      dav_methods PUT DELETE MKCOL COPY MOVE;
      create_full_put_path on;
      dav_access user:rw group:rw all:r;

      location = /favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
      }

      location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
      }

      # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
      location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
      }

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

      location @webdav {
                fastcgi_split_path_info ^(.+.php)(/.+)$;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
                #fastcgi_param HTTPS on;
                fastcgi_pass 127.0.0.1:9000;
      }

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

I maybe did something wrong today! I rm the default config under /etc/nginx/sites-available/ and /etc/nginx/sites-enabled/ . Is that bad? and if it is wrong can you paste here the default config so i can make a new file? :o

Also I notice that there is no php5-cgi pid in my netstat -ntap is that my problem? The php5-fpm don't start?

edit: Now I saw that you wanted netstat -tapn !! sorry!!

the only diference is the

tcp 0 0 127.0.0.1:80 127.0.0.1:51587 TIME_WAIT -

nikal 15th February 2012 11:07

Hi again ,

I tried some changes to my vhost based to that my php5-fpm not working

i changed the fastcgi_pass

Quote:

Originally Posted by nikal (Post 273585)
.....

Code:

.....

      location ~ \.php$ {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
        this--->      fastcgi_pass 127.0.0.1:9000;
          to ---->      fastcgi_pass unix:/tmp/php5-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_index index.php;
      }
}

.......

But still don't work maybe for that reason?
I maybe did something wrong today! I rm the default config under /etc/nginx/sites-available/ and /etc/nginx/sites-enabled/ . Is that bad? and if it is wrong can you paste here the default config so i can make a new file?

Yes yes I know I'am dummie :D

falko 15th February 2012 13:26

Quote:

Originally Posted by nikal (Post 273585)
Hello again Falco and thank you for your reply!

The netstat -ntap
Code:

tcp                0        0        127.0.0.1:3306        0.0.0.0:*        LISTEN                667/mysqld
tcp                0        0        0.0.0.0:80        0.0.0.0:*        LISTEN                717/nginx
tcp                0        0        0.0.0.0:22        0.0.0.0:*        LISTEN                447/sshd
tcp                0        0        0.0.0.0:25        0.0.0.0:*        LISTEN                847/master
tcp6                0        0        :::22                :::*                LISTEN                447/sshd


There's no PHP-FPM daemon listening on port 9000, so make sure it is running and uses TCP instead of Unix sockets.

nikal 15th February 2012 13:40

Thanks again ,

I am not sure how to do that :(

can you please guide me !

nikal 15th February 2012 18:58

Ok here I am again , I managed to make the php daemon to work so my netstat -tapn
shows

Code:

tcp      0        0    127.0.0.1:9000    0.0.0.0:*      LISTEN    4606/php-fpm.conf
(changed the listen to 127.0.0.1:9000 under /etc/php5/fpm/pool.d/www.conf)

changed the fastcgi_pass to 127.0.0.1:9000; in my vhost
restart php5-fpm
reload nginx

and nothing happends again :(

I supose the answer is in front off my eyes and I don't see it !

nikal 15th February 2012 20:43

Ok good news I just reboot the pc and voila !!

one more owncloud instalation (and nginx) on the net!!

Thank you so mutch for the greats howtos and for your help!


All times are GMT +2. The time now is 18:12.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.