Table of Contents
So,开始之前你需要什么?
关于openwrt
安装Python以及Django
让路由器咆哮
Home Database Mysql Tutorial Openwrt django,路由器上运行Django,基于DB120与Openwrt

Openwrt django,路由器上运行Django,基于DB120与Openwrt

Jun 07, 2016 pm 03:25 PM
django openwrt router run

So,开始之前你需要什么? 关于openwrt OpenWrt的被描述为一个嵌入式设备的Linux发行版,而不是试图建立一个单一的,静态的固件,OpenWrt的包管理提供了一个完全可写的文件系统,从应用程序供应商提供的选择和配置,并允许您自定义的设备,以适应任何应用程

So,开始之前你需要什么?

关于openwrt

OpenWrt的被描述为一个嵌入式设备的Linux发行版,而不是试图建立一个单一的,静态的固件,OpenWrt的包管理提供了一个完全可写的文件系统,从应用程序供应商提供的选择和配置,并允许您自定义的设备,以适应任何应用程序通过使用包。对于开发人员,OpenWrt的是框架来构建应用程序,而无需建立一个完整的固件左右;对于用户来说,这意味着完全定制的能力,从来没有预想的方式使用该设备。

  1. 装有Openwrt的路由器              一个      
  2. 使你的路由器能上网

所以,你需要买上一个路由器,或者用自带的,至于各种教程就网上找吧。如果不知道Openwrt是什么请谷歌,如果你的路由器不能上网,带有无线的话,试着用connectify共享出你的网络。

(Ps:需要有Linux基础才会各种没有压力,power by Phodal.com)

参考这个贴子:http://www.openwrt.org.cn/bbs/forum.php?mod=viewthread&tid=5983,扩展你的系统到U盘上。

1

2

3

4

5

6

7

8

9

10

11

12

13

opkg update

opkg install kmod-usb-ohci kmod-usb2 kmod-fs-ext3

opkg install kmod-usb-storage

reboot

mount /dev/sda1 /mnt

mkdir /tmp/root

mount -o bind / /tmp/root

