恩山无线论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 7562|回复: 12

WZR-HP-G300NH dd-wrt mysql 安装问题

[复制链接]
发表于 2010-8-1 15:26 | 显示全部楼层 |阅读模式
我的步骤:
1、格式化U盘为Ext3格式。
2、dd-wrt启动命令

  1. mount /dev/scsi/host0/bus0/target0/lun0/part1 /jffs
  2. export LD_LIBRARY_PATH=/jffs/lib:/jffs/usr/lib:/jffs/usr/local/lib
  3. cp -p -r -f "/etc" "/jffs"
  4. sleep 15
  5. mount /jffs/etc /etc
  6. /jffs/etc/init.d/lighttpd
复制代码
3、将编译好的lib放在/jffs/lib目录下,下载
opkg_528-1_ar71xx.ipk
,上传到/jffs/tmp目录下
4、安装opkg_528-1_ar71xx.ipk

  1. ipkg install opkg_528-1_ar71xx.ipk
复制代码
有提示错误,可不理会。
5、更新/jffs/etc/opkg.conf文件为以下内容:

  1. src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
  2. dest root /jffs
  3. dest ram /tmp
  4. lists_dir ext /tmp/var/opkg-lists
复制代码
6、更新opkg清单列表:

  1. opkg update
复制代码
7、安装php5 and lighttpd

  1. opkg install libsqlite3 php5-fastcgi php5-mod-gd
  2. opkg install lighttpd lighttpd-mod-fastcgi lighttpd-mod-simple-vhost
  3. mkdir /jffs/www
复制代码
8、配置php.ini

  1. 编辑 /etc/php.ini
  2. 查找 doc_root = "/www"(也许不是这样) 修改为doc_root = "/jffs/www"
  3. 查找 extension_dir = "/usr/lib/php" 修改为extension_dir = "/jffs/usr/lib/php"
  4. 查找 ;extension=gd.so 删除前面的注释,比如修改为extension=gd.so
  5. 查找;date.timezone= ,  删除前面的注释,比如修改为date.timezone = "Asia/Shanghai"
  6. 这里视你的地区而定,看这里:http://www.php.net/manual/en/timezones.php
复制代码
9、配置lighttpd.conf
在我这个例子中lighttpd的配置文件位于 /jffs/etc/lighttpd/lighttpd.conf
首先允许 mod_fastcgi 和 mod_simple_vhost::
如图:
lighttpd-module-enable.gif
找到 server.document-root  把它的值改为“/jffs/www”
假如你的路由器使用80端口管理,那你得修改 #server.port = 81 删除前面的注释,比如 server.port = 81
接着来:
在lighttpd.conf文件适当的位置(可以是末尾)加上这段代码:

  1. fastcgi.server = ( ".php" => ((
  2.                      "bin-path" => "/jffs/usr/bin/php-cgi -c /jffs/etc/php.ini",
  3.                      "socket" => "/tmp/php.socket"
  4.                  )))
复制代码
这里要说明一下:

  1. -c /jffs/etc/php.ini
复制代码
它的意思是指定php.ini的位置。本例中,可以省略。
11、修改Lighttpd运行脚本:
如果你的环境跟我的不同,不要照搬。删除这个文件原有内容,正确内容如下,

  1. #!/bin/sh

  2. BIN=lighttpd
  3. LOG_D=/var/log/$BIN
  4. RUN_D=/var/run
  5. PID_F=$RUN_D/$BIN.pid
  6. COND=$1
  7. [ $# -eq 0 ] && COND="start"

  8. case $COND in
  9. stop)
  10.   killall lighttpd
  11.   killall php-cgi
  12.   ;;
  13. start)
  14.   mkdir -p $LOG_D
  15.   mkdir -p $RUN_D
  16.   $BIN -f /jffs/etc/lighttpd/lighttpd.conf -m /jffs/usr/lib/lighttpd
  17.   ;;
  18. *)
  19.   exit 1
  20. esac
复制代码
12、测试lighttpd服务
创建文件/jffs/www/phpinfo.php 如:

  1.   <?php phpinfo(); ?>
复制代码
启动lighttpd 命令/jffs/etc/init.d/lighttpd
停止lighttpd 命令/jffs/etc/init.d/lighttpd stop
用浏览器打开

  1. http://router_ip:你的http端口/phpinfo.php
复制代码
顺利的话你能看到php信息。
-------------------------------------------------------------------------分割线-------------------------------------------------------------------------
问题来了,我安装mysql了,但是不知道如何创建root和密码。请高手指点一下:
我的安装脚本是:

  1. opkg install php5-mod-mysql
