this how-to can be found on my website also: http://wpte.kicks-ass.net/forum/view...p?thread_id=14
Change-log
Code:
11-07-09 Added clean-up for lighttpd so it always start after a reboot.
11-07-09 Activated PEAR in php.ini
31-07-09 Fixed mysql starting under non-root user
21-09-09 Fixed possible insecurity for the www folder
21-09-09 Added fix for TraceWatch web counter ip2country database update
20-11-09 Added update for possible lighttpd version 1.4.24-1 problems
12-03-10 Updated a lot of messy unclear stuff
12-03-10 Updated eaccelerator howto because of a new stable version
12-03-10 Added ipkg eaccelerator howto for the ones that don't like building after a php update
12-03-10 Include the ipkg update and upgrade parts so users won't download old software
10-09-10 Massive cleanup and bug fixing because of ipkg package fixes:
MySQL starting, php-fcgi, eaccelerator
Introduction
First of all, you might wonder what all these packages are...
lighttpd: quite a famous web-server used by a few well known sites like youtube (yes youtube), mininova and thepiratebay! (see the whole list: http://redmine.lighttpd.net/wiki/lig...eredByLighttpd)
php: probably the most used web-based scripting language
MySQL: Free database software, also widely used in combination with php and CMS packages.
Eaccelerator: a free open-source PHP accelerator, optimizer, and dynamic content cache.
So there are some how-to's out there already about these packages, but they are not really that complete, or contain some old unfixed things.
What do you need?
1. A valid wengi-like ipkg installation
2. Build enviroment if you want to build eaccelerator (no worries, this will be explained newbie proof)
3. A few ipkg packages
4. Eaccelerator source code if you want to build eaccelerator
5. knowledge of basic linux stuff
6. about 300mb free optware space
7. enough swap space (About 15mb swap free)
Installation: Lighttpd
Well, lets start of easy by typing:
ipkg update
ipkg upgrade
ipkg install lighttpd
this will install the basic lighttpd package.
When done enter:
vi /opt/etc/lighttpd/lighttpd.conf
now edit the following lines:
(note: uncomment means remove the # in the beginning of the line)
Code:
line 40: change
server.document-root = "/tmp/harddisk/www"
(presuming you have the same mount point as in wengi's)
This is for fixing the excluded e-poll:
line 51: change
# server.event-handler = "freebsd-kqueue" # needed on OS X
into
server.event-handler = "poll" # needed on OS X
Code:
line 139: change
server.port = 8081
into:
server.port = 80
(changing the webinterface port will be explained later)
and save it!
now create the folder where your web pages will be saved (remember this)
mkdir /tmp/harddisk/www
chmod 744 /tmp/harddisk/www
By installing php-fcgi, the fast-cgi server will be enabled automatically, so there is no need of manually uncommenting the settings anymore.
Because we want to host our web pages on the standard port of 80, we need to change the port of the web interface, since this is also hosted on port 80.
When someone thinks he can change it by doing portforwarding or virtual server... yeah, you can but you most likely get problems with cookies (and that isn't nice).
changing the port:
Code:
nvram set http_lanport=8080
nvram commit
after a reboot you will need to access the web interface by this url:
http://your-asus-router-ip:8080
Installation: php with some extensions
To be sure you are as covered as you can on this router, you can just add all the php packages available:
ipkg install php php-curl php-dev php-fcgi php-gd php-imap php-ldap php-mbstring php-mysql php-pear php-xmlrpc
activate pear:
Code:
Line 426:
change the lines into this:
; UNIX: "/path1:/path2"
include_path = ".:/opt/lib/php/extentions:/opt/share/pear"
Save the file
as you will notice it will also install mysql, since we don't have to do anything for php yet lets move on to mysql!
Installation: MySQL
now we have mysql installed and started we have to set a password.
use this command:
/opt/bin/mysqladmin -u root password 'secretpassword'
note: leave the '' in the command, otherwise mysql won't understand!
edit the my.cfg again to add the password for automatic login when you're in shell.
Code:
line 20: uncomment and type your password
password = yourpassword
ofcourse change "yourpassword" into something you want to use as password!
end result:
[client]
password = secret
port = 3306
socket = /tmp/mysql.sock
save it!
now type:
and you will enter the mysql console, which is important to control your mysql server!
a few handy commands:
Code:
Create a database = create database mydatabase;
Remove a database = drop database mydatabase;
select a database to use = use mydatabase;
import sql queries = source /some/sql/file.sql;
exit the prompt = exit;
for more commands please read the mysql manual.
Installation: Eaccelerator
In this how-to you can choose which eaccelerator you want.
The ipkg version is for people who don't want to worry about manually updating the php extension.
for now the build-your-own eaccelerator is more up to date.
(just pick the installation you prefer)
Installation: IPKG Eaccelerator
The worry-less installation
ipkg install eaccelerator
follow the final steps in "FINAL STEPS"
Installation: OWN-BUILD Eaccelerator
for the die-hards (still it's simple to follow)
Don't forget to update eaccelerator when php receives an update
first of all we need the build environment, which takes a while to download:
ipkg install wget optware-devel buildroot
you'll probably receive an error like:
Code:
Collected errors:
ERROR: The following packages conflict with wget-ssl:
wget
don't worry, wget-ssl is reported as not working here, and wget is working just as well
while you are downloading everything, lets get the sources:
http://bart.eaccelerator.net/source/...-0.9.6.tar.bz2
(at this moment this is the latest version, you may download a newer version if available)
Just save the file to your pc, unpack it somewhere and place it on your router via samba share or ftp. Lets say you place the folder into /tmp/harddisk/eaccelerator-0.9.6
after the ipkg package installation is done, you can continue:
Before we start building, we need to install some libraries required by eaccelerator:
now lets get to the real building stuff:
cd /tmp/harddisk/eaccelerator-0.9.6
export PHP_PREFIX="/opt"
$PHP_PREFIX/bin/phpize
./configure --prefix=/opt --enable-eaccelerator=shared --with-eaccelerator-disassembler --with-eaccelerator-userid
make
make install
please execute these command 1 at a time, to make sure everything goes well!
you shouldn't get any errors... (don't pay too mutch attention to the configure command, unless it tells you there is an error in the end)
note that make test is not possible and not required.
after you executed make install, the files are in place, ready to be used.
Now we only need to create a php configuration file.
vi /opt/etc/php.d/eaccelerator.ini
and copy paste this into the file
Code:
;;EACCELERATOR
;;the settings for eaccelerator
extension=eaccelerator.so
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/opt/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="3"
save the file and execute the final commands to create the cache dir:
mkdir -p /opt/tmp/eaccelerator
chmod 777 /opt/tmp/eaccelerator
FINAL STEPS
lets create a file to test everything after the reboot:
vi /tmp/harddisk/www/index.php
and enter the code:
Code:
<?php
phpinfo();
?>
save it,
chmod 766 /tmp/harddisk/www/index.php
and done you are, just a final reboot to restart everything properly:
after the reboot you can visit http://your-asus-router/
and you should get a page with information about the php installation... something you shouldn't get is a http 500 error.
if you get this error here, please look over the how-to again, because you might have missed something.
It is however possible that not all web packages work in this set-up, which is unfortunate, but there is no other option than find an alternative web package.