cp /tmp/root/* /mnt -a

umount /tmp/root

umount /mnt

echo Booted from internal rom >> /etc/banner

opkg update

opkg install block-extroot

Copy after login

#修改etc/config/fstab文件如下:

1

2

echo option force_space >> /etc/opkg.conf

reboot

Copy after login


当然了,如果你的路由器带有支持extroot功能的话,直接就能用。如我的

Openwrt django,路由器上运行Django,基于DB120与Openwrt

总之是为了保证有足够的空间来安装这些。


安装Python以及Django

需要安装libffi,python-mini,python。libffi以及python-mini需要安装在python之前

1

2

3

wget -c http://downloads.openwrt.org.cn/backfire/10.03.1/brcm63xx/packages/libffi_3.0.9-1_brcm63xx.ipk

wget -c http://downloads.openwrt.org.cn/backfire/10.03.1/brcm63xx/packages/python-mini_2.6.4-3_brcm63xx.ipk

wget -c http://downloads.openwrt.org.cn/backfire/10.03.1/brcm63xx/packages/python_2.6.4-3_brcm63xx.ipk

Copy after login
安装这几个包

1

2

3

opkg install libffi*.ipk

opkg install python-mini*.ipk

opkg install python_2*.ipk

Copy after login


下载setuptools

http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086

安装easy_install

1

sh setuptools-0.6c11-py2.6.egg

Copy after login

安装Pip

1

easy_install pip

Copy after login

安装django

1

pip install django

Copy after login


创建一个django项目,比如Onrt

1

django-admin.py startproject Onrt

Copy after login
 

让路由器咆哮

(powered by Phodal.com)

安装sqlite以及lighttpd,如果不能直接安装请使用wget 

1

2

3

4

5

6

7

8

9

10

opkg install lighttpd

opkg install libsqlite2

opkg install libsqlite3

opkg install lighttpd-mod-access

opkg install lighttpd-mod-alias

opkg install lighttpd-mod-cgi

opkg install lighttpd-mod-fastcgi

opkg install lighttpd-mod-rewrite

opkg install lighttpd-mod-redirect

opkg install sqlite2-cli

Copy after login

1

2

opkg install nginx

opkg install fastcgi

Copy after login

测试下nginx

1

/etc/init.d/nginx start

Copy after login

遇到错误,修改端口。

修改nginx.conf。位于/etc/nginx/nginx.conf

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

user nobody nogroup;

worker_processes  1;

 

error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

events {

    worker_connections  1024;

}

 

 

http {

    include mime.types;

    index index.php index.html index.htm;

    default_type text/html;

 

    sendfile on;

    keepalive_timeout 65;

    gzip on;

 

    gzip_min_length  1k;

    gzip_buffers     4 16k;

    gzip_http_version 1.0;

    gzip_comp_level 2;

    gzip_types       text/plain application/x-javascript text/css application/xml;

    gzip_vary on;

    server {

            listen       88;

            server_name  YOUR_SERVER;

 

        fastcgi_connect_timeout 300;

        fastcgi_send_timeout 300;

        fastcgi_read_timeout 300;

        fastcgi_buffer_size 32k;

        fastcgi_buffers 4 32k;

        fastcgi_busy_buffers_size 32k;

        fastcgi_temp_file_write_size 32k;

        client_body_timeout 10;

        client_header_timeout 10;

        send_timeout 60;

        output_buffers 1 32k;

        postpone_output 1460;

 

        root   /root/Onrt;

 

        location /static/ { # STATIC_URL

            alias /root/Onrt; # STATIC_ROOT

            expires 30d;

        }

 

        location /media/ { # MEDIA_URL

            alias /root/Onrt; # MEDIA_ROOT

            expires 30d;

        }

 

        location / {

            include fastcgi_params;

            fastcgi_pass 127.0.0.1:1259;

        }

 

        #location ~ \.php$ {

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        #    include        fastcgi_params;

        #

        #    if (-f $request_filename) {

        #        # Only throw it at PHP-FPM if the file exists (prevents some PHP exploits)

        #        fastcgi_pass    127.0.0.1:1026;     # The upstream determined above

        #    }

        #}

    }

}

Copy after login

运行fastcgi

1

python /root/Onrt/manage.py runfcgi host=127.0.0.1 port=1259;

Copy after login

记得保持端口一致


大功告成:Welcome to Django

Openwrt django,路由器上运行Django,基于DB120与Openwrt



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to execute .sh file in Linux system? How to execute .sh file in Linux system? Mar 14, 2024 pm 06:42 PM

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

PyCharm usage tutorial: guide you in detail to run the operation PyCharm usage tutorial: guide you in detail to run the operation Feb 26, 2024 pm 05:51 PM

PyCharm is a very popular Python integrated development environment (IDE). It provides a wealth of functions and tools to make Python development more efficient and convenient. This article will introduce you to the basic operation methods of PyCharm and provide specific code examples to help readers quickly get started and become proficient in operating the tool. 1. Download and install PyCharm First, we need to go to the PyCharm official website (https://www.jetbrains.com/pyc

What are the benefits of turning on ipv6 on the router 'Advantages of using the latest IPv6' What are the benefits of turning on ipv6 on the router 'Advantages of using the latest IPv6' Feb 06, 2024 pm 05:34 PM

Students who know computers all know that if our computer wants to connect to the network, it must have an IP address. This IP address can be manually configured, such as 172.16.19.20; it can also be automatically obtained by the DHCP server of the computer network card, such as 192.168.1.100 etc. These IP addresses are what we often call IPV4 addresses, and the corresponding IPV6 is also a type of IP address. What is IPV6 IPV6 is a new IP address that emerged in response to the exhaustion of IPV4 address resources. Its full name is "Internet Protocol Version 6", and its Chinese name is the sixth generation of Internet Protocol. The number of IPv6 addresses is theoretically 2^128

Reasons why exe files cannot be run on Windows 7 Reasons why exe files cannot be run on Windows 7 Feb 18, 2024 pm 08:32 PM

Why can't win7 run exe files? When using the Windows7 operating system, many users may encounter a common problem, that is, they cannot run exe files. exe files are common executable files in Windows operating systems. They are usually used to install and run various applications. However, some users may find that when they try to run the exe file, the system does not respond or gives an error message. There are many reasons for this problem. Below are some common causes and corresponding solutions:

Django Framework Pros and Cons: Everything You Need to Know Django Framework Pros and Cons: Everything You Need to Know Jan 19, 2024 am 09:09 AM

Django is a complete development framework that covers all aspects of the web development life cycle. Currently, this framework is one of the most popular web frameworks worldwide. If you plan to use Django to build your own web applications, then you need to understand the advantages and disadvantages of the Django framework. Here's everything you need to know, including specific code examples. Django advantages: 1. Rapid development-Djang can quickly develop web applications. It provides a rich library and internal

Why can't I execute bat file on Windows 7? Why can't I execute bat file on Windows 7? Feb 19, 2024 pm 03:19 PM

Why can't win7 run bat files? Recently, many users using the Windows7 operating system have reported that they cannot run .bat files. This sparked widespread discussion and confusion. Why can't a well-functioning operating system run a simple .bat file? First, we need to understand the background of the .bat file. A .bat file, also known as a batch file, is a plain text file that contains a series of commands that can be used by the Windows command interpreter (cmd.ex

How many lights on the router are normal? 'Recommended detailed explanation of the normal status of the router indicator lights' How many lights on the router are normal? 'Recommended detailed explanation of the normal status of the router indicator lights' Feb 06, 2024 pm 09:12 PM

The first light is on, indicating that the router is powered on. Which port is plugged in, the light of which port is on, and flashing means data is being transmitted. Wireless routers usually have three indicator lights: SYS, LAN and WAN. When the wireless router is powered on, the SYS light will light up. When the wireless router is connected to the network modem, the WAN light will light up. The LAN light corresponds to each interface of the wireless router. As long as the network cable is inserted into the corresponding interface, the corresponding LAN light will light up. 1. If it keeps flashing, it means it is transmitted by data, and the router settings should be normal. 2. If you have always been able to access the Internet, but you can't get online recently; it is probably a problem with the external line, that is, a problem with the operator (usually there is a problem with the line, causing the data signal to attenuate too much, although the line is good)

How to run m-file in matlab - Tutorial on running m-file in matlab How to run m-file in matlab - Tutorial on running m-file in matlab Mar 04, 2024 pm 02:13 PM

Do you know how to run m files in matlab? Below, the editor will bring you a tutorial on how to run m files in matlab. I hope it will be helpful to you. Let’s learn with the editor! 1. First open the matlab software and select the upper left "Open" the corner, as shown in the picture below. 2. Then select the m file to be run and open it, as shown in the figure below. 3. Press F5 in the window to run the program, as shown in the figure below. 4. We can view the running results in the command line window and workspace, as shown in the figure below. 5. You can also run the file by clicking "Run" directly, as shown in the figure below. 6. Finally, you can view the running results of the m file in the command line window and workspace, as shown in the figure below. The above is the matlab method that the editor brought to you

See all articles