當前位置:首頁 » 網頁前端 » openwrtweb開發
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

openwrtweb開發

發布時間: 2022-09-02 20:59:04

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的源碼