复制代码
安装完毕没有提示我输入root的密码,请问如何触发这个操作?
我的恩山、我的无线 The best wifi forum is right here.
发表于 2010-8-1 18:04 | 显示全部楼层
没用过opkg做包管理,参考下面文章看看吧

https://www.right.com.cn/forum/v ... amp;page=1#pid66183
我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2010-8-1 19:10 | 显示全部楼层
没用过opkg做包管理,参考下面文章看看吧

https://www.right.com.cn/forum/v ... amp;page=1#pid66183
noisyle 发表于 2010-8-1 18:04

感谢回复。不过他用的是mipsel包,而我这里不能用这种包,只能用mips包。郁闷。
我的恩山、我的无线 The best wifi forum is right here.
发表于 2010-8-1 19:20 | 显示全部楼层
路由器跑mysql做什么哦?php博客吗?
我的恩山、我的无线 The best wifi forum is right here.
发表于 2010-8-1 19:23 | 显示全部楼层
架构虽然不同,估计代码是相似的吧,他的步骤是
1、运行init.d下的启动脚本,启动mysql的守护进程
2、使用mysqladmin 工具设置root的密码
3、用root用户登录mysql

这个是否可以借鉴?
我的恩山、我的无线 The best wifi forum is right here.
发表于 2010-8-1 19:26 | 显示全部楼层
默认应该是空密码
我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2010-8-1 21:08 | 显示全部楼层
架构虽然不同,估计代码是相似的吧,他的步骤是
1、运行init.d下的启动脚本,启动mysql的守护进程
2、使用mysqladmin 工具设置root的密码
3、用root用户登录mysql

这个是否可以借鉴?
noisyle 发表于 2010-8-1 19:23

现在是没有可以运行的mysql的守护进程,搜索了一下整个文件系统无法找到,编译又太过麻烦。
我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2010-8-1 21:09 | 显示全部楼层
默认应该是空密码
luyi1234 发表于 2010-8-1 19:26

用户名试过root,密码为空。不行。
我的恩山、我的无线 The best wifi forum is right here.
发表于 2012-2-22 07:23 | 显示全部楼层
不知道搞好了吗?转一篇资料给你看看
Have you ever wanted to have additional functionality like Email, Bit-torrent or even MySQL directly on your router? Well maybe now you can. How-To Geek dives into how-to install Opkg software on DD-WRT.

Image by Jean Spector and Aviad Raviv

If you haven’t already, be sure and check out previous articles in the series:

Turn Your Home Router Into a Super-Powered Router with DD-WRT
How to Remove Advertisements with Pixelserv on DD-WRT
Assuming you are familiar with those topics, keep reading. Keep in mind that this guide is a little more technical, and beginners should be careful when modding their router.

Tribulations
I’ve recently bought a new Buffalo WZR-HP-AG300H which comes with a re-branded version of DD-WRT. Due to the fact that this router has a USB port, I immediately connected an HD and tried to use the “Optware, The Right Way” wiki guide. Unfortunately I’ve quickly found that the router that I got, is Atheros based and the script from that wiki page, doesn’t support it. So I’ve started digging (as i always do) and came across several guides (1, 2, 3 and 4) that aimed to explain how to get Opkg working manually. While their contribution (among other sources on the web) to this guide was invaluable, some of the instructions are (IMHO) simply not straight forward enough. For example, giving you the “lib” files fish, but don’t teach you how to fish it from the source. Also having to make use of a Linux formatted HD or at least a partition of one (which actually doesn’t even work on the firmwares I’ve tested with). That is why, I felt the need to create the below concise, simple to follow and reproducible procedure for getting the OpenWRT Opkg package manager to work on such routers.

Update: The mounting partitions capability has been reintroduced into the re-branded version on the 17798 alpha build.

What is Opkg?
Opkg is a package manager like apt/aptitude and yum. It acts as a replacement for the Ipkg package manager, and can be used to install software such as: the Transmission BitTorrent daemon, the ssmtp email sender and Knockd a daemon that execute scripts after a specified port triggering sequence, to name a few. From the OpenWRT site:

The opkg utility (an ipkg fork) is a lightweight package manager used to download and install OpenWrt packages from local package repositories or ones located on the Internet. Opkg attempts to resolve dependencies with packages in the repositories – if this fails, it will report an error, and abort the installation of that package.

So using Opkg we can install things like we did with Ipkg on the “Unleash Even More Power from Your Home Router” guide. The major differences, are:

