A. openwrt系统web环境PHP和Mysql怎么运行
openwrts系统,VB环境下,这个php,和MSPL他们是怎么样的运行的,希望啊,有这方面的,电脑工程师或者爱好有爱好发烧者可以解答一下。
B. 如何在OpenWRT环境下做开发
1、搭建开发环境
首先,在执行make menuconfig后,会出现下图:
其中,图中红框部分是我定制路由器的系统版本,大家可以根据不同的路由器进行不同的选择;绿框部分表示我们需要编译一个SDK开发环境(默认情况下,此项未勾选)。
编译过程中需要通过官网下载很多相关的软件包,所以必须保证能够顺利连上外网。由于下载速度的限制,编译过程大概需要数小时。编译结束后,所有的产品都会放在编译根目录下的bin/yourtarget/. 例如:我所编译的产物都放在./bin/brcm47xx/下,其中文件主要有几类:
(1).bin/.trx 文件: 这些都是在我们所选的target-system的类别之下,针对不同路由器型号、版本编译的路由器固件。这些不同路由器的型号和版本是openwrt预先设置好的,我们不需要更改。至于.bin和.trx的区别,一种说法是,第一次刷路由器的时候,需要用.bin文件,如果需要再升级,则不能再使用.bin文件,而需要用.trx文件。原因是,.bin是将路由器的相关配置信息和.trx封装在一起而生成的封包,也就是说是包含路由器版本信息的.trx。在第一次刷固件的时候,我们需要提供这样的信息,而在后续升级时,则不再需要,用.trx文件即可。
(2)packages文件夹: 里面包含了我们在配置文件里设定的所有编译好的软件包。默认情况下,会有默认选择的软件包。
(3)OpenWrt-SDK.**.tar.bz2: 这个也就是我们定制编译好的OpenWRT SDK环境。我们将用这个来进行OpenWrt软件包的开发。例如,我所编译好的SDK环境包为:/bin/brcm47xx/OpenWrt-SDK-brcm47xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.30.1.tar.bz2
可以从名称上看出,target system是brcm47xx,host system是Linux-x86_64,使用的编译工具以及库是4.3.3+cs_uClibc-0.9.30.1。
(4)md5sums 文件: 这个文件记录了所有我们编译好的文件的MD5值,来保证文件的完整性。因为文件的不完整,很容易将路由器变成“砖头”。
需要主要的是,编译完成后,一定要将编译好的bin目录进行备份(如果里面东西对你很重要的话),因为在下次编译之前,执行make clean 会将bin目录下的所有文件给清除掉!!
2、 更改原有packages
在编译根目录下会有一个dl的目录,这个目录其实是“download”的简写,在编译前期,需要从网络下载的数据包都会放在这个目录下,这些软件包的一个特点就是,会自动安装在所编译的固件中,也就是我们make menuconfig的时候,为固件配置的一些软件包。如果我们需要更改这些源码包,只需要将更改好的源码包打包成相同的名字放在这个目录下,然后开始编译即可。编译时,会将软件包解压到build_dir目录下。
当然,你也可以自己在dl里面创建自己的软件包,然后更改相关的配置文件,让openwrt可以识别这个文件包。
由于我的项目更改的内容是底层的,需要跟固件一起安装。所以,我使用的方法就是直接更改dl目录下软件包,然后重新进行固件编译。感觉类似于Linux的内核编译。反复编过十多次,没有任何问题。
3、 新建自己的packages
对于自己新建的package,而这个package又不需要随固件一起安装,换句话说,就是可以当做一个可选软件包的话。我们可以利用我们的SDK环境来单独编译,编译后会生成一个ipk的文件包。然后利用 opkg install xxx.ipk 来安装这个软件。
下面具体说下,如何编译一个helloword的软件包。
(1)首先,编写helloworld程序
编写helloworld.c
/****************
* Helloworld.c
* The most simplistic C program ever written.
* An epileptic monkey on crack could write this code.
*****************/
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("Hell! O' world, why won't my code compile?
");
return 0;
}
编写Makefile文件
# build helloworld executable when user executes "make"
helloworld: helloworld.o
$(CC) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o: helloworld.c
$(CC) $(CFLAGS) -c helloworld.c
# remove object files and executable when user executes "make clean"
clean:
rm *.o helloworld
在这两个文件的目录下,执行make 应该可以生成helloworld的可执行文件。执行helloworld后,能够打印出“Hell! O' world, why won't my code compile?”。 这一步,主要保证我们的源程序是可以正常编译的。下面我们将其移植到OpenWRT上。
(2)将OpenWrt-SDK-brcm47xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.30.1.tar.bz2解压
tar –xvf OpenWrt-SDK-brcm47xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.30.1.tar.bz2
(3)进入SDK
cd OpenWrt-SDK-brcm47xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.30.1
可以看到里面的目录结构跟我们之前source的目录结构基本相同,所需要编译的软件包,需要放置在package目录下
(4)在package目录下创建helloworld目录
cd package
mkdir helloworld
cd helloworld
(5)创建src目录,拷贝 helloworld文件
mkdir src
cp /home/wrt/test/helloworld.c src
cp /home/wrt/test/Makefile src
(6)在helloworld目录下创建Makefile文件
这个Makefile文件是给OpenWRT读的,而之前写的那个Makefile文件是针对helloworld给编译其读的。两个Makefile不在同一层目录下。
touch Makefile
vim Makefile
Makefile文件模板内容如下:
##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to
# specify a basic description of the package,
# where to build our program, where to find
# the source files, and where to install the
# compiled program on the router.
#
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and
# there should be no trailing whitespace in
# lines that are not commented.
#
##############################################
include $(TOPDIR)/rules.mk
# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1
# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
# Specify package information for this program.
# The variables defined here should be self explanatory.
# If you are running Kamikaze, delete the DESCRIPTION
# variable below and uncomment the Kamikaze define
# directive for the description below
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Helloworld -- prints a snarky message
endef
# Uncomment portion below for Kamikaze and delete DESCRIPTION variable above
define Package/helloworld/description
If you can't figure out what this program does, you're probably
brain-dead and need immediate medical attention.
endef
# Specify what needs to be done to prepare for building the package.
# In our case, we need to the source files to the build directory.
# This is NOT the default. The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one
# Specify where and how to install the program. Since we only have one file,
# the helloworld executable, install it by ing it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist. Likewise $(INSTALL_BIN) contains the
# command to the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef
# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))
(7)返回到SDK的根目录
执行make进行编译
编译过程会在build_dir目录下完成
编译结果会放在 bin/[yourtarget]/package目录下helloworld_1_bcm47xx.ipk
(8)上传helloworld_1_bcm47xx.ipk
使用sftp软件上传helloworld_1_bcm47xx.ipk至路由器
执行 opkg install helloworld_1_bcm47xx.ipk
输入hello然后按Tab键,发现openwrt中已经有helloworld可执行命令。
执行 helloworld 查看程序的效果。
Hell! O' world, why won't my code compile?
【End】
希望对大家能有帮助 :)
转载
C. 如何利用openwrt的web配置界面来配置端口映射
/etc/config/firewall
修改完以后请在终端窗口输入 /etc/init.d/firewall restart来重启防火墙使设置生效
端口映射:来自internet的使用tcp协议访问路由80端口的请求映射到内网192.168.1.10的 80端口
可以映射端口提高P2P效率
config redirect
option src wan
option src_dport 80
option proto tcp
option dest_ip 192.168.1.10
重定向:局域网访问10.55.34.85的请求将被重定向到63.240.161.99的123端口
可以用来做网页重定向等通告功能
config redirect
option src lan
option dest wan
option src_ip 10.55.34.85
option src_dip 63.240.161.99
option dest_port 123
option target SNAT
访问控制:拦截局域网到 123.45.67.89的访问请求
可以用来过滤某些网站
config rule
option src lan
option dest wan
option dest_ip 123.45.67.89
option target REJECT
基于MAC的访问控制,拦截局域网内MAC为 00:00:00:00:00的机子访问互联网
config rule
option src lan
option dest wan
option src_mac 00:00:00:00:00
option target REJECT
设置DMZ:
config redirect
option src wan
option proto all
option dest_ip 192.168.1.2
D. 请教openwrt远程web管理设置问题
里两个路由器,一级路由器a192.168.10.1,路由器a的DMZ指向二级路由器b192.168.10.2,在路由器a动态DNS邦定动态IP,二级路由器关掉DHCP,电脑连接二级路由器可以上网,二级路由器系统是openwrt,之前二级路由器系统是DDWRT的,直接开远程访问就可以在公网访问二级路由器,现在换openwrt系统了,怎么弄也不行,我知道是openwrt设置出问题了,哪位高手知道的请指教一下,感激不尽。我的openwrt系统是luci的web管理接口,本人小菜不懂的用命令
补充一下,二级路由是经过LAN接口跟一级路由器连接的,关掉二级路由器的DHCP服务器,
E. 如何从零开始学习OpenWrt
第一部分:搭建编译环境
1、安装Ubuntu(编译需要Linux环境),到其官网下载,版本根据自己所需选择即可。可以选择安装到虚拟机或者物理机,图形化安装而且是中文版,连安装都搞不定的,可以关闭本页面了;
2、切记不要改动软件源,同时按住Ctrl + Alt + T,调出终端;
3、逐条输入下列命令(及时验证是否安装成功):
sudo apt-get install g++
sudo apt-get install libncurses5-dev
sudo apt-get install zlib1g-dev
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install unzip
sudo apt-get install autoconf
sudo apt-get install gawk
sudo apt-get install make
sudo apt-get install gettext
sudo apt-get install gcc
sudo apt-get install binutils
sudo apt-get install patch
sudo apt-get install bzip2
sudo apt-get install libz-dev
sudo apt-get install asciidoc
sudo apt-get install subversion
sudo apt-get install sphinxsearch
sudo apt-get install libtool
sudo apt-get install sphinx-common
至此编译环境搭建完成。
第二部分:下载OpenWrt源码并编译
OpenWrt源码分两种,一种是最新但不是最稳定的Trunk开发版,一种是最稳定的Backfire版,建议下载官方源码。下载前先在本地创建文件夹:
mkdir openwrt
sudo chmod 777 openwrt
cd openwrt
选择你想要的版本然后执行下载命令,下载结束会显示版本号:
Trunk版下载命令:
svn co svn://svn.openwrt.org/openwrt/trunk/
Backfire版下载命令:
svn co svn://svn.openwrt.org/openwrt/branches/backfire/
添加软件扩展包,将feeds.conf.default修改为feeds.conf:
cp feeds.conf.default feeds.conf
更新扩展,安装扩展:
./scripts/feeds update -a
./scripts/feeds install -a
注:如果不是刚下载的源码,为保持代码为最新状态,应定期运行svn update命令更新源码。
测试编译环境:
make defconfig
到这里就可以开始编译自己的固件了。进入定制界面:
make menuconfig
如果一切正常,会出现一个配置菜单,可以选择要编译的固件平台(芯片类型)、型号,还能选择固件中要添加的功能和组件,配置好后保存并退出菜单即可。
如果你想修改源码,应该在此步进行,如支持大容量Flash之类的修改,自己上网查到修改什么文件什么地方后,就在ubuntu图形界面上进去找到文件,双击打开文本编辑器修改保存。
开始编译:
make
或者
make V=99
或者
make -j V=99
make是编译命令,V=99表示输出debug信息,V一定要大写,如果要让CPU全速编译,就加上 -j 参数,第一次编译最好不带-j参数。
编译过程保持联网(会从网上下载一些源码包),所以断网可能造成编译中断,编译所需时间与电脑CPU及网络环境有很大关系,第一次编译时间较久,快则半小时长则2、3个小时,之后的编译所需时间较短。编译完成后会在源码文件目录出现bin文件夹(如trunk/bin/XXXX),如果你手里的路由是原版固件需要刷OpenWrt需要选用XXX-factory.bin固件,如果路由已经刷了OpenWrt,选用升级固件XXXX-sysupgrade.bin升级用的,在升级界面升级即可。进到文件夹找到你需要的固件传出(通过邮箱、网盘、U盘等),开始刷机吧。
第三部分:将OpenWrt刷入路由器
要在路由器上使用OpenWrt,首先要将路由器固件刷新为OpenWrt,即相当于OpenWrt 系统的安装,不同型号的路由器的安装方法可能也会不一样,但一般常用的有三种方法:
Web上传固件更新
PFTP上传固件更新
编程器写入固件
具体型号的路由器适用于哪种或哪几种方法,需自行尝试。
第四部分:开始使用OpenWrt
要对OpenWrt进行配置,一般有两条途径:
SSH登录通过命令行控制
Web登录通过Web界面设置
首次安装OpenWrt后,需要设置密码才可以使用SSH登录,方法是使用telnet登录或者Web登录设置密码。在Windows下面telnet和SSH登录可以使用Putty,在Linux或Mac下可分别使用如下命令:
ssh –l root 192.168.1.1 //Linux
ssh [email protected] //Mac
一般指令与常见Linux发行版相同,但是OpenWrt使用自己的包管理器:opkg,使用“opkg –help”查看帮助信息。以下是一些常用操作命令:
opkg update //更新软件包列表
opkg install //在线安装软件包
opkg remove //移除软件包
登录Web管理界面,前提是该OpenWrt系统中要安装了Web界面,一般是Luci,登录方式与普通路由器无异,打开浏览器,输入路由器IP即可进入登录界面,OpenWrt的默认IP是192.168.1.1。
到此,OpenWrt的大门已为你敞开。接下来,开始尝试利用OpenWrt实现更多智能应用吧,比如单号多拨榨取运营商带宽、绑定域名远程控制、挂载大容量硬盘、搭建BT下载机、搭建网络摄像头、Samba/DLNA家庭NAS共享、私有云同步、FTP、个人网站/服务器
F. openwrt没有web管理界面
需要自己手动安装。
要给自己的开发板添加上Web管理界面,只需要在OpenWrt源码中,将LuCI配置进去即可。首先进入OpenWrt源码顶层目录,然后运行makemenuconfig命令。就可以将Web管理界面给配置进系统了。
OpenWRT是一个高度模块化、高度自动化的嵌入式Linux系统,拥有强大的网络组件和扩展性,常常被用于工控设备、电话、小型机器人、智能家居、路由器以及VOIP设备中。
G. openwrt java环境
jikes jamvm 和 classpath
查看方法:
ipkg list |grep jamvm
安装
ipkg install jikes classpath jamvm
然后bin下面会有 jamvm
ln -s /opt/bin/jamvm /opt/bin/java
java -> /opt/bin/jamvm
===================
/opt/bin # java -version
java version "1.5.0"
JamVM version 1.5.4
Copyright (C) 2003-2010 Robert Lougher <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2,
or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Build information:
Execution Engine: inline-threaded interpreter with stack-caching
Compiled with: gcc 4.2.3
Boot Library Path: /opt/lib/classpath
Boot Class Path: /opt/share/jamvm/classes.zip:/opt/share/classpath/glibj.zip
===================
java命令可用,同样在找 tomcat的方法,看过一个帖子写的
tomcat需要修改conf文件,使用jikes解析class文件
实在看不下去到处贴 win环境的玩意的,先分享一部分经验吧~
H. openwrt怎么启用web界面
tp 的941n刷完openwrt,怎么安装web管理界面
首先,用ssh登录路由(可用putty等软件)。确保路由连上网。——————————配置PPPOE上网————————————参考:openwrt命令行配置PPPOE上网的方法:1.vi /etc/config/network(编辑network网络配置文件)2.如果无法编辑,按a进入编辑模式。3.输入以下内容:config 'interface' 'wan'option ifname 'wan'option proto 'pppoe'option username 'xxxxxxx' (xxxxxxx表示是你的pppoe帐号)option password 'xxxxxx' (xxxxxx表示是你的密码)option peerdns '1'option defaultroute '1'4.按:(冒号)退出编辑模式,再输入x,然后回车,保存文件。5.输入 /etc/init.d/network start 并回车。配置PPPOE上网完毕。——————————配置PPPOE上网————————————输入opkg update 并回车。(更新软件包列表)输入opkg install luci 并回车。(安装Web管理软件luci)待完成,输入/etc/init.d/uhttpd start 并回车。(启动Web服务)输入/etc/init.d/uhttpd enable 并回车。(设为开机自动启动)好了,完成,可以通过浏览器访问你的路由器并进行配置了。补充一下:如果你需要中文界面,可以opkg install luci-i18n-chinese安装中文语言包。
I. 怎样为openwrt开发自己的应用
openwrt的Web MVC是lua语言写的luci
http://luci.subsignal.org/trac
两个luci主要的api接口
http://luci.subsignal.org/api/
还有init脚本调用config的方法
http://wiki.openwrt.org/doc/devel/config-scripting
建议先看一边luci和openwrt的源码