Problems with Nginx & Clean URLS (Drupal 8)

Discussion in 'Installation/Configuration' started by Tobbe, Jan 17, 2015.

  1. Tobbe

    Tobbe New Member

    Hi,

    I followed this tutorial on how to set up a webserver on a local machine I have at home.
    https://www.howtoforge.com/perfect-server-ubuntu-14.10-with-nginx-bind-dovecot-and-ispconfig-3

    I have managed to install ISPConfig 3, setup a website and install Drupal 8. However the site doesn't
    work and from what I get when bughunting it's either a clean url rewrite issue with Nginx or something
    else in regards to my server installation.

    I am running the server on Ubuntu 14.10 (GNU/Linux 3.16.0-23-generic i686)
    with nginx version: nginx/1.6.2 (Ubuntu)

    Not sure if it's a server configueration thing or a client website config thing inside of ispconfig 3.

    Other:

    I'm not to worried about not having webmail and other extra services working. Right now I just need to get my website working and I can tackle everything else afterwards.

    Thanks for the help. I really appreciate it .
     
  2. Tobbe

    Tobbe New Member

    Website error log
    Code:
    
    2015/01/16 21:50:41 [crit] 4320#0: *7 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcgi:
    //unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/16 22:07:02 [crit] 4835#0: *1 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcgi:
    //unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/16 22:07:07 [crit] 4915#0: *1 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcgi:
    //unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/16 22:07:13 [crit] 4915#0: *1 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcgi:
    //unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/16 22:08:14 [crit] 4915#0: *1 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcgi:
    //unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/16 22:11:23 [crit] 4915#0: *17 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcgi
    ://unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/17 09:47:26 [crit] 2788#0: *8 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcgi:
    //unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/17 12:16:48 [crit] 2790#0: *106 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcg
    i://unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/17 12:16:50 [crit] 2790#0: *108 connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.1, server: toreceasar.com, request: "GET / HTTP/1.1", upstream: "fastcg
    i://unix:/var/run/php-fpm.sock:", host: "toreceasar.com"
    2015/01/17 12:27:45 [error] 6901#0: *6 open() "/var/www/toreceasar.com/web/contextual/render" failed (2: No such file or directory), client: 192.168.1.1, server: toreceasar.com, request: "POST /contextual/render HTTP/1.1", host: "torecea
    sar.com", referrer: "http://toreceasar.com/"
    2015/01/17 12:27:53 [error] 6901#0: *6 open() "/var/www/toreceasar.com/web/user/logout" failed (2: No such file or directory), client: 192.168.1.1, server: toreceasar.com, request: "GET /user/logout HTTP/1.1", host: "toreceasar.com", ref
    errer: "http://toreceasar.com/"
    2015/01/17 12:33:16 [error] 6901#0: *14 open() "/var/www/toreceasar.com/web/contextual/render" failed (2: No such file or directory), client: 192.168.1.1, server: toreceasar.com, request: "POST /contextual/render HTTP/1.1", host: "torece
    asar.com", referrer: "http://toreceasar.com/?q=admin/settings/clean-urls"
    2015/01/17 12:33:46 [error] 6901#0: *14 open() "/var/www/toreceasar.com/web/user" failed (2: No such file or directory), client: 192.168.1.1, server: toreceasar.com, request: "GET /user HTTP/1.1", host: "toreceasar.com", referrer: "http:
    //toreceasar.com/?q=admin/settings/clean-urls"
    2015/01/17 12:33:49 [error] 6901#0: *14 open() "/var/www/toreceasar.com/web/admin/content" failed (2: No such file or directory), client: 192.168.1.1, server: toreceasar.com, request: "GET /admin/content HTTP/1.1", host: "toreceasar.com"
    , referrer: "http://toreceasar.com/?q=admin/settings/clean-urls"
    2015/01/17 12:34:02 [error] 6901#0: *14 open() "/var/www/toreceasar.com/web/admin/config" failed (2: No such file or directory), client: 192.168.1.1, server: toreceasar.com, request: "GET /admin/config HTTP/1.1", host: "toreceasar.com",
    referrer: "http://toreceasar.com/?q=admin/settings/clean-urls"
     
  3. Tobbe

    Tobbe New Member

    Additional server installation info

    Code:
    ##### SERVER #####
    IP-address (as per hostname): ***.***.***.***
    IP-address(es) (as per ifconfig): ***.***.***.***
    [WARN] ip addresses from hostname differ from ifconfig output. Please check your ip settings.
    [INFO] ISPConfig is installed.
    
    ##### ISPCONFIG #####
    ISPConfig version is 3.0.5.4p5
    
    
    ##### VERSION CHECK #####
    
    [INFO] php (cli) version is 5.5.12-2ubuntu4.1
    
    ##### PORT CHECK #####
    
    [WARN] Port 443 (Webserver SSL) seems NOT to be listening
    [WARN] Port 465 (SMTP server SSL) seems NOT to be listening
    
    ##### MAIL SERVER CHECK #####
    
    [WARN] I found no "submission" entry in your postfix master.cf
    [INFO] this is not critical, but if you want to offer port 587 for smtp connections you have to enable this.
    [WARN] I found no "smtps" entry in your postfix master.cf
    [INFO] this is not critical, but if you want to offer SSL for smtp (not TLS) connections you have to enable this.
    
    ##### RUNNING SERVER PROCESSES #####
    
    [INFO] I found the following web server(s):
            Nginx (PID 6900)
    [INFO] I found the following mail server(s):
            Postfix (PID 3112)
    [INFO] I found the following pop3 server(s):
            Dovecot (PID 1129)
    [INFO] I found the following imap server(s):
            Dovecot (PID 1129)
    [INFO] I found the following ftp server(s):
            PureFTP (PID 2823)
    
    ##### LISTENING PORTS #####
    (only           ()
    Local           (Address)
    [anywhere]:993          (1129/dovecot)
    [anywhere]:995          (1129/dovecot)
    [localhost]:10025               (3112/master)
    [anywhere]:3306         (2682/mysqld)
    [anywhere]:110          (1129/dovecot)
    [anywhere]:143          (1129/dovecot)
    [anywhere]:80           (6900/nginx)
    [anywhere]:8080         (6900/nginx)
    [anywhere]:8081         (6900/nginx)
    [anywhere]:21           (2823/pure-ftpd)
    ***.***.***.***:53              (1346/named)
    [localhost]:53          (1346/named)
    [anywhere]:22           (1146/sshd)
    [anywhere]:25           (3112/master)
    [localhost]:953         (1346/named)
    *:*:*:*::*:993          (1129/dovecot)
    *:*:*:*::*:995          (1129/dovecot)
    [localhost]10           (1129/dovecot)
    [localhost]43           (1129/dovecot)
    *:*:*:*::*:80           (6900/nginx)
    *:*:*:*::*:21           (2823/pure-ftpd)
    *:*:*:*::*:53           (1346/named)
    *:*:*:*::*:22           (1146/sshd)
    *:*:*:*::*:25           (3112/master)
    *:*:*:*::*:953          (1346/named)
    
    
    
    
    ##### IPTABLES #####
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination
    fail2ban-postfix-sasl  tcp  --  [anywhere]/0            [anywhere]/0            multiport dports 25
    fail2ban-dovecot-pop3imap  tcp  --  [anywhere]/0            [anywhere]/0            multiport dports 110,995,143,993
    fail2ban-pureftpd  tcp  --  [anywhere]/0            [anywhere]/0            multiport dports 21
    fail2ban-ssh  tcp  --  [anywhere]/0            [anywhere]/0            multiport dports 22
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination
    
    Chain fail2ban-dovecot-pop3imap (1 references)
    target     prot opt source               destination
    RETURN     all  --  [anywhere]/0            [anywhere]/0
    
    Chain fail2ban-postfix-sasl (1 references)
    target     prot opt source               destination
    RETURN     all  --  [anywhere]/0            [anywhere]/0
    
    Chain fail2ban-pureftpd (1 references)
    target     prot opt source               destination
    RETURN     all  --  [anywhere]/0            [anywhere]/0
    
    Chain fail2ban-ssh (1 references)
    target     prot opt source               destination
    RETURN     all  --  [anywhere]/0            [anywhere]/0
     
  4. vhacker11

    vhacker11 Member

    Hi,
    Can you verify if php-fpm is running and on which port ? Also, post the conf for toreceasar.com (assuming that is the domain for which you're getting this error) and nginx.conf.

    Regards,
    Vikram
     
  5. Tobbe

    Tobbe New Member

    Hmm so now I can't even access ispconfig3 or view the site.

    I confirmed that php5-fpm is running as a service on boot.
    sudo netstat -tlpn | grep :9000 // Doesn't return a value at all. Cannot find a reference to the port it listens to.

    /etc/php5/fpm/pool.d
    Code:
    " ============================================================================
    " Netrw Directory Listing                                        (netrw v151)
    "   /etc/php5/fpm/pool.d
    "   Sorted by      name
    "   Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
    "   Quick Help: <F1>:help  -:go up dir  D:delete  R:rename  s:sort-by  x:special
    " ==============================================================================
    ../
    ./
    apps.conf
    ispconfig.conf
    web2.conf
    www.conf
    ~
    ~
    ~
    

    /etc/php5/fpm/pool.d/apps.conf
    Code:
    [apps]
    
    listen = /var/lib/php5-fpm/apps.sock
    listen.owner = ispapps
    listen.group = ispapps
    listen.mode = 0660
    
    user = ispapps
    group = ispapps
    
    pm = dynamic
    pm.max_children = 500
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 5
    
    chdir = /
    
    ; php_admin_value[open_basedir] = /var/www/apps:/srv/www/apps:/usr/share
    php_admin_flag[magic_quotes_gpc] = off
    ~
     
  6. Tobbe

    Tobbe New Member

    /etc/php5/fpm/pool.d/ispconfig.conf
    Code:
    [ispconfig]
    
    listen = /var/lib/php5-fpm/ispconfig.sock
    listen.owner = ispconfig
    listen.group = ispconfig
    listen.mode = 0660
    
    user = ispconfig
    group = ispconfig
    
    pm = dynamic
    pm.max_children = 500
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 5
    
    chdir = /
    
    ; php_admin_value[open_basedir] = /usr/local/ispconfig/interface:/usr/share
    php_admin_value[session.save_path] = /usr/local/ispconfig/interface/temp
    php_admin_flag[magic_quotes_gpc] = off
    ~
    /etc/php5/fpm/pool.d/web2.conf
    Code:
    [web2]
    
    listen = /var/lib/php5-fpm/web2.sock
    listen.owner = web2
    listen.group = client1
    listen.mode = 0660
    
    user = web2
    group = client1
    
    pm = dynamic
    pm.max_children = 10
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 5
    pm.max_requests = 0
    
    chdir = /
    
    php_admin_value[open_basedir] = /var/www/clients/client1/web2/web:/var/www/clients/client1/web2/private:/var/www/clients/client1/web2/tmp:/var/www/toreceasar.com/web:/srv/www/toreceasar.com/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin
    php_admin_value[session.save_path] = /var/www/clients/client1/web2/tmp
    php_admin_value[upload_tmp_dir] = /var/www/clients/client1/web2/tmp
    php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i [email protected]"
    
    
    ~
    /etc/php5/fpm/pool.d/www.conf
    The rest of the code was commented out.
    Code:
    [www]
    user = www-data
    group = www-data
    listen = /var/run/php5-fpm.sock
    listen.owner = www-data
    listen.group = www-data
    pm = dynamic
    pm.max_children = 5
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 3
    chdir = /
     
  7. Tobbe

    Tobbe New Member

    /etc/nginx/nginx.conf
    Code:
    user www-data;
    worker_processes 4;
    pid /run/nginx.pid;
    
    events {
            worker_connections 768;
            # multi_accept on;
    }
    
    http {
    
            ##
            # Basic Settings
            ##
    
            sendfile on;
            tcp_nopush on;
            tcp_nodelay on;
            keepalive_timeout 65;
            types_hash_max_size 2048;
            # server_tokens off;
    
            # server_names_hash_bucket_size 64;
            # server_name_in_redirect off;
    
            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";
    
            # gzip_vary on;
            # gzip_proxied any;
            # gzip_comp_level 6;
            # gzip_buffers 16 8k;
            # gzip_http_version 1.1;
            # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    
            ##
            # nginx-naxsi config
            ##
            # Uncomment it if you installed nginx-naxsi
            ##
    
            #include /etc/nginx/naxsi_core.rules;
    
            ##
            # nginx-passenger config
            ##
            # Uncomment it if you installed nginx-passenger
            ##
    
            #passenger_root /usr;
            #passenger_ruby /usr/bin/ruby;
    
            ##
            # Virtual Host Configs
            ##
    
            include /etc/nginx/conf.d/*.conf;
            include /etc/nginx/sites-enabled/*;
    }
    
    #mail {
    #       # See sample authentication script at:
    #       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
    #
    #       # auth_http localhost/auth.php;
    #       # pop3_capabilities "TOP" "USER";
    #       # imap_capabilities "IMAP4rev1" "UIDPLUS";
    #
    #       server {
    #               listen     localhost:110;
    #               protocol   pop3;
    #               proxy      on;
    #       }
    #
    #       server {
    #               listen     localhost:143;
    #               protocol   imap;
    #               proxy      on;
    #       }
    #}
     
  8. Tobbe

    Tobbe New Member

    Now I am unsure of exactly what conf file for toreceasar.com to get so i'm guessing it's the nginx sites-available / sites-enabled that you are asking for? If not then please specify which file and i'll get it. I really appreciate the help here.

    /etc/nginx/sites-enabled/100-toreceasar.com.vhost
    Code:
    server {
            listen *:80;
    
    
            server_name toreceasar.com www.toreceasar.com;
    
            root   /var/www/toreceasar.com/web;
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    
            error_log /var/log/ispconfig/httpd/toreceasar.com/error.log;
            access_log /var/log/ispconfig/httpd/toreceasar.com/access.log combined;
    
            location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
            }
    
            location = /favicon.ico {
                log_not_found off;
                access_log off;
            }
    
            location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
            }
    
            location /stats/ {
    
                index index.html index.php;
                auth_basic "Members Only";
                auth_basic_user_file /var/www/clients/client1/web2/web/stats/.htpasswd_stats;
            }
    
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                try_files /beba8d51a912d3aa334bfa760cadd7f8.htm @php;
            }
    
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php5-fpm/web2.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
    
    
    
    
    
    
    
    }
    ~
     
  9. Tobbe

    Tobbe New Member

    Now at the end of this it seems that my website did load so I can access ispconfig and the site (although the drupal site is throwing a 404 not found error message. Yesterday it complained about a bad gateway.
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Try to add this in the nginx directives field of the website in ispconfiig for the drupal site:

    Code:
     location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
                    deny all;
           }
           location / {
                    try_files $uri $uri/ /index.php?$args;
           }
           location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                    expires max;
                    log_not_found off;
           }
     
  11. Tobbe

    Tobbe New Member

    Thank you so much Till, this seems to do the trick and drupal is now working.
    I wonder if you could explain the logic behind these nginx tweaks and how it works with ispconfig3?
    I'd like to understand it so I know for future sites plus a better understanding of nginx and ispconfig ;)
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    The above is not ispconfig specific, this is the translation of the apache .htaccess file that comes with drupal into the nginx rewrite rule syntax as nginx cant read the apache style .htaccess rules. Explaining how nginx rules work in detail is maybe a bit too much, if you like to dig into this you should take a look at the nginx documentation page or get a book about nginx, e.g. the one from oreilly.

    The nginx directives field in ispconfig just inserts the config into the nginx configuration file.
     

Share This Page