Upgrading mysql and configurating my custom 404.html page

I have two problems : Upgrading mysql and configurating my custom
404.html page.

I wanted to install an admin page, but need to the consistency of mysql
and php version, so I wanted upgrade mysql as the same version as PHP,
and I had the following result:

Nginx failure and impossible to use port 81. My website stop to work.

I set Nginx on port 81 because I could not connect my VPS on Internet
for updating and installing packages.

Here is my configuration :

Debian 6 wheezy (ok)
nginx (ok)
php5 (cgi and fmp not installed)
mysql (ok)
csf firewall (ok)
naxsi (installed but not working)

So I spent days on google without finding solutions, knowing I had
previously installed csf firewall, Meanwhile I wanted to change the
default nginx 404 page to my custom 404.html page, my errors html files
are in the root directory, that I had configure this default server
file, but still does not work, and then I can’t stop nginx ( “nginx stop
service.” ) The nginx.pid is missing.

My website works and mysql too, but I’m stuck here.

Can you give me the solution ?

Any help will be appreciated.

Thank you.


-nginx.conf

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_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 application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    include /etc/nginx/naxsi_core.rules;

    ##
    # Virtual Host Configs
    ##

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

}


My default server conf file :

server {
listen 81; ## listen for ipv4; this line is default and
implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    root /var/www/;
    index index.html index.htm index.php

     error_page 404 /404.html;
     location = /40x.html {
            root /var/www/;
            internal;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
     location = /50x.html {
            root /var/www/;

    }


    #Make site accessible from http://www.site.com/
    server_name site.com www.site.com;

access_log /var/log/nginx/site.access.log;
error_log /var/log/nginx/site.error.log;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.html;
            # Uncomment to enable naxsi on this location
             include /etc/nginx/naxsi.rules;
    }

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            allow ::1;
            deny all;
    }


    # Only for nginx-naxsi used with nginx-naxsi-ui : process denied

requests
location /RequestDenied {
proxy_pass http://127.0.0.1:8081;
return 500;

    }




    # pass the PHP scripts to FastCGI server listening on

127.0.0.1:9000
#
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
# # NOTE: You should have “cgi.fix_pathinfo = 0;” in
php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:

    #       fastcgi_pass 127.0.0.1:9000;
    #       # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}

}


root@xxx:~# netstat -ntpul

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name

tcp 0 0 127.0.0.1:3306 0.0.0.0:*
LISTEN 2989/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:*
LISTEN 3198/sshd
tcp 0 0 0.0.0.0:81 0.0.0.0:*
LISTEN 4647/nginx
tcp 0 0 127.0.0.1:6010 0.0.0.0:*
LISTEN 18881/0
tcp6 0 0 :::22 :::*
LISTEN 3198/sshd
tcp6 0 0 :::80 :::*
LISTEN 2266/apache2
tcp6 0 0 ::1:6010 :::*
LISTEN 18881/0
udp 0 0 0.0.0.0:36913 0.0.0.0:*
2299/avahi-daemon:
udp 0 0 xx.xx.x.xx:xxx 0.0.0.0:*
3139/ntpd
udp 0 0 xxx.xx.xxx.xxx:xxx 0.0.0.0:*
3139/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:*
3139/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:*
3139/ntpd
udp 0 0 0.0.0.0:5353 0.0.0.0:*
2299/avahi-daemon:
udp 0 0 0.0.0.0:1900 0.0.0.0:*
3303/minissdpd
udp6 0 0 :::49180 :::*
2299/avahi-daemon:
udp6 0 0 ::1:123 :::*
3139/ntpd
udp6 0 0 xx80::xxxx:xx:xxx::xxx :::*
3139/ntpd
udp6 0 0 :::123 :::*
3139/ntpd
udp6 0 0 :::5353 :::*
2299/avahi-daemon:

On Mon, Nov 24, 2014 at 08:38:49PM +0100, Thornx John wrote:

Hi there,

I have two problems : Upgrading mysql and configurating my custom
404.html page.

The 404 page part may be relevant to this mailing list.

So I spent days on google without finding solutions, knowing I had
previously installed csf firewall, Meanwhile I wanted to change the
default nginx 404 page to my custom 404.html page, my errors html files
are in the root directory, that I had configure this default server
file, but still does not work, and then I can’t stop nginx ( “nginx stop
service.” ) The nginx.pid is missing.

I’m confused as to what exactly you are doing and what exactly you are
seeing and what exactly you are expecting to see.

So take this as “information” rather than “a recipe”.

My website works and mysql too, but I’m stuck here.

Your “netstat” output suggests that nginx is running as pid 4647 and
listening on port 81.

If you manually “kill” that pid, then that will probably cause your
current nginx to exit.

(Don’t do that until you want to, of course.)

Then the “normal” nginx commands can be used to confirm that your config
file is syntactically correct, and can be started and stopped. If you
use any “wrapper” commands to do that, make sure that they refer to the
binaries and config files that you want them to.

    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    include /etc/nginx/naxsi_core.rules;

