内核版本 3.10.49
1、安装Nginx、PHP与MySQL软件
获取列表
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
二、opkg install mysql-server
三、opkg install nginx spawn-fcgi zoneinfo-core zoneinfo-asia shadow-groupadd shadow-useradd

完事的话中途不会提示出错的。

我用的512M电子盘,系统空间用的不多,剩下有300多M的空间,要先格式化出未分配的空间才能使用,可以CFDISK
为了让盘支持大文件装个libext2fs支持ext4格式化
装个FDISK来格式化磁盘

下面安装CFDISK分区的一些操作截图,选new创建分区

选type选择分区格式

我选83

最后write

进过上面的准备,开始调试
1、建立操作用户
groupadd www
useradd -g www www
chown -R www:www /mnt/wwwroot
2、创建数据库文件夹
mkdir -p /mnt/data /mnt/data/mysql /mnt/data/tmp
3、创建默认数据库
/usr/bin/mysql_install_db --force
下面是提示
root@xr:/mnt# /usr/bin/mysql_install_db --force
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h Navigator password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/scripts/mysqlbug script!

4、启动mysql,并且创建root密码,密码设置为123,如果真正使用,建议设置复杂点的密码

启动:/etc/init.d/mysqld start
设置密码:/usr/bin/mysqladmin -u root password 123
登录mysql:mysql -u root -p
输入密码后进入,开始创建个数据库:
create database wordpress
\g

创建成功!
查看当前可用数据库
show databases
\g

查看MySQL运行状态,输入 \s
退出输入 \q

路由器的后台启动占用的是80端口,如果你想要直接80端口给nginx使用,必须修改端口端口文件在
/etc/config/uhttpd
找到list listen_http '0.0.0.0:80'把这行的80改为8080(暂时不知道修改端口后对路由管理今后是否有影响,希望朋友给我反馈一下)

到nginx和php的配置:
1、nginx配置目录在/etc/nginx/,需要修改nginx.conf
2、php配置/etc/nginx/fastcgi_params
3、修改 /etc/php.ini 增减一些模块
4、启动spawn-fcgi(如需开机自动运行,可将命令添加到/etc/rc.local)
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 2 -f /usr/bin/php-cgi
5、启动nginx
/etc/init.d/nginx enable
/etc/init.d/nginx start

配置好nginx.conf后,测试配置文件
root@NNTD:~# /usr/sbin/nginx -t
/usr/sbin/nginx: can't load library 'libpcre.so.1'
提示错误!
ldd $(which /usr/sbin/nginx)
可以看到一行
libpcre.so.1 => not found
检查下ls /usr/lib -l看看
实际上文件是存在的,名字是libpcre.so.0.0.1
只要在该目录执行一次,
ln -s libpcre.so.0.0.1 libpcre.so.1
然后再
32位系统则:
ln -s /usr/lib/libpcre.so.1 /lib
64位系统则:
ln -s /usr/lib/libpcre.so.1 /lib64
解决这个问题。

2014-10-28 增加php自动启动的脚本
让php自动启动并添加后台管理
vim /usr/bin/php-fastcgi

#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 3 -u www -f /usr/bin/php-cgi

chmod +x /usr/bin/php-fastcgi

vim /etc/init.d/php-fcgi

#!/bin/sh /etc/rc.common
# Copyright (C) 2004-2014 nntd.com

START=70
PHP_SCRIPT=/usr/bin/php-fastcgi

start() {
$PHP_SCRIPT
}
stop() {
killall -9 php-cgi
}
restart() {
killall -9 php-cgi
$PHP_SCRIPT
}

chmod 755 /etc/init.d/php-fcgi

现在可以在后台的启动项看到php-fcgi的管理了。重启也可以很好的自动启动。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。