Busybox httpd is good for simple static pages, now here is a tutorial for installing lighttpd and php with fastcgi support in the router. Here I choose lighttpd over Apache for its light cpu usage and small memory footprint.
Since all our software are based in /opt folder, some modification must be done to get everything working:
- Install php5 and lighttpd
To install php5 with fastcgi support, run
opkg install libsqlite3
opkg install php5-fastcgi
opkg install php5-modgd
Along with php5, the popular libgd module is also installed. Copy php.ini to its default location.
cp /opt/etc/php.ini /etc/php.ini
After that, test php installation by running:
php-cgi -v
You should see the version info and no warning/error message.
Install lighttpd and some modules
opkg install lighttpd
opkg install lighttpd-mod-fastcgi
opkg install lighttpd-mod-simple-vhost
- Modify php.ini
Edit /etc/php.ini
Find doc_root = "/www"(or whatever) and change it to doc_root = "/opt/www"
Find extension_dir = "/usr/lib/php" and change it to extension_dir = "/opt/usr/lib/php"
Find ;extension=gd.so and remove the leading semicolon, i.e., change it to extension=gd.so
Find ;date.timezone= , remove the leading semicolon and change it to
date.timezone = "America/New_York"
Replace the red part with yours, a full list is available here.
- Modify lighttpd.conf
With our installation, the configuration file for lighttpd is located at /opt/etc/lighttpd/lighttpd.conf. Edit this file:
First, enable mod_fastcgi and mod_simple_vhost:
Then
find server.document-root and change its value to "/opt/www"
find #server.port = 81 and change it to server.port = 81
This will set lighttpd server to listen port 81. If you want to use port 80, make sure to move the DD-WRT's web admin to another port, details here, step 1.
add following at the end of the file:fastcgi.server = ( ".php" => ((
"bin-path" => "/opt/usr/bin/php-cgi",
"socket" => "/tmp/php.socket"
))) - Lighttpd startup script
Create or edit file /opt/etc/init.d/lighttpd with below. Remove any previous contents if its not empty.
#!/bin/sh
source /mnt/root/.profile
BIN=lighttpd
LOG_D=/var/log/$BIN
RUN_D=/var/run
PID_F=$RUN_D/$BIN.pidCOND=$1
[ $# -eq 0 ] && COND="start"case $COND in
stop)
killall lighttpd
killall php-cgi
;;
start)
mkdir -p $LOG_D
mkdir -p $RUN_D
$BIN -f /opt/etc/lighttpd/lighttpd.conf -m /opt/usr/lib/lighttpd
;;
*)
exit 1
esac
Set it as a service
chmod a+x /opt/etc/init.d/lighttpd
ln -s /opt/etc/init.d/lighttpd /opt/etc/init.d/S80lighttpd - Test lighttpd server
First create the home folder
mkdir /opt/www
Then the test file /opt/www/phpinfo.php with contents below:
<?php
phpinfo();
?>
After that, launch lighttpd
/opt/etc/init.d/lighttpd
#to stop the lighttpd server, run /opt/etc/init.d/lighttpd stop
Open browser and navigate to http://router_ip:81/phpinfo.php to check the output.
38 comments:
To make the router more useful, how can we install MySQL 5 with Drupal 5 or MediaWiki 1.X under DD-WRT?
Hi, first of all thanks for all tutorials you have on your site, it is very helpful to me! ;)
Today a was looking for some Rapidshare, etc. download manager which will run thru PHP and I found this one http://www.networkedmediatank.com/showthread.php?tid=16833&page=1 . It seems very promising but I can't get it to work. I configured most of the things but now I'm stucked on SQLlite database which this manager using. Do you have any experiences with this manager or configuring SQLlite? I'm runing this on router TL-WR1043ND using DD-WRT. Thank you
It may have changed since this was published, but "opkg install php5-modgd" should be "opkg install php5-mod-gd".
And if you are installing sqlite, you may want to install the php support for it with "opkg install php5-mod-sqlite3"
Oh, and in addition to the above, remove the semicolon before "extension=sqlite3.so" in php.ini too.
Yeah I tried that but it seems that it need a database to be created but I don't know how to create it...
Does anybody know how to install mysql on this router?
I was able to install&use the phpXplore:
http://www.webxplorer.org/phpXplorer/www/
to install mysql server...
Openwrt contains mysql server in 10.03.1-rc4
1. update /etc/opkg.conf to
src/gz snapshots http://downloads.openwrt.org/backfire/10.03.1-rc4/ar71xx/package
dest root /opt
dest ram /tmp
lists_dir ext /tmp/var/opkg-lists
2. Run opkg update
3. Run opkg install mysql-server
4. modify /opt/etc/my.cnf to set the database variables, recommend to use my-small.cnf example from mysql
5. Run mkdir
6. Run mysql_install_db --defaults-file=/opt/etc/my.cnf --force
7. Replace /opt/etc/init.d/mysqld with...
#!/bin/sh
source /mnt/root/.profile
BIN=mysqld
RUN_D=/var/run
PID_F=$RUN_D/$BIN.pid
COND=$1
[ $# -eq 0 ] && COND="start"
case $COND in
stop)
start-stop-daemon -K -n $BIN
;;
start)
start-stop-daemon -p $PID_F -b -m -S -x $BIN -- --defaults-file=/opt/etc/my.cnf
;;
*)
exit 1
esac
8. set mysqld as service
chmod a+x /opt/etc/init.d/mysqld
ln -s /opt/etc/init.d/mysqld /opt/etc/init.d/S70mysqld
9. start mysqld by /opt/etc/init.d/mysqld start
10. remember to change root password by
mysqladmin --defaults-file=/opt/etc/my.cnf -u root password 'new-password'
11. after this, mysqld should be found in ps command. to enter mysql in console, run mysql --defaults-file=/opt/etc/my.cnf
Hi!
I tried out this tut and are nearly done.
All packages where installed successfully, but when i tried "php-cgi -v" I got a "Segmentation fault".
Deactivating "mod_fastcgi" made the lighttpd running without php.
How can I fix this? Is the only way to set up new partitions again? Or can there be also a different problem?
Thanks for your support so far!
I have followed the instructions on this site and installed transmission since last year. Currently, when I want to add lighttpd and mysql but when I tried to run opkg install I got an error that I have no space left, which probably mean that I have no write permission or so. However, I tried running opkg remove and it worked.
This is the response from opkg install:
"Installing busybox (1.17.3-2) to root...
Collected errors:
* verify_pkg_installable: Only have 0kb available on filesystem /opt/, pkg busybox needs 230
* opkg_install_cmd: Cannot install package busybox.
"
Sorry, but I don't really understand what's going on. What should I do to fix this?
I tried again and it worked today for no reason. Now, I have the same problem with henschwa. Segmentation fault...
For Heavy hand henschwa try downgrading ddw-rt to build 15962 when I went for this years build got all sorts of problems including this one. On reversion all was peachy. Hope this helps.
When I run /opt/etc/init.d/lighttpd i get a bus error i followed directions to a t so why isnt it working
mysql_install_db --defaults-file=/opt/etc/my.cnf --force
Could not find help file 'fill_help_tables.sql' in /usr/share/mysql or inside /usr.
any ideas?
Running from /mnt/opt/usr/share/mysql
gives a different error:
Didn't find /usr/lib/mysqld
You should do a 'make install' before executing this script
php/lighthttpd are running great. Thanks for the blog.
Thanks for this great tut!
Hi,
I tried very hard to install ipkg/opkg but failed miserably. Thus, I need to manually install all the required packages required by lighttpd, php5 and mysql.
Can you please help list down all the required dependencies for the packages that you have recommended in your post?
Currently Installed Packages
==============================
libsqlite3
php5-fastcgi
php5-modgd
lighttpd
lighttpd-mod-fastcgi
lighttpd-mod-simple-vhost
With the latest version calling lighttpd produces a bus error. Any suggestions?
Hello!
I get an error:
root@DD-WRT root $ /opt/etc/init.d/lighttpd
lighttpd: symbol 'errno': can't handle reloc type 0x2f
root@DD-WRT root $
i kept receiving "no input file specified" no matter what i do, anyone with the same problem??
Hi I have followed all the tutorial without encountering any problem except for, when I wanted to start the lightttpd server, I had received an error saying "Bus error"
root@DD-WRT root $ /opt/etc/init.d/lighttpd
Bus error
Any idea how to fix that?
Thank
Eric
Hi,
I cannot copy php.ini to /etc/php.ini as /etc is not writable for me. I guess that php-cgi is then not started with the php.ini file.
Content that you just created is extremely fascinating and helpful on behalf of me, I love it. Is also helpful for U.S. all.. Thanks
Read more information :- Brother Printer Technical Support
Thanks for sharing this blog.This is very helpful and solving problems easily related to router problems. Good work. Please visit this link ----- Linksys Router Technical Support .
I have router running busybox, it support 32GB SD Card and 500GB of SSD. I want to host my WordPress websites on this router for local users to access. I do not have any linux knowledge. Can anyone assist me on this? I would be ready to pay for this.
Thanks for providing this nice blog
Routerlogin
Routerlogin Net
Thanks For Sharing With Us. It's Very Informative Post Keep It Up.
Google Chrome Technical Support
I got the Best Carpet Cleaning Services from you and found it Very helpful and effective. Your Professionals were Experienced and skilled in the Service. Click here on https://www.back2newcleaning.com.au/carpet-cleaning-sydney to know about their Service.
Best 1 Cleaning was established over 15 years and operates as the leading carpet cleaning service in Brisbane, Ipswich, Gold & Sunshine Coast. Our clients are covered with full public liability insurance and all our cleaning products are environmentally friendly.
Visit : https://www.best1cleaning.com
Best Carpet Cleaning service in Brisbane is Best1Cleaning. Best 1 Cleaning was established over 15 years and operates as the leading carpet cleaning service in Brisbane, Ipswich, Gold & Sunshine Coast. Our clients are covered with full public liability insurance and all our cleaning products are environmentally friendly.
Sage 50 Technical Support Number
Sage 100 Technical Support Number
Sage 50 live chat
Sage 50 Technical Support phone Number
Sage 50 customer service number
Sage 50 payroll support number
If you are new user to sage 50 accounting software and looking for the sage 50 technical support.If yes than you have come to right place as we provide efficient technical support service to customers who show complete faith in us. With our efficient and highly qualified team ,we never disappoint our customers.You can reach us at 1800-910-4754 at any hour of the day. You can also visit our website at https://www.geekaccounting247.com/ for the complete knowledge of the sage products and services.
The Services we offered are following-
Sage 50 update support
Sage 50 customer support
Sage 50 upgrade support
Sage 100 support
Sage 50 support
Unlock Extratorrent
Extratorrent and Mirror sites
Extratorrent unlock
ET Proxy Sites
Extratorrent Proxy websites
unblock Extratorrent
Unlock the extratorrent
How to Activate Twitch channel on Roku?
If you are new to the Roku streaming platform, select the best device among Roku Express, Express Plus, Premiere, and Premiere plus. Complete the setup and then navigate to the store. Add the channel to find the activation code. This code must be provided on the page, Twitch.tv/activate. Sign with the Twitch TV channel account, if required. If you are expecting any help to complete Twitch TV channel activation, talk to our network support team by dialing our number +1-855-718-4111 and you can visit our site twitch.tv/activate
YouTube TV channel activation guide
You can select the compatible device, add the channel, and then proceed with the settings to collect the activation code. This code must be provided on the page Sign in with the channel account, if necessary. For help and support to execute YouTube TV channel activation, please visit our portal tv.youtube.com/activate
Learn what to do if QuickBooks outlook is not responding while managing your financial work.
Read more: https://asquarecloudhosting.com/fix-quickbooks-outlook-is-not-responding-error/
bittorrent pro crack software is one of the most popular torrent programs that can easily download torrent files. BitTorrent Pro compared to similar software.
bittorrent crack is one of the main tools of Peer 2 Peer networks. Torrent is a network for sharing files between various computers using special software. Using search engines that have these files on your destination computers, you can get the file you want and get it with software like BitTorrent etc.
winrar full crack
Very wonderful informative article. I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks!
theeducationlife
geteducationskills
educationisaround
Post a Comment