RG100A-AA-openwrt+nginx+php+mysql

來源:互聯網
上載者:User
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論壇

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.