Ubuntu 11.10 & nginx configuration

Discussion in 'HOWTO-Related Questions' started by nikal, Feb 12, 2012.

  1. nikal

    nikal New Member

    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 :)
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Please restart PHP-FPM:

    Code:
    /etc/init.d/php5-fpm restart
     
  3. nikal

    nikal New Member

    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
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Can you post your vhost configuration and the output of
    Code:
    netstat -tapn
    ?
     
  5. nikal

    nikal New Member

    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? :eek:

    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 -
     
    Last edited: Feb 14, 2012
  6. nikal

    nikal New Member

    Hi again ,

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

    i changed the fastcgi_pass

    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
     
  7. falko

    falko Super Moderator Howtoforge Staff

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

    nikal New Member

    Thanks again ,

    I am not sure how to do that :(

    can you please guide me !
     
  9. nikal

    nikal New Member

    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 !
     
    Last edited: Feb 15, 2012
  10. nikal

    nikal New Member

    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!
     
  11. vaya

    vaya New Member

    Thanks!

    after 3 days, I got it working too!

    to resume, all you have to do
    WHEN :
    you get a HTTP Error 502 Bad gateway
    with nginx and Owncloud (and in my case ISPConfig)

    IS :

     
  12. falko

    falko Super Moderator Howtoforge Staff

    Your changes will be overwritten the next time you modify the vhost in ISPConfig. If it's not working with the configuration written by ISPConfig, there's probably something wrong with your setup, and you should check your logs.
     
  13. vaya

    vaya New Member

    you're right, the victory was short lived ..

    I decided to Use Socket For PHP-FPM

    by checking this box in ISPConfig:

    so now my vhost file looks like this :

    works fine so far


    Ubuntu 12.04
    ISPConfig 3
    Owncloud 3.0.3
     
    Last edited: May 25, 2012
  14. So if I understand you correctly, you created a separate vhost just for running ownCloud alongside with ISPConfig 3?

    Also, I guess that you're using completely different nginx configuration rules than the ones found on the ownCloud wiki.

    This sounds interesting, though :)
     

Share This Page