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

aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增強codemodocultion,可驗證性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

選擇DependencyInjection(DI)用於大型應用,ServiceLocator適合小型項目或原型。 1)DI通過構造函數注入依賴,提高代碼的測試性和模塊化。 2)ServiceLocator通過中心註冊獲取服務,方便但可能導致代碼耦合度增加。

phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)啟用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替換loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

phpemailvalidation invoLvesthreesteps:1)格式化進行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)

tomakephpapplicationsfaster,關注台詞:1)useopcodeCachingLikeLikeLikeLikeLikePachetoStorePreciledScompiledScriptbyTecode.2)MinimimiedAtabaseSqueriSegrieSqueriSegeriSybysequeryCachingandeffeftExting.3)Leveragephp7 leveragephp7 leveragephp7 leveragephpphp7功能forbettercodeefficy.4)

到ImprovephPapplicationspeed,關注台詞:1)啟用opcodeCachingwithapCutoredUcescriptexecutiontime.2)實現databasequerycachingingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandreduceconnection.4 limitesclection.4.4

依赖注入(DI)通过显式传递依赖关系,显著提升了PHP代码的可测试性。1)DI解耦类与具体实现,使测试和维护更灵活。2)三种类型中,构造函数注入明确表达依赖,保持状态一致。3)使用DI容器管理复杂依赖,提升代码质量和开发效率。

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

Dreamweaver CS6
視覺化網頁開發工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器

SublimeText3漢化版
中文版,非常好用

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。