上一步已经把HG255D的系统刷为OpenWrt,将环境搭建起来就可以上传博客的安装包了
先上一个php探针
1.安装软件(我的固件已经将nginx、php编译进去了,这一步只需安装mysql、spawn和shadow相关的软件)
opkg update
opkg install block-mount #自动挂载U盘
opkg install mysql-server
opkg install spawn-fcgi zoneinfo-core zoneinfo-asia
opkg install shadow-groupadd shadow-useradd
2.创建账户、数据库文件夹等
groupadd www
useradd -g www www
mkdir /mnt/sda1/web #确保挂载了U盘
chown -R www:www /mnt/sda1/web
mkdir -p /mnt/sda1/data /mnt/sda1/data/mysql /mnt/sda1/data/tmp
3.修改/etc/my.cnf
datadir = /mnt/sda1/data/mysql/
tmpdir = /mnt/sda1/data/tmp/
4.启动mysql
/etc/init.d/mysqld start
5.输入如下命令创建mysql的密码(记住账户密码)
/usr/bin/mysqladmin -u root password 123456
6.登陆数据库
mysql -u root -p
7.连接上mysql,创建数据库(aaaa随意写,记住即可,安装博客时需要填)
create database aaaa
\g
8.退出mysql
quit
9.修改/etc/nginx/nginx.conf
user www www;
worker_processes 1;
pid /var/run/nginx.pid;
error_log /var/log/nginx_error.log;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
access_log off;
include vhost.conf;
}
10.修改/etc/nginx/fastcgi_params,解决Nginx文件类型错误解析漏洞
if ($request_filename ~* (.*)\.php) {
set $php_url $1;
}
if (!-e $php_url.php) {
return 403;
}
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
11.添加/etc/nginx/vhost.conf(端口需要修改成80以外的端口,我这里设置成82)
server {
listen 82;
server_name localhost;
root /mnt/sda1/web;
index index.html index.htm index.php default.php;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~* ^.+\.php(\/.*)*$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
12.修改/etc/php.ini
short_open_tag = on
#doc_root = "/mnt/www"
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
13.启动spawn-fcgi(如需开机自动运行,可将命令添加到/etc/rc.local)
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 2 -f /usr/bin/php-cgi
14.启动nginx
/etc/init.d/nginx enable
/etc/init.d/nginx start
接着就可以上传类似emlog、TypeCho等博客安装程序了
网友评论