search
HomeBackend DevelopmentPHP TutorialRG100A-AA-openwrt+nginx+php+mysql

RG100A-AA内存为32M,flash为16M,主频为300MHZ,较小的内存和较低的主频,这决定了在搭建服务器时,必须考虑硬件条件的局限性。《Lighttpd+PhP5+MYSQL标准教程》中说内存最低为64M,这显然不符合现有硬件需求。因此需要寻找开销更小的方案。可以参考http://www.right.com.cn/forum/thread-89216-1-1.html 和 http://tieba.baidu.com/p/2950214737方案进行尝试配置。

RG100A-AA搭载 OpenWrt-DreamBox 20120201配置Nginx+PHP5+MySql步骤:

1、安装相关软件包:

    opkg update

    opkg install php5 php5-mod-gd php5-mod-session php5-mod-pdo php5-mod-pdo-mysql php5-mod-mysql php5-mod-mcrypt php5-mod-mbstring php5-fastcgi php5-cgi php5-mod-xml php5-mod-ctype php5-mod-curl php5-mod-exif php5-mod-ftp php5-mod-iconv php5-mod-json php5-mod-sockets php5-mod-sqlite3 php5-mod-tokenizer php5-mod-zip mysql-server nginx spawn-fcgi zoneinfo-core zoneinfo-asia shadow-groupadd shadow-useradd

遇到的问题:

        Unknown package 'php5-mod-zip';Unknown package 'zoneinfo-core';Unknown package 'zoneinfo-asia';

        Collected errors:

        * opkg_install_cmd: Cannot install package php5-mod-zip.

        * opkg_install_cmd: Cannot install package zoneinfo-core.

        * opkg_install_cmd: Cannot install package zoneinfo-asia.

此种情况是由于软件包的源长时间没有更新,需要更换软件包源,找一个与本处理器型号相同的软件包源地址。在/etc/opkg.conf中

root@DreamBox:/# vi /etc/opkg.conf 

#src/gz packages http://downloads.openwrt.org.cn/backfire/10.03.1/brcm63xx/packages

src/gz packages http://downloads.openwrt.org/attitude_adjustment/12.09/brcm63xx/generic/packages 

dest root /  

dest ram /tmp                

lists_dir ext /var/opkg-lists

option overlay_root /overlay

红色字体为原来的软件包源地址,绿色字体为新的源地址,注释掉红色配置行,保存后重新执行opkg update;opkg install php5-mod-zip zoneinfo-core zoneinfo-asia。

2、建立操作用户

mkdir /html

groupadd www
useradd -g www www
chown -R www:www /html

3、建立数据库文件夹

mkdir -p /mnt/data /mnt/data/mysql /mnt/data/tmp

4、创建默认数据库

/usr/bin/mysql_install_db --force 

报错:Installing MySQL system tables...

/usr/bin/mysqld: can't resolve symbol 'pthread_setschedprio'

Installation of system tables failed!  Examine the logs in

/mnt/data/mysql/ for more information.

这个错误是安装的mysql-server有一个小bug,这个bug的介绍在http://bugs.mysql.com/bug.php?id=4 2599 中有详细说明。

解决办法:

(1)卸载mysql-server :opkg remove mysql-server;

(2)更换opkg源,取消opkg.conf第一行注释,注释第二行。

(3)opkg update;opkg install mysql-server

(4)/usr/bin/mysql_install_db --force

出现如下绿色字体,说明已经安装正确的mysql-server了。

Installing MySQL system tables...

OK

Filling help tables...

OK

(5)启动mysqld:/etc/init.d/mysqld start

 

5、启动mysql,并且创建root密码,密码设置为123,如果真正使用,建议设置复杂点的密码:

/usr/bin/mysqladmin -u root password 123456

6、连接上mysql后,创建数据库:

mysql  >  create database discuz;

查看当前可用数据库:

mysql  > show databases;

