Home Backend Development PHP Tutorial RG100A-AA-openwrt+nginx+php+mysql

RG100A-AA-openwrt+nginx+php+mysql

Jun 20, 2016 pm 12:58 PM

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 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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks 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)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP Logging: Best Practices for PHP Log Analysis PHP Logging: Best Practices for PHP Log Analysis Mar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

See all articles