RG100A-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论坛

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...