In order to give the examples of SSMTP and Knockd, yours truly, had to figure out the dependencies manually. The procedure to do this manually is bothersome and not very straight forward. Opkg does this automatically.
This time we will be adding software on top of the firmware that’s in place, rather then replacing it. While replacing it was an excellent geek exercise, it was without a doubt: dangerous, prone to problems, irreversible and worst of all router specific. Needless to say that this is way simpler and safer.
Prerequisites
In order to complete this guide note the following:

As stated above, this guide was created and tested on Buffalo WZR-HP-AG300H with Buffalo’s “Pro” firmware version 17135. It should work on any Atheros (ar71xx) based routers with any version of DD-WRT of the same revision or above, but your mileage may very.
You will need to enable SSH on the router, as well as install and use WinSCP  to connect to it. This was explained in the “How to Remove Advertisements with Pixelserv on DD-WRT” guide. In fact, it will be assumed that you are able to do everything that is explained in that guide.
You need to be able to connect to the router using a terminal (SSH is recommended). Some pointers on how to do this, are on the DD-WRT wiki.
Space for JFFS and about 4MB of post formatted space for the base setup. JFFS space is not only a prerequisite, it is a show stopper. This is because, If your router doesn’t have at least the above mentioned 4MB of post formatted space, you will not gain any real benefit from this guide, and will be better off using the “Unleash Even More Power from Your Home Router” guide to install Ipkg packages directly into the firmware or installing the Ipkg packages manually. Follow the instructions on the “How to Remove Advertisements with Pixelserv on DD-WRT” guide to enable JFFS, and see how much free space you actually have after it is formatted.
Note: It is possible to do this with only 2MB of space for the setup, but then we would lose the upshot of “/etc” becoming read-writable and would have to invoke Opkg, while specifying the configuration file manually every time… which is like sooo lame…  

Lets get cracking
At this point you should have enabled JFFS and are able to SSH/WinSCP into the router.

Open a terminal session to the router.
Create a temporary directory that we will be working in:

mkdir /tmp/1
cd /tmp/1

Use Ipkg to install Opkg
While we are going to replace Ipkg as the package manager, we will be using it to manually install the Opkg installation package.

To do this, download the Opkg installation package for the ar71xx architecture from the OpenWRT project trunk:

wget http://downloads.openwrt.org/sna ... kg_618-2_ar71xx.ipk

Note1: At the time of this writing, 618 is the latest version, this may be subject to change in the future, so adjust accordingly.
Note2: It may be possible that the only difference in getting this guide to work for other architectures is to get the Opkg installer from the applicable architecture for your router… however this is untested by yours truly.

Invoke Ipkg to manually install Opkg using:

ipkg install opkg_618-2_ar71xx.ipk
我的恩山、我的无线 The best wifi forum is right here.
发表于 2012-2-22 07:23 | 显示全部楼层

Note: You can, if you wanted too, install every package in the repository manually this way. However this would mean that you will have to resolve the dependencies on your own… and what would be the fun in that?

Obtaining the dynamic library files (“lib”s)
The required “lib” files to make Opkg work, are part of the OpenWRT distribution. To obtain them, one has to extract them from the “Root FileSystem” of said distribution.

To do This, download the latest basic “Root FileSystem” for the openWRT distrebution which containes the required “lib”s from the OpenWRT project trunk:

wget http://downloads.openwrt.org/sna ... neric-rootfs.tar.gz

Extract it using:

tar xvzf openwrt-ar71xx-generic-rootfs.tar.gz

Copy the “libs” files from the “rootfs” we’ve extracted above to the “libs” directory on our JFFS, while preserving their attributes and symbolic links:

