NSLU2-Linux
view · edit · print · history

LLMP (Linux, Lighttpd, MySQL, PHP) on a Plug (omit Pogoplug specific steps for other platforms) (LLMP is in place of LAMP to conserve resources) (Pogoplug specific refers to Pogoplug V1, Pogoplug V2 (gray and pink), Pogoplug Pro, Pogoplug Biz, Seagate devices such as Dockstar and GoFlex).

(Please be aware that you are responsible for any damage to your hardware, software, or files, so use extreme caution when following guides/instructons on this site. NO warranty is explicitly or implicitly provided. It is assumed that you know what you are doing and if not, get assistance from somebody that does, or do not perform the installation.)

Lighttpd

1. Install Lighttpd and PHP after making the root file system accessible and creating /var/run:

    Type "mount -o rw,remount /"
    Type "mv /var /varold".  If you stop using optware, you can restore the old var with "mv /varold /var"
    Type "mkdir /opt/var".  You might not need this if /opt/var already exists.
    Type "mkdir /opt/var/run"
    Type "ln -s /opt/var /var"
    Type "ipkg install lighttpd php fcgi php-fcgi php-pear mysql phpmyadmin"

2. Configure Lighttpd by editing lighttpd.conf in /opt/etc/lighttpd by typing "cd /opt/etc/lighttpd" and edit lighttpd.conf with your preferred editor (if you use nano, try to invoke it with "nano -w filename" so that long lines are not wrapped). Because Pogoplug based plugs use port 80 for Cloud Engines functionality, a different port such as 8081 needs to be used. You also need to turn on some modules. The web site directory has to be designated.

Make sure "mod_access", "mod_auth", "mod_fastcgi", and "mod_accesslog" and any other modules you choose are uncommented.

server.modules              = (
#                               "mod_rewrite",
#                               "mod_redirect",
#                               "mod_alias",
                               "mod_access",
#                               "mod_cml",
#                               "mod_trigger_b4_dl",
                               "mod_auth",
#                               "mod_status",
#                               "mod_setenv",
                               "mod_fastcgi",
#                               "mod_proxy",
#                               "mod_simple_vhost",
#                               "mod_evhost",
#                               "mod_userdir",
#                               "mod_cgi",
#                               "mod_compress",
#                               "mod_ssi",
#                               "mod_usertrack",
#                               "mod_expire",
#                               "mod_secdownload",
#                               "mod_rrdtool",
                                "mod_accesslog" )

The default web site directory has to be designated. The default is "/opt/share/www". Change this to your preference.

    server.document-root        = "/opt/share/www/"

The port has to be set and if you are using my.pogoplug.com services, you cannot use port 80. So change the port to 8081 (which is not typically used).

    server.port                = 8081

Save you changes and then type "cd /opt/etc/lighttpd/conf.d" and check if 10-php-fcgi.conf exists. You can verify its contents:

server.modules += ( "mod_fastcgi" )

fastcgi.server = ( ".php" =>
                   ( "localhost" =>
                     ( "socket" => "/tmp/php-fcgi.sock",
                       "bin-path" => "/opt/bin/php-fcgi",
                       "max-procs" => 1,
                       "bin-environment" =>
                         ( "PHP_FCGI_CHILDREN" => "2",
                           "PHP_FCGI_MAX_REQUESTS" => "1000" )
                     )
                   )
                 )

3. Test lighttpd by starting it and look for any error messages:

    Type "/opt/etc/init.d/S80lighttpd start"

Fix any errors that show up and try to access it by using your web browser with the address "http://your.pogoplug.ipaddress:8081". You should see the lighttpd default web page.

PHP

You can test php by creating the file "php-info.php" in you web site directory with the contents:

    <html>
    <head>
    <title>PHP Test Page</title>
    </head>
    <body>
    <?php phpinfo(); ?>
    </body>
    </html>

And then accessing it with your web browser with the address "http://your.pogoplug.ipaddress:8081/php-info.php". This should give you the PHP configuration. You may want to rename or remove this file if you do not want other people to know your configuration.

You need to initialize pear by typing "pear install DB". Make sure to place "/opt/share/pear" in your php.ini include_path.

MySQL (with PHPMyAdmin)

1. Time to set up your MySQL root password which should probably be different from your system password"

    Type "/opt/bin/mysqladmin -u root password 'sqlrootpassword'"

Where sqlrootpassword is the password you chose and should remember because you need it also for the next step.

2. Change to the phpmyadmin directory with "cd /opt/share/www/phpmyadmin" and edit config.inc.php with your favorite editor (if you use nano, make sure you use it as "nano -w filename" which is important here). Next, search for the line $cfg['Servers'][$i]['password'] and fill in your sql root password between the empty quotes without removing them. Save your changes.

3. If you used a different default web site directory other than "/opt/share/www" then phpmyadmin has to be place there. You can do this with a symbolic link"

    Type "ln -s /opt/share/www/phpmyadmin /default/website/directory/phpmyadmin"

Where /default/website/directory is the actual one your chose.

4. At this point, it is time to start MySQL and fix any errors:

    Type "/opt/etc/init.d/S70mysqld start"

5. Restart Lighttpd:

    Type "/opt/etc/init.d/S80lighttpd restart"

6. Check to make sure that you can access PHPMyAdmin by using your web browser with the address "http://your.pogoplug.ipaddress:8081/phpmyadmin/". You are now ready to create databases.

7. You can now insert "/opt/etc/init.d/S70mysqld start" and "/opt/etc/init.d/S80lighttpd start" in your rcS or mount_optextX file so they can be called at system start up.

8. You can type "mount -o ro,remount /" to return your root file system to read only.

9. Try rebooting your computer to make sure that everything works.

Additional Enhancements

Ruby on Rails and RubyGems (credit to Brian Zhou)

To install Ruby on Rails and RubyGems:

    Type "ipkg install rubygems".
    Type "gem update --system".
    Type "gem install rails --remote --include-dependencies".
    Type "wget http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.gem".
    Type "gem install scgi_rails-0.4.3.gem --include-dependencies".

User's Guide is at "http://docs.rubygems.org/read/book/1".

Django Framework

To install Django and Python:

    Type "ipkg install python26 py26-django"

Test they installation by typing "python2.6", then at the python prompt type "import django" then "print django.get_version()". Control-d to exit.

By default, the runserver command starts the development server on the internal IP at port 8000. If you want to change the server's port, pass it as a command-line argument. Type this command to start the server on port 8080:

    "python2.6 manage.py runserver 8080"

If you want to change the server's IP, pass it along with the port.

To listen on all public IPs (Django only listens to request on localhost by default), use:

    "python2.6 manage.py runserver 0.0.0.0:8000"

Information for Django is at "http://www.djangoproject.com/". How to use it with Lighttpd "http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/".

Here is a sample Vhost entry in lighttpd:

$HTTP["host"] == "www.pluggy.com" {
  fastcgi.server = ( "/django.fcgi" =>
                     ( "django" =>
                       (
                         "socket" => "/opt/lib/lighttpd/django-fastcgi.socket",
                         "bin-path" => "/opt/path/to/startfcgi.sh",
                         "check-local" => "disable",
                         "max-procs" => 1,
                       )
                     )
                   )
  alias.url += ( "/media/" => "/opt/path/to/django/media/",
                 "/admin_media/" => "/opt/lib/python2.6/site-packages/django/contrib/admin/media/" )
  url.rewrite-once = ( "^(/media/.*)$" => "$1",
                       "^(/admin_media/.*)$" => "$1",
                       "^(/robots.txt)$" => "$1",
                       "^(/.*)$" => "/django.fcgi$1" )
}

The startfcgi.sh contains:

#!/bin/sh
app_path='/opt/path/to/django/app'
p='/opt/var/run/lighttpd/django-fastcgi.pid'
cd "$app_path"
if [ -f $p ]; then
    kill $(cat -- $p)
    rm -f -- $p
fi

exec /usr/bin/env \
    PYTHONPATH="$app_path/.." python \
    manage.py runfcgi \
    daemonize=false \
    method=prefork \
    maxspare=2 \
    pidfile="$p"

Dynamic DNS

To be able to access your web site from the internet, you may need to set up a Dynamic DNS updater. If you have a Pogoplug Pro, you may have conflicts with wget and wget-ssl. Just follow the suggestion in the install to place the new wget in /usr/bin and then "ipkg remove wget".

Content Management Systems

  • CMSimple - http://www.cmsmadesimple.org/
  • CMS Made Simple - http://www.cmsimple.org/
  • Drupal - http://drupal.org/
  • Joomla - http://www.joomla.org/
  • MediaWiki - http://www.mediawiki.org/wiki/MediaWiki
  • MODx - http://modxcms.com/
  • Pixelpost - http://www.pixelpost.org/
  • Pixie - http://www.getpixie.co.uk/
  • TextPattern - http://www.textpattern.com/
  • WordPress - http://wordpress.org/
view · edit · print · history · Last edited by OddballHero.
Originally by OddballHero.
Page last modified on November 24, 2011, at 12:15 PM