Sep 19

[原]龙芯社区版的Debian系统安装Nginx+PHP+Mysql 晴

linuxing , 11:06 , 网络服务 » 常见服务 , 评论(0) , 引用(0) , 阅读(30690) , Via 本站原创 | |
    这是对[原]龙芯社区版的Debian系统安装Apache2+PHP+Mysql一文的补充。过程就是简单的apt-get,和修改配置文件,算做个记录吧。

一、安装套件
执行以下命令,安装所需的补充软件包:

sudo apt-get intsall nginx
sudo apt-get install php5 php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-sqlite php5-xsl
sudo apt-get install spawn-fcgi

※ 以上安装PHP的包是辅助的,可选。
Nginx版本:
引用
$ sudo nginx -v
nginx version: nginx/0.7.67

二、修改配置文件
1、相关文件
该版本Nginx的相关文件是:
引用
● 所有的配置文件都在/etc/nginx下,独立的配置文件存放在/etc/nginx/sites-available目录下
● 程序文件在/usr/sbin/nginx
● 日志文件/var/log/nginx中
● 服务脚本/etc/init.d/nginx
● 默认的虚拟主机的目录设置在了/var/www/

此外,打包的Nginx已经把大部分的常用选项存放在/etc/nginx/sites-available/default文件中,我们要修改的也是该文件。

2、修改配置
修改/etc/nginx/sites-available/default,把以下配置打开或取消注释:
引用
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
}

※ 注意:上述配置必须与安装的Nginx 相关文件一致。

三、启动服务
启动spawn-fcgi:

sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

启动Nginx:

sudo /etc/init.d/nginx start

查看端口:
引用
$ netstat -ln|more
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN

※ 80端口是Nginx的,9000端口是spawn-fcgi 负责的。若之前启动了Apache,请先关闭。

四、测试
访问phpinfo页面:
点击在新窗口中浏览此图片
ab压力测试:
引用
# ab -c 100 -n 1000 http://127.0.0.1/phpinfo.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        nginx/0.7.67
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /phpinfo.php
Document Length:        73259 bytes

Concurrency Level:      100
Time taken for tests:   29.305 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      73417000 bytes
HTML transferred:       73259000 bytes
Requests per second:    34.12 [#/sec] (mean)
Time per request:       2930.469 [ms] (mean)
Time per request:       29.305 [ms] (mean, across all concurrent requests)
Transfer rate:          2446.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    3   8.5      0      33
Processing:   165 2792 491.1   2928    3038
Waiting:       74 2696 490.9   2832    2948
Total:        189 2795 484.0   2928    3038

Percentage of the requests served within a certain time (ms)
  50%   2928
  66%   2934
  75%   2939
  80%   2941
  90%   2951
  95%   2965
  98%   3010
  99%   3028
100%   3038 (longest request)

响应时间一般,似乎比Apache好些。(加载的模块比之前测试的要多)
Tags: , ,
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]