查看数据库状态:

mysql > \s;

7、修改/etc/nginx/nginx.conf:

user  www;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;

    #tcp_nopush     on;

    #keepalive_timeout  0;

    keepalive_timeout  65;

    #gzip  on;

    server {

        listen       88;

        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {

            root   html;

            index index.php index.html index.htm;

        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        location ~ \.php$ {

            root           html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /html$fastcgi_script_name;

            include        fastcgi_params;

        }

}

8、修改、/etc/php.ini

short_open_tag = on

#doc_root = "/html" 


extension=ctype.so

extension=curl.so

extension=gd.so

extension=mbstring.so

extension=mcrypt.so

extension=mysql.so

extension=pdo.so

extension=pdo_mysql.so

extension=session.so

extension=sockets.so

extension=tokenizer.so

extension=xml.so


[Date]

date.timezone = Asia/Shanghai


[MySQL]

mysql.default_socket = /var/run/mysqld.sock 

}

9、启动spawn-fcgi(如需开机自动运行,可将命令添加到/etc/rc.local)

usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 2 -f /usr/bin/php-cgi

10、启动nginx

/etc/init.d/nginx start

11、在/html目录下建立php测试文件:

#cd /html

#touch test.php

#chown www:www test.php

#vi test.php

phpinfo();

?>

   在浏览器上输入192.168.1.11:88/test.php,就可以看到php的配置信息了。

12、可以下载雅黑探针到/html目录,雅黑探针php文件名为tz.php,在浏览器中输入192.168.1.11:88/tz.php就可以看到web服务器的配置详情了。

13、建立discuz论坛


Statement
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
How do you create and use an interface in PHP?How do you create and use an interface in PHP?Apr 30, 2025 pm 03:40 PM

The article explains how to create, implement, and use interfaces in PHP, focusing on their benefits for code organization and maintainability.

What is the difference between crypt() and password_hash()?What is the difference between crypt() and password_hash()?Apr 30, 2025 pm 03:39 PM

The article discusses the differences between crypt() and password_hash() in PHP for password hashing, focusing on their implementation, security, and suitability for modern web applications.

How can you prevent Cross-Site Scripting (XSS) in PHP?How can you prevent Cross-Site Scripting (XSS) in PHP?Apr 30, 2025 pm 03:38 PM

Article discusses preventing Cross-Site Scripting (XSS) in PHP through input validation, output encoding, and using tools like OWASP ESAPI and HTML Purifier.

What is autoloading in PHP?What is autoloading in PHP?Apr 30, 2025 pm 03:37 PM

Autoloading in PHP automatically loads class files when needed, improving performance by reducing memory use and enhancing code organization. Best practices include using PSR-4 and organizing code effectively.

What are PHP streams?What are PHP streams?Apr 30, 2025 pm 03:36 PM

PHP streams unify handling of resources like files, network sockets, and compression formats via a consistent API, abstracting complexity and enhancing code flexibility and efficiency.

What is the maximum size of a file that can be uploaded using PHP ?What is the maximum size of a file that can be uploaded using PHP ?Apr 30, 2025 pm 03:35 PM

The article discusses managing file upload sizes in PHP, focusing on the default limit of 2MB and how to increase it by modifying php.ini settings.

What is Nullable types in PHP ?What is Nullable types in PHP ?Apr 30, 2025 pm 03:34 PM

The article discusses nullable types in PHP, introduced in PHP 7.1, allowing variables or parameters to be either a specified type or null. It highlights benefits like improved readability, type safety, and explicit intent, and explains how to declar

What is the difference between the unset() and unlink() functions ?What is the difference between the unset() and unlink() functions ?Apr 30, 2025 pm 03:33 PM

The article discusses the differences between unset() and unlink() functions in programming, focusing on their purposes and use cases. Unset() removes variables from memory, while unlink() deletes files from the filesystem. Both are crucial for effec

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool