Sunday, January 19, 2014

Install Lighttpd/PHP5/MySQL on PogoPlug or Dockstar running Debian


I wanted to set up a PogoPlug with an HTTP(S) server, PHP support and MySQL so I can use it for logging my home automation data (e.g. energy usage).

I had already installed Debian Wheezy on the PogoPlog E02 (See my previous post).

Since the Seagate Dockstar has the same CPU as the PogoPlug E02, these instructions should also work for the Dockstar.

For the most part I followed the instructions here: Installing Lighttpd With PHP5 (PHP-FPM) And MySQL Support On Debian Wheezy

1. install MySQL
apt-get install mysql-server mysql-client

Note:
Probably a good idea to enter a root password for MySQL when asked.

Note2:
Unfortunately, this install hung on the message "InnoDB: using native Linux AIO".
I had to reboot the server and then run
dpkg --configure -a to finish the installation, which went fine after that.


2. install lighttpd
apt-get install lighttpd


3. install PHP5, PHP5 FPM (FastCGI Process Manager) and related PHP modules
apt-get install php5 php5-fpm php5-mysql php5-cli php5-xcache


4. configure lighttpd to use fastcgi and php5-fpm (more details: http://www.howtoforge.com/installing-lighttpd-with-php5-php-fpm-and-mysql-support-on-debian-wheezy)

- edit the /etc/lighttpd/conf-enabled/15-fastcgi-php.conf file to use the FPM (replace the existing content which uses php-cgi with this):
## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server += ( ".php" =>
    ((
        "socket" => "/var/run/php5-fpm.sock",
        "broken-scriptfilename" => "enable"
    ))
)


- enable the modules
lighttpd-enable-mod fastcgi 
lighttpd-enable-mod fastcgi-php 

- reload lighttpd
/etc/init.d/lighttpd force-reload

- edit the /etc/php5/fpm/php.ini file, uncomment the line:
cgi.fix_pathinfo=1

- reload FPM
/etc/init.d/php5-fpm reload

5. configure URL rewriting for lighttpd
- edit /etc/lighttpd/lighttpd.conf to add the url.rewrite section based on your needs

6. configure SSL for lighttpd

- create a self-signed certificate
apt-get install openssl

mkdir /etc/lighttpd/cert


cd /etc/lighttpd/cert


openssl req -new -x509 -keyout midnightcoding.pem -out midnightcoding.pem -days 365 -nodes


chmod 600 /etc/lighttpd/cert


lighttpd-enable-mod ssl


- edit the ssl configuration file
vi /etc/lighttpd/onf-available/10-ssl.conf

- change the line with ssl.pemfile to point to the path /etc/lighttpd/cert/midnightcoding.pem


7. install phpMyAdmin (optional)

apt-get install phpmyadmin

(select lighted as the web server for phpMyAdmin)


8. get phpmyadmin and other url rewrite rules to play nice

- url.rewrite overwrites the alias.url used by phpmyadmin in /etc/lighttpd/conf-enabled
  -> need to add a special rule to pass along  phpmyadmin urls "as-is"

url.rewrite-if-not-file = (
     "^/(phpmyadmin)/(.*)" => "$0",     
     "^/([^?]*)(\?.*)?$" => "/$1.php$2"
)



Now you should be able to access your server at:
https://[YOUR-SERVER-IP]/phpmyadmin




4 comments:

Saro said...

I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog. 
rpa training in bangalore
best rpa training in bangalore
RPA training in bangalore
rpa course in bangalore
rpa training in chennai
rpa online training

Mounika said...

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post I would like to read this
python Online training in chennai
python Online training in bangalore
python interview question and answers

aarthi said...

Thank you midnight coder for sharing the knowledge of mysql.
Java training in Chennai

Java training in Bangalore

Java training in Hyderabad

Java Training in Coimbatore

Java Online Training

lakshmik7410 said...

Great thanks for the sharing of the blog page ! it was very useful

data science training in chennai

ccna training in chennai

iot training in chennai

cyber security training in chennai

ethical hacking training in chennai