Diagnosing Web Server Problems?

Hi,

I'm no command line or *nix expert, but not a complete noob either.

I setup a new Linode using Ubuntu 11.10, followed the guides for setting up a LEMP server and Wordpress. It seemed to work okay and I could log into WP admin, etc. so I know that the nginx, mysql and php must have been working at one point.

I rebooted the server to be sure everything still worked and now browsing to the site returns server not found page and it acts totally dead. The browser returns a server not found immediately with no delay at all.

I would appreciate any pointers of things to look at. So far I have done this:

  • I did a ps aux | egrep '(PID|nginx)' and can see my processes are alive so they started up as they should. Same for mysql.

  • I tried just browsing to the readme.html that wordpress installs as a test for nginx without php and mysql, didn't work.

  • I checked the DNS Manager and all seems okay.

  • I checked my iptables and not completely sure how to decipher it, but it matches the example referenced from the Linode wiki and port 80 is enabled

  • I checked my nginx conf files and they still reflect the same contents as the guide had (that had worked before)

Is there some sort of guide for diagnosing problems like this?

Thanks for any advice!

Brett

25 Replies

Post your nginx configuration, domain and ip address so we can look it over.

Hi,

Thanks for your post. Sorry I didn't post the conf files first, I thought if I could find a guide I wouldn't need to trouble people with my particular configuration. Thanks for taking a look.

173.230.149.5

http://realizedventures.com

From /etc/nginx/nginx.conf

user www-data;
worker_processes 4;
pid /var/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/x-javascript text/xml application/xml $

        ##
        # Virtual Host Configs
        ##

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

And from /etc/nginx/sites-enabled/realizedventures.com