I do not know what naxsi is, so I do not know what is involved in
that “include” file. If it breaks normal nginx semantics, then you’ll
probably want to ask naxsi people for help. If it doesn’t, then this
should work as-is.

    ##
    # Virtual Host Configs
    ##

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

Potentially, every one of those files matter.

I am only working off the partial config you have shown here.

If you need to understand the whole thing, you may prefer to remove most
of those files so that you have a small and understandable config file,
and then add in other pieces one at a time.

    root /var/www/;
    index index.html index.htm index.php

     error_page 404 /404.html;

So, any 404 error is handled by the url /404.html, which (unless other
configuration overrides it) corresponds to the file /var/www/404.html.

     location = /40x.html {

This configuration does not apply to the url /404.html

    location / {

This configuration can apply to the url /404.html; and is the one that
will apply (based on the other location{} blocks in this server{}.

            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.html;

The comment says one thing; the config directive says another. This line
will never cause a 404 to be raised. Anything that might have caused a
404 will instead return the content of /var/www/index.html…

            # Uncomment to enable naxsi on this location
             include /etc/nginx/naxsi.rules;

…unless that causes something else to happen.

(And if /var/www/index.html does not exist, you’ll probably get a
500-series error.)

So:

what request do you make where you expect a 404?

What response do you actually get instead?

(“curl -i” is usually good for showing this.)

As to the solution – it depends on what you want to have happen; and
it is not clear to me from this mail what that is.

Perhaps remove every configuration directive that you do not understand,
and see what happens on your test system? Add things back one at a
time? Then when things work there as you expect, transfer the config to
your live system?

Good luck with it,

f

Francis D. [email protected]

Hello Francis.

Thank you for your reply.

I made a discovery that cooled me, I stopped nginx fully with the
command:

kill -9 27932 27931 27930 27929 27928 27925 with the help of “ps ax” but
the site still works with Apache in my opinion.

Now I know why nginx does not react and personal error pages not more!

Here are my new process :


PID TTY STAT TIME COMMAND
1 ? Ss 0:01 init [2]
2 ? S 0:00 [kthreadd]
3 ? S 0:05 [ksoftirqd/0]
5 ? S 0:00 [kworker/u:0]
6 ? S 0:00 [migration/0]
7 ? S 0:02 [watchdog/0]
8 ? S< 0:00 [cpuset]
9 ? S< 0:00 [khelper]
10 ? S 0:00 [kdevtmpfs]
11 ? S< 0:00 [netns]
12 ? S 0:00 [sync_supers]
13 ? S 0:00 [bdi-default]
14 ? S< 0:00 [kintegrityd]
15 ? S< 0:00 [kblockd]
17 ? S 0:00 [khungtaskd]
18 ? S 0:00 [kswapd0]
19 ? SN 0:00 [ksmd]
20 ? SN 0:00 [khugepaged]
21 ? S 0:00 [fsnotify_mark]
22 ? S< 0:00 [crypto]
120 ? S 0:00 [khubd]
121 ? S< 0:00 [ata_sff]
128 ? S 0:00 [scsi_eh_0]
129 ? S 0:00 [scsi_eh_1]
143 ? S 0:00 [kworker/u:1]
164 ? S 0:02 [kjournald]
308 ? Ss 0:00 udevd --daemon
446 ? S 0:00 [vballoon]
448 ? S< 0:00 [kpsmoused]
451 ? S 0:04 [kworker/0:3]
2094 ? Sl 0:00 /usr/sbin/rsyslogd -c5
2124 ? Ss 0:00 /usr/sbin/acpid
2154 ? Ss 0:00 /usr/bin/dbus-daemon --system
2179 ? Ssl 0:00 /usr/sbin/NetworkManager
2200 ? Sl 0:00 /usr/lib/policykit-1/polkitd --no-debug
2216 ? S 0:00 /usr/sbin/modem-manager
2266 ? Ss 0:05 /usr/sbin/apache2 -k start
2288 ? S 0:00 /usr/sbin/apache2 -k start
2299 ? S 0:00 avahi-daemon: running [108.local]
2300 ? S 0:00 avahi-daemon: chroot helper
2325 ? Ss 0:00 /usr/sbin/bluetoothd
2337 ? S< 0:00 [krfcommd]
2410 ? Ss 0:00 /usr/sbin/cron
2430 ? Ss 0:33 lfd - sleeping
2447 ? Sl 0:00 /usr/sbin/lightdm
2453 tty7 Ss+ 1:57 /usr/bin/X :0 -auth /var/run/lightdm/root/:0
-nolisten tcp vt7 -novtswitch
2478 ? S 0:00 udevd --daemon
2556 ? S 0:00 /bin/sh /usr/bin/mysqld_safe
2689 ? Sl 0:00 lightdm --session-child 16 19
2716 ? Sl 0:00 /usr/lib/accountsservice/accounts-daemon
2758 ? Sl 0:00 /usr/sbin/console-kit-daemon --no-daemon
2967 ? Ssl 3:49 /usr/sbin/lightdm-gtk-greeter
2989 ? Sl 0:55 /usr/sbin/mysqld --basedir=/usr
–datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql
–log-error=/var/log/mysql/error.log --pid-fi
3008 ? Sl 0:00 /usr/lib/upower/upowerd
3009 ? S 0:00 [flush-254:0]
3047 ? S 0:00 lightdm --session-child 12 19
3139 ? Ss 0:07 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u
101:103
3198 ? Ss 0:00 /usr/sbin/sshd
3303 ? Ss 0:00 /usr/sbin/minissdpd -i 0.0.0.0
3385 tty1 Ss+ 0:00 /sbin/getty 38400 tty1
3386 tty2 Ss+ 0:00 /sbin/getty 38400 tty2
3387 tty3 Ss+ 0:00 /sbin/getty 38400 tty3
3388 tty4 Ss+ 0:00 /sbin/getty 38400 tty4
3389 tty5 Ss+ 0:00 /sbin/getty 38400 tty5
3390 tty6 Ss+ 0:00 /sbin/getty 38400 tty6
3485 ? S 0:00 /usr/sbin/apache2 -k start
3794 ? S 0:00 /usr/sbin/apache2 -k start
4265 ? S 0:00 /usr/sbin/apache2 -k start
4340 ? S 0:00 /usr/sbin/apache2 -k start
4574 ? S 0:00 /usr/sbin/apache2 -k start
4756 ? S 0:00 /usr/sbin/apache2 -k start
5226 ? S 0:00 /usr/sbin/apache2 -k start
5227 ? S 0:00 /usr/sbin/apache2 -k start
17467 ? S 0:00 /usr/sbin/apache2 -k start
26445 ? S 0:00 [kworker/0:0]
27969 ? Ss 0:00 sshd: root@pts/0
27972 pts/0 Ss 0:00 -bash
28049 pts/0 R+ 0:00 ps ax


Now I must make a choice: keep or not Apache2 !

I confess that I prefer nginx, but if I uninstall apache that will
happen to my website ?

I hope it’s a little clearer.

Thank you.

John.T

On Tue, Nov 25, 2014 at 02:56:18PM +0100, Thornx John wrote:

Hi there,

Now I must make a choice: keep or not Apache2 !

I confess that I prefer nginx, but if I uninstall apache that will
happen to my website ?

I hope it’s a little clearer.

If you have a working system, the easiest thing is to leave it working
as-is.

From your first mail, I thought that you had a working nginx system,
then made two changes and it stopped working.

From this mail, I think that you did not have a working nginx system.

There is too much information missing from these mails for me to know
what you want to do.

If your apache system works well enough, do not change it. Maybe build
a test system on another machine, and play with changing that to nginx.

Good luck with it,

f

Francis D. [email protected]

On Wed, Nov 26, 2014 at 09:24:27PM +0100, Thornx John wrote:

Hi there,

I had upgraded mysql and installed php-fpm and stay with nginx,
everything works, but my first goal was to establish an admin page,
so when I’v done this update to the latest version, nothing goes better
for my admin panel, I had the following message about mysql :

This all seems to relate to mysql and php.

There is nothing nginx that I can see here.

You may want to look in to how you upgraded, and make sure that you have
a matching set of packages.

But you are much more likely to get a better answer about that
elsewhere.

Good luck with it,

f

Francis D. [email protected]

Hello Francis,

I had upgraded mysql and installed php-fpm and stay with nginx,
everything works, but my first goal was to establish an admin page,
so when I’v done this update to the latest version, nothing goes better
for my admin panel, I had the following message about mysql :


Warning: mysql_connect(): Headers and client library minor version
mismatch. Headers:50540 Library:50621 in
/var/www/admin/inc/database.inc.php on line 58


All these packages are fully upgraded, I really do not understand.

mysql version :

mysql server: 5.6.21-1~dotdeb.1
client MySQL: 5.6.21

Here is my php info page :

PHP Version 5.4.35-1~dotdeb.1

System Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u1 x86_64
Build Date Nov 17 2014 02:54:02
Server API FPM/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php5/fpm
Loaded Configuration File /etc/php5/fpm/php.ini
Scan this dir for additional .ini files /etc/php5/fpm/conf.d
Additional .ini files parsed /etc/php5/fpm/conf.d/10-pdo.ini,
/etc/php5/fpm/conf.d/20-mcrypt.ini, /etc/php5/fpm/conf.d/20-mysql.ini,
/etc/php5/fpm/conf.d/20-mysqli.ini,
/etc/php5/fpm/conf.d/20-pdo_mysql.ini
PHP API 20100412
PHP Extension 20100525
Zend Extension 220100525
Zend Extension Build API220100525,NTS
PHP Extension Build API20100525,NTS
Debug Build no
Thread Safety disabled
Zend Signal Handling disabled
Zend Memory Manager enabled
Zend Multibyte Support provided by mbstring
IPv6 Support enabled
DTrace Support disabled
Registered PHP Streams https, ftps, compress.zlib, compress.bzip2, php,
file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3,
tls
Registered Stream Filters zlib., bzip2., convert.iconv.,
string.rot13, string.toupper, string.tolower, string.strip_tags,
convert.
, consumed, dechunk, mcrypt., mdecrypt.


Thank you.

J.T.