Print this Page

Home Server Internal Nginx Management Web

Index.

 18-Jan-2012: Initial release.

 

Introduction.

For maintenance of our Home Server we need an internal web server. On this server we can install things for example like phpMyAdmin to have easy access to our MySQL server. We could also create a Intra-net server, but in a Home environment that is not so useful.

Important!

This server is not intended to be your external web server, but it is possible to do that. The setup below is NOT suited for external use! You need to make several changes to let it function as an and external server. My advice is use a separate virtual server.

 

Installation.

Install all software that we need to run nginx on our Home Server:

[root@homsrv ~]# pacman -S nginx php-fpm php-gd php-mcrypt php-snmp fcgiwrap
resolving dependencies...
looking for inter-conflicts...

Targets (10): fcgi-2.4.0-7  libmcrypt-2.5.8-3  php-5.3.9-1  spawn-fcgi-1.6.3-2
              fcgiwrap-1.0.3-2  nginx-1.0.11-1  php-fpm-5.3.9-1  php-gd-5.3.9-1
              php-mcrypt-5.3.9-1  php-snmp-5.3.9-1

Total Download Size:    4.97 MiB
Total Installed Size:   23.61 MiB

Proceed with installation? [Y/n]
:: Retrieving packages from extra...
 php-5.3.9-1-i686           2.8 MiB  1058K/s 00:03 [######################] 100%
 php-fpm-5.3.9-1-i686    1590.6 KiB  1023K/s 00:02 [######################] 100%
 php-gd-5.3.9-1-i686       71.2 KiB   328K/s 00:00 [######################] 100%
 libmcrypt-2.5.8-3-i686    67.4 KiB   305K/s 00:00 [######################] 100%
 php-mcrypt-5.3.9-1-i686   10.3 KiB   100K/s 00:00 [######################] 100%
 php-snmp-5.3.9-1-i686      7.2 KiB   134K/s 00:00 [######################] 100%
 fcgi-2.4.0-7-i686         47.3 KiB   215K/s 00:00 [######################] 100%
:: Retrieving packages from community...
 nginx-1.0.11-1-i686      362.5 KiB   725K/s 00:01 [######################] 100%
 spawn-fcgi-1.6.3-2-i686    8.4 KiB   150K/s 00:00 [######################] 100%
 fcgiwrap-1.0.3-2-i686      9.4 KiB   188K/s 00:00 [######################] 100%
(10/10) checking package integrity                 [######################] 100%
(10/10) loading package files                      [######################] 100%
(10/10) checking for file conflicts                [######################] 100%
(10/10) checking available disk space              [######################] 100%
( 1/10) installing nginx                           [######################] 100%
Optional dependencies for nginx
    passenger
( 2/10) installing php                             [######################] 100%
( 3/10) installing php-fpm                         [######################] 100%
( 4/10) installing php-gd                          [######################] 100%
( 5/10) installing libmcrypt                       [######################] 100%
( 6/10) installing php-mcrypt                      [######################] 100%
( 7/10) installing php-snmp                        [######################] 100%
( 8/10) installing fcgi                            [######################] 100%
( 9/10) installing spawn-fcgi                      [######################] 100%
(10/10) installing fcgiwrap                        [######################] 100%
[root@homsrv ~]#

 

The PHP package needs some configuration, here is the diff output of /etc/php/php.ini:

--- php.ini.orig        2011-06-24 15:43:06.000000000 +0200
+++ php.ini     2011-06-24 15:51:23.000000000 +0200
@@ -376,7 +376,7 @@
 ; or per-virtualhost web server configuration file. This directive is
 ; *NOT* affected by whether Safe Mode is turned On or Off.
 ; http://php.net/open-basedir
-open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/
+open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/var/state/dhcp

 ; This directive allows you to disable certain functions for security reasons.
 ; It receives a comma-delimited list of function names. This directive is
@@ -635,7 +635,7 @@
 ; Example:
 ;error_log = php_errors.log
 ; Log errors to syslog (Event Log on NT, not valid in Windows 95).
-;error_log = syslog
+error_log = syslog

 ;;;;;;;;;;;;;;;;;
 ; Data Handling ;
@@ -725,7 +725,7 @@

 ; Maximum size of POST data that PHP will accept.
 ; http://php.net/post-max-size
-post_max_size = 8M
+post_max_size = 32M

 ; Magic quotes are a preprocessing feature of PHP where PHP will attempt to
 ; escape any character sequences in GET, POST, COOKIE and ENV data which might
@@ -876,7 +876,7 @@

 ; Maximum allowed size for uploaded files.
 ; http://php.net/upload-max-filesize
-upload_max_filesize = 2M
+upload_max_filesize = 32M

 ; Maximum number of files that can be uploaded via a single request
 max_file_uploads = 20
@@ -938,47 +938,47 @@
 ; If you only provide the name of the extension, PHP will look for it in its
 ; default extension directory.
 ;
-;extension=bcmath.so
-;extension=bz2.so
-;extension=calendar.so
-extension=curl.so
-;extension=dba.so
+extension=bcmath.so
+extension=bz2.so
+extension=calendar.so
+;extension=curl.so
+extension=dba.so
 ;extension=enchant.so
-;extension=exif.so
-;extension=ftp.so
-;extension=gd.so
+extension=exif.so
+extension=ftp.so
+extension=gd.so
 extension=gettext.so
 ;extension=gmp.so
-;extension=iconv.so
-;extension=imap.so
+extension=iconv.so
+extension=imap.so
 ;extension=intl.so
 extension=json.so
 ;extension=ldap.so
-;extension=mcrypt.so
+extension=mcrypt.so
 ;extension=mssql.so
-;extension=mysqli.so
-;extension=mysql.so
+extension=mysqli.so
+extension=mysql.so
 ;extension=odbc.so
-;extension=openssl.so
-;extension=pdo_mysql.so
+extension=openssl.so
+extension=pdo_mysql.so
 ;extension=pdo_odbc.so
 ;extension=pdo_pgsql.so
 ;extension=pdo_sqlite.so
 ;extension=pgsql.so
-;extension=phar.so
-;extension=posix.so
+extension=phar.so
+extension=posix.so
 ;extension=pspell.so
 ;extension=shmop.so
-;extension=snmp.so
-;extension=soap.so
-;extension=sockets.so
+extension=snmp.so
+extension=soap.so
+extension=sockets.so
 ;extension=sqlite3.so
-;extension=sqlite.so
-;extension=sysvmsg.so
-;extension=sysvsem.so
-;extension=sysvshm.so
+extension=sqlite.so
+extension=sysvmsg.so
+extension=sysvsem.so
+extension=sysvshm.so
 ;extension=tidy.so
-;extension=xmlrpc.so
+extension=xmlrpc.so
 ;extension=xsl.so
-;extension=zip.so
+extension=zip.so

 ;;;;;;;;;;;;;;;;;;;
 ; Module Settings ;
 @@ -989,7 +989,7 @@
 [Date]
 ; Defines the default timezone used by the date functions
 ; http://php.net/date.timezone
-;date.timezone =
+date.timezone = Europe/Amsterdam

 ; http://php.net/date.default-latitude
 ;date.default_latitude = 31.7667

 

The configuration file /etc/nginx/conf/nginx.xonf:

# /etc/nginx/conf/nginx.conf at homsrv.wpl.ym

worker_processes        1;
error_log               logs/error_log;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile            on;
    keepalive_timeout   65;
    gzip                on;
    gzip_min_length     1000;
    gzip_proxied        expired no-cache no-store private auth;
    gzip_types          text/plain text/css application/x-javascript
                        text/xml application/xml application/xml+rss
                        text/javascript;
    gzip_disable        "MSIE [1-6]\.";

    # Upstream to abstract backend connection(s) for PHP.
    upstream php {
        server          unix:/var/run/php-fpm/php-fpm.sock;
    }
    upstream cgi {
        server          127.0.0.1:9001;
    }

    server {
        listen          10.126.160.253:80;
        listen          [2001:1af8:fecf:7ea0::fd]:80;
        listen          10.126.161.2:80;
        listen          [2001:1af8:fecf:7ea1::2]:80;
        server_name     homsrv.wpl.ym;
        root            /srv/http/htdocs;
        access_log      logs/access_log main;
        error_log       logs/error_log;
        index           index.html index.php;

        location ~ \.php$ {
            include             fastcgi.conf;
            fastcgi_pass        php;
        }
    }
}

 

Now, for the first time start the server like this:

[root@homsrv ~]# mkdir -p /srv/http/htdocs
[root@homsrv ~]# rc.d start php-fpm
:: Checking configuration                                                [DONE]
:: Starting php-fpm                                                      [DONE]
[root@homsrv ~]# rc.d start fcgiwrap
:: Starting fcgiwrap daemon                                              [DONE]
[root@homsrv ~]# rc.d start nginx
:: Checking configuration                                                [DONE]
:: Starting Nginx                                                        [DONE]
[root@homsrv ~]#

 

If it all works, add php-fpm, fcgiwrap and nginx to /etc/rc.conf.

That’s it. In the support archive is a sample home page with some links to existing and feature utilities.

Home Server maintenance web

Home Server maintenance web

 

 

Download.

The complete configuration is in the next archive:

Linux Home Server complete package
Linux Home Server complete package
homeserver-complete.tar.gz
2.6 MiB
7 Downloads
Details...

 

Permanent link to this article: http://www.mbse.eu/linux/homeserver/essential/int-nginx/