server {
    listen   80;
    server_name www.realizedventures.com realizedventures.com;
    access_log /srv/www/realizedventures.com/logs/access.log;
    error_log /srv/www/realizedventures.com/logs/error.log;
    root   /srv/www/realizedventures.com/public_html;

    location / {
        index  index.html index.htm index.php;
    }

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

Thanks again for any help.

Cheers,

Brett

DNS looks fine, your network settings are fine (ssh is working), so either nginx isn't working right (config looks fine) or your firewall is blocking it.

Run `iptables -L -v -n[code] show?`[/code]

Thanks for your post!

Here's the output of iptables

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     all  --  lo     *       0.0.0.0/0            127.0.0.0/8         reject-with icmp-port-unreachable 
  951 74853 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
   17  1088 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:80 
    4   256 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:443 
    4   256 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
    1    84 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 8 
   29  1640 LOG        all  --  *      *       0.0.0.0/0            0.0.0.0/0           limit: avg 5/min burst 5 LOG flags 0 level 7 prefix `iptables denied: ' 
  684 43560 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable 

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  699 73492 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Thanks again :)

Not that then you're default policy is to accept traffic so iptables isn't doing much.

What happens when you run nginx -t && service nginx restart if that doesn't work try nginx -t && /etc/init.d/nginx restart or nginx -t && restart nginx (I can't remember how ubuntu 11.10 is set up to start nginx)

I wasn't sure about the iptables. My goal was to lock down everything except 80, 443, SFTP and SSH. I probably did something wrong though. I'll look into that once this is all fixed.

root@sadhana:/home# nginx -t && service nginx restart
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Continued thanks!

I ran ps aux | egrep '(PID|nginx)' and it looks like nginx isn't running? isn't the things listed below the fast-cgi processes?

root@sadhana:/home# ps aux | egrep '(PID|nginx)'
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
nginx     2277  0.0  1.0  61128  5516 ?        Ss   04:01   0:00 /usr/bin/php5-cgi
nginx     2344  0.0  0.3  61128  1988 ?        S    04:01   0:00 /usr/bin/php5-cgi
nginx     2345  0.0  0.3  61128  1988 ?        S    04:01   0:00 /usr/bin/php5-cgi
nginx     2346  0.0  0.3  61128  1988 ?        S    04:01   0:00 /usr/bin/php5-cgi
nginx     2347  0.0  0.3  61128  1988 ?        S    04:01   0:00 /usr/bin/php5-cgi
nginx     2348  0.0  0.3  61128  1988 ?        S    04:01   0:00 /usr/bin/php5-cgi
nginx     2349  0.0  0.3  61128  1988 ?        S    04:01   0:00 /usr/bin/php5-cgi
root      2611  0.0  0.1   4196   760 pts/0    S+   04:47   0:00 egrep --color=auto (PID|nginx)

Yep looks like it's not running, simply run nginx and see if it starts up

Woohoo!

So it looks like it's not starting up on boot. It has a file in init.d and update-rc as I followed the guides. But how can I check/verify these? Obviously something must be wrong there.

Thanks!

How did you install nginx? via apt-get? a ppa? or from source?

Via apt-get as per the guide.

Hrm should work then, connect to lish via terminal and run the log view command see: http://library.linode.com/troubleshooti … node-shell">http://library.linode.com/troubleshooting/using-lish-the-linode-shell it'll show the boot process see if nginx is mentioned there.

I thought I might be missing the /usr/sbin/update-rc.d -f nginx defaults as it's at the end of the source install section and I thought I might have skipped it.

If I run it, I get:

root@sadhana:/etc/init.d# /usr/sbin/update-rc.d -f nginx defaults
 System start/stop links for /etc/init.d/nginx already exist.

So it looks like it's already there. I'll try the Lish suggestion and post what I find.

If you installed via apt-get you shouldn't have to touch any startup files or anything except what's in /etc/nginx/

I'm having Lish trouble :(

It logs me into Lish and then it's sitting at:

[linode185164@fremont182 lish] Linode Shell (lish) Console starting...
[linode185164@fremont182 lish] 
 <some menu="" command="" text="">Ubuntu 11.10 sadhana hvc0

sadhana login:</some> 

How can I abort login? I can't seem to esc out of this so I'm unable to type the log view command.

Thanks for the continued help!

Press ctrl+a then d, it's a screen session that will bring you to the lish prompt

Okay, I didn't understand the screen session comments applied to what I was doing, thanks that helped.

And running log view yields:

Showing last 100 lines from current boot
-----------------------------------------
SGI XFS with ACLs, security attributes, large block/inode numbers, no debug enabled
SGI XFS Quota Management subsystem
GFS2 installed
msgmni has been set to 989
NET: Registered protocol family 38
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Event-channel device installed.
brd: module loaded
loop: module loaded
nbd: registered device at major 43
drbd: initialized. Version: 8.3.11 (api:88/proto:86-96)
drbd: built-in
drbd: registered as block device major 147
drbd: minor_table @ 0xdef806c0
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
PPTP driver version 0.8.5
SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256) (6 bit encapsulation enabled).
CSLIP: code copyright 1989 Regents of the University of California.
SLIP linefill/keepalive option.
Initialising Xen virtual ethernet driver.
blkfront: xvda: barrier: enabled
tun: Universal TUN/TAP device driver, 1.6
tun: (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>i8042: No controller found
mousedev: PS/2 mouse device common for all mice
md: linear personality registered for level -1
md: raid0 personality registered for level 0
md: raid1 personality registered for level 1
md: raid6 personality registered for level 6
md: raid5 personality registered for level 5
md: raid4 personality registered for level 4
md: multipath personality registered for level -4
device-mapper: ioctl: 4.20.0-ioctl (2011-02-02) initialised: dm-devel@redhat.com
padlock_aes: VIA PadLock not detected.
padlock_sha: VIA PadLock Hash Engine not detected.
GACT probability NOT on
u32 classifier
    Performance counters on
    Actions configured
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (8192 buckets, 65536 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPv4 over IPv4 tunneling driver
GRE over IPv4 demultiplexor driver
GRE over IPv4 tunneling driver
ip_tables: (C) 2000-2006 Netfilter Core Team
TCP cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 10
ip6_tables: (C) 2000-2006 Netfilter Core Team
IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
NET: Registered protocol family 15
Bridge firewalling registered
Ebtables v2.0 registered
802.1Q VLAN Support v1.8
sctp: Hash tables configured (established 16384 bind 16384)
Registering the dns_resolver key type
Using IPI No-Shortcut mode
registered taskstats version 1
 xvda: unknown partition table
blkfront: xvdb: barrier: enabled
 xvdb: unknown partition table
Setting capacity to 524288
xvdb: detected capacity change from 0 to 268435456
XENBUS: Device with no driver: device/console/0
md: Waiting for all devices to be available before autodetect
md: If you don't use raid, use raid=noautodetect
md: Autodetecting RAID arrays.
md: Scanned 0 and added 0 devices.
md: autorun ...
md: ... autorun DONE.
EXT3-fs: barriers not enabled
kjournald starting.  Commit interval 5 seconds
EXT3-fs (xvda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 202:0.
devtmpfs: mounted
Freeing unused kernel memory: 388k freed
Write protecting the kernel text: 5984k
Write protecting the kernel read-only data: 1432k
NX-protecting the kernel data: 3232k
FATAL: Module nf_conntrack_ftp not found.
FATAL: Module nf_nat_ftp not found.
FATAL: Module nf_conntrack_netbios_ns not found.
fsck from util-linux 2.19.1
/dev/xvda: clean, 29850/573856 files, 209900/2560000 blocks
spawn-fcgi: child spawned successfully: PID: 2143
 * Starting NTP server ntpd                                              [ OK ] 

Ubuntu 11.10 sadhana hvc0

sadhana login: 
[linode185164@fremont182 lish]#</maxk@qualcomm.com> 

No nginx mentioned…

Yep looks like some how you managed to break the init scripts on installation, try running update-rc.d -f nginx remove; update-rc.d nginx defaults then reboot.

Before I posted my original post, I looked at that and ran that exact command.

I did it again:

root@sadhana:/home# update-rc.d -f nginx remove; update-rc.d nginx defaults
 Removing any system startup links for /etc/init.d/nginx ...
   /etc/rc0.d/K20nginx
   /etc/rc1.d/K20nginx
   /etc/rc2.d/S20nginx
   /etc/rc3.d/S20nginx
   /etc/rc4.d/S20nginx
   /etc/rc5.d/S20nginx
   /etc/rc6.d/K20nginx
 Adding system startup for /etc/init.d/nginx ...
   /etc/rc0.d/K20nginx -> ../init.d/nginx
   /etc/rc1.d/K20nginx -> ../init.d/nginx
   /etc/rc6.d/K20nginx -> ../init.d/nginx
   /etc/rc2.d/S20nginx -> ../init.d/nginx
   /etc/rc3.d/S20nginx -> ../init.d/nginx
   /etc/rc4.d/S20nginx -> ../init.d/nginx
   /etc/rc5.d/S20nginx -> ../init.d/nginx
root@sadhana:/home# 

And on reboot, nginx is still not running. The plot thickens :)

Very much appreciate you taking part of your weekend to help. Hopefully not detracting you too much from your dissertation!

Eh I should be doing it but I'm having a lazy weekend.

Does running /etc/init.d/nginx start manually start nginx?

Nope, /etc/init.d/nginx start doesn't work, but just nginx does.

Contents of /etc/init.d/nginx

#! /bin/sh

### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO

PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
        . /etc/default/nginx
fi

set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile /opt/nginx/logs/$NAME.pid \
                --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /opt/nginx/logs/$NAME.pid \
                --exec $DAEMON
        echo "$NAME."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile \
                /opt/nginx/logs/$NAME.pid --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet --pidfile \
                /opt/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  reload)
         echo -n "Reloading $DESC configuration: "
          start-stop-daemon --stop --signal HUP --quiet --pidfile     /opt/nginx/logs/$NAME.pid \
              --exec $DAEMON
          echo "$NAME."
          ;;
      *)
            N=/etc/init.d/$NAME
            echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
            exit 1
            ;;
    esac

    exit 0

What's your dissertation on?

It's on building asynchronous javascript applications, bit like how the new gmail and twitter interfaces work but on a smaller scale (I get to build browser based computer games for a dissertation :D )

Anyway you're init script is fubard, looks like you replaced it with the one you use for building from source, replace it with http://pastebin.linode.com/6486 which I copied from ubuntu 11.10's apt package

Success!

Well, obviously at some point I overwrote the script as you pointed out, must have been done when I was double-checking everything and noticed a difference and mistakenly overwrote it. Bah! Very sorry to have taken so much of your time for a user error :(

But if I can return the favor somehow let me know. I have been developing games professionally for more than 20 years so if I can be of service during your dissertation, let me know!

Cheers,

Brett

No worries :) now I'll go and do something else useful has pages and pages to read

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct