Sep
7
[原]龙芯社区版的Debian系统安装Apache2+PHP+Mysql
继续昨天的工作,既然系统已经装好,那就从最简单的服务开始吧:Apache 2.2+PHP 5.3.3 +Mysql 5.1。
一、安装
操作不复杂(Debian的优势),用apt-get逐一运行:
包不同,依赖关系可能有点差异,可确认一下这几个包是否已经安装:
若没安装,用apt-get装一下即可。
二、配置
修改Apache配置文件/etc/apache2/apache2.conf,支持PHP后缀,即在最后加入:
然后,确认一下/etc/apache2/mods-enabled/目录中是否已打开php支持:
没有的话,从/etc/apache2/mods-available/下面做个链接过去吧。
三、测试
默认的DocumentRoot在/var/www目录下,有个index.html文件。也可以建个phpinfo看看结果:
还放了个正在制作中的程序进去:
※ 注意,Apache2是以www-data用户运行的。
四、常用服务
把常用软件也装上:
遵循LSB标准,服务启动脚本都存放在/etc/init.d目录下,而各runlevel 启动服务则由/etc/rc0.d ~ /etc/rc6.d 目录下的情况决定。
查看/etc/inittab,可知,默认为level 2。
可使用update-rc.d 脚本进行服务启动配置:
(无法打开图形,因此,把gdm暂时关掉)
重启后,查看打开端口:
五、压力测试
顺带做了个简单的压力测试。龙芯的性能就比较一般了,这是ab 压力测试的情况:
内存太少,只有512M,跑c 1000,直接死掉:
一、安装
操作不复杂(Debian的优势),用apt-get逐一运行:
apt-get install php5
apt-get install apache2
apt-get install mysql-server mysql-client
apt-get install php5-mysql php5-curl php5-gd
apt-get install apache2
apt-get install mysql-server mysql-client
apt-get install php5-mysql php5-curl php5-gd
包不同,依赖关系可能有点差异,可确认一下这几个包是否已经安装:
dpkg -l 'apache2-mpm-prefork'
dpkg -l 'php5-mysql'
dpkg -l 'php5-curl'
dpkg -l 'php5-gd'
dpkg -l 'php5-mysql'
dpkg -l 'php5-curl'
dpkg -l 'php5-gd'
若没安装,用apt-get装一下即可。
二、配置
修改Apache配置文件/etc/apache2/apache2.conf,支持PHP后缀,即在最后加入:
引用
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ServerName yeeloong
AddType application/x-httpd-php-source .phps
ServerName yeeloong
然后,确认一下/etc/apache2/mods-enabled/目录中是否已打开php支持:
引用
# ll /etc/apache2/mods-enabled/php*
lrwxrwxrwx 1 root root 27 Sep 6 16:33 /etc/apache2/mods-enabled/php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 Sep 6 16:33 /etc/apache2/mods-enabled/php5.load -> ../mods-available/php5.load
lrwxrwxrwx 1 root root 27 Sep 6 16:33 /etc/apache2/mods-enabled/php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 Sep 6 16:33 /etc/apache2/mods-enabled/php5.load -> ../mods-available/php5.load
没有的话,从/etc/apache2/mods-available/下面做个链接过去吧。
三、测试
默认的DocumentRoot在/var/www目录下,有个index.html文件。也可以建个phpinfo看看结果:
还放了个正在制作中的程序进去:
※ 注意,Apache2是以www-data用户运行的。
四、常用服务
把常用软件也装上:
apt-get install subversion
apt-get install lftp
apt-get install lftp
遵循LSB标准,服务启动脚本都存放在/etc/init.d目录下,而各runlevel 启动服务则由/etc/rc0.d ~ /etc/rc6.d 目录下的情况决定。
查看/etc/inittab,可知,默认为level 2。
可使用update-rc.d 脚本进行服务启动配置:
update-rc.d ssh enable
update-rc.d vsftpd enable
update-rc.d gdm disable
update-rc.d vsftpd enable
update-rc.d gdm disable
(无法打开图形,因此,把gdm暂时关掉)
重启后,查看打开端口:
引用
# netstat -ln
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: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 :::22 :::* LISTEN
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: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 :::22 :::* LISTEN
五、压力测试
顺带做了个简单的压力测试。龙芯的性能就比较一般了,这是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: Apache/2.2.16
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /phpinfo.php
Document Length: 63515 bytes
Concurrency Level: 100
Time taken for tests: 21.896 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 63706000 bytes
HTML transferred: 63515000 bytes
Requests per second: 45.67 [#/sec] (mean)
Time per request: 2189.606 [ms] (mean)
Time per request: 21.896 [ms] (mean, across all concurrent requests)
Transfer rate: 2841.28 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 5.4 0 22
Processing: 162 2136 969.9 1942 5744
Waiting: 75 1232 554.5 1291 2510
Total: 180 2138 967.9 1942 5744
Percentage of the requests served within a certain time (ms)
50% 1942
66% 2116
75% 2217
80% 2289
90% 2767
95% 4760
98% 5398
99% 5526
100% 5744 (longest request)
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: Apache/2.2.16
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /phpinfo.php
Document Length: 63515 bytes
Concurrency Level: 100
Time taken for tests: 21.896 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 63706000 bytes
HTML transferred: 63515000 bytes
Requests per second: 45.67 [#/sec] (mean)
Time per request: 2189.606 [ms] (mean)
Time per request: 21.896 [ms] (mean, across all concurrent requests)
Transfer rate: 2841.28 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 5.4 0 22
Processing: 162 2136 969.9 1942 5744
Waiting: 75 1232 554.5 1291 2510
Total: 180 2138 967.9 1942 5744
Percentage of the requests served within a certain time (ms)
50% 1942
66% 2116
75% 2217
80% 2289
90% 2767
95% 4760
98% 5398
99% 5526
100% 5744 (longest request)
内存太少,只有512M,跑c 1000,直接死掉:
引用
# ab -c 1000 -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
apr_socket_recv: Connection reset by peer (131)
Total of 376 requests completed
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
apr_socket_recv: Connection reset by peer (131)
Total of 376 requests completed