cp -Pp /tmp/1/lib/* /jffs/usr/lib/

Note: You will get messages saying that the sub-directories are being omitted. As we don’t need anything but the “lib” files, this is fine and you can safely ignore these messages.

Fixing the LD_LIBRARY “PATH”
We need to tell the router, where to look for the shared libraries (libs) we’ve just “installed” and that it needs to do this before the ones that came with the firmware.

To do this set the LD_LIBRARY environment variable manually (for now), to make it so the location where we copied the new lib files will be the first one in the “PATH”:

export LD_LIBRARY_PATH=/jffs/usr/libLD_LIBRARY_PATH

Read-writable “/etc”
We are going to copy “/etc” to JFFS and then make the regular “/etc” mount point, point to it. Doing so, will both open up a world of possibilities, because “/etc” will become read-writeable (which I personally have been waiting for give or take 7 years now) and enable packages that expect this behavior, to work correctly.

Create the directory that will hold “/etc”:

mkdir -p /jffs/geek/etc

Recursively copy the entirety of “/etc” while preserving all subdirectories, file attributes and symbolic links.

cp -a /etc/* /jffs/geek/etc/

Manually (for now) “bind mount” the “/etc” directory to the JFFS one:

mount -o bind /jffs/geek/etc/ /etc/

Set the Optware directory (“/opt”)
Opkg from OpenWRT, expects to be used when the router’s firmware is built. As at such time, the FileSystem isn’t on the router yet, and thus still subject to change, there is no problem installing to any location on the FileSystem. That is why the Opkg configuration file points packages to install to the “root” (/) of the FileSystem. However, we are using Opkg after the firmware was built and installed on the router, and as we can’t change the root of the filesystem to be read-writeable, we will point all installations to be installed under “/opt”. However Currently “/opt” also points to a read-only location on the router’s firmware. To overcome this, we will make “/opt” point to JFFS, which is read-writable.

To do this, Create the directory that will contain the Optware packages:

mkdir -p /jffs/opt

Manually (for now) “bind mount” the “/opt” directory to the JFFS one:

mount -o bind /jffs/opt/ /opt/

Note: While beyond the scope of this guide, more advanced users may want to change this mount point, to point to an HD.

Adjusting the Opkg configurations file
We want the Opkg configuration file to be where Opkg searches for it by default (which is “/etc”) and adjusted to install to “/opt”.

To do this, move the opkg configuration file installed by the Opkg package to the read-writable “/etc” location:

mv /jffs/etc/opkg.conf /etc/

Change the destination for Optware installations to be “/opt” instead of “root” (/).
To do this, with the “vi” editor or WinSCP navigate to “/etc/” and make the “opkg.conf” file’s content:

vi /etc/opkg.conf

Make it look like:

src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
dest root /opt
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay

Note: You can change the “lists_dir” directive to point to a location that isn’t in RAM, but rather on JFFS. While this would relieve you from updating the lists, before you can install additional software (if your router is rebooted from the last time), you would lose about 1.5MB of the scarce JFFS space and you would be compounding to its erosion.

Hello baby
You should be able to see that Opkg is working by issuing the update and lists commands.

If all went well you should be seeing that the Opkg lists have been updated without error and you are ready to implement the script in the next step:

opkg update; opkg list

Take the time to start exploring the packages available on the repository….
StartUp script
We now need to make it so all of the required mounting and path-ing will happen automatically when the router boots. To that end, we’ve created for you, this initialization geek-init script.

Download, then extract it and place it under “/jffs/geek/etc/”. (Consider doing this with WinSCP).
Make the script executable by going into its properties with WinSCP or executing:

chmod +x /jffs/geek/etc/geek-init.sh

Make the script execute on the router’s startup, using the WebGUI. Under Administration -> Commands, in the text box, put:

/jffs/geek/etc/geek-init.sh web-gui

And Click “Save Startup”.

Kicking the tires
If all went well, you should now be able to reboot the router and still use the Opkg package manager. That is to update, list and install applications.
Lets test that everything is working by installing the “netstat” command, which for some reason has been omitted from DD-WRT’s builds lately. Before we do this, execute the netstat command in the terminal and you will see that you’re grated by an error from the shell, saying “-sh: netstat: not found”.

Your first step will always be, to update the Opkg lists, as to have the latest packages listing from the repository:

opkg update

If you don’t know which package contains the “netstat” command, you can filter the results using.

opkg list | grep netstat

And now install “netstat” using:

opkg install net-tools-netstat

And now, when you execute the netstat command again it works… neat ha?

Until the future articles in which we will install and configure software packages using this method, may you have tons of geek fun exploring the vast amount of software that is now right at your finger tips.


我的恩山、我的无线 The best wifi forum is right here.
发表于 2012-2-22 07:31 | 显示全部楼层
  1. 用户名试过root,密码为空。不行。
复制代码
实在不行就COPY一份用户和密码文件覆盖原文件 看看可行吗
我的恩山、我的无线 The best wifi forum is right here.
发表于 2012-2-28 21:32 | 显示全部楼层
关注一下。。。
我的恩山、我的无线 The best wifi forum is right here.
发表于 2012-5-28 08:59 | 显示全部楼层
学习了。。。谢谢楼主分享。。。
我的恩山、我的无线 The best wifi forum is right here.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )|网站地图

GMT+8, 2020-9-20 05:36

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表