nginx0.6.34+php-5.27 fastcgi 安装

所需包:
php-5.2.7.tar.bz2
nginx-0.6.34
lighttpd-1.4.20.tar.gz
mysql-5.0.67.tar.gz

编译安装mysql-6.0.67

hqlong@ubuntu:~/software/tar.gz$ tar zxvf mysql-5.0.67.tar.gz 
hqlong@ubuntu:~/software/tar.gz$ cd mysql-5.0.67/
hqlong@ubuntu:~/software/tar.gz/mysql-5.0.67$ ./configure \
--prefix=/usr/local/webserver/mysql/ \
--without-debug \
--with-unix-socket-path=/tmp/mysql.sock \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static --enable-assembler \
--with-extra-charsets=gbk,gb2312,utf8 \
--with-pthread \
--enable-thread-safe-client
hqlong@ubuntu:~/software/tar.gz/mysql-5.0.67$ make && sudo make install
hqlong@ubuntu:~/software/tar.gz/mysql-5.0.67$ sudo chmod +w /usr/local/webserver/mysql
hqlong@ubuntu:~/software/tar.gz/mysql-5.0.67$ sudo chown -R mysql:mysql /usr/local/webserver/mysql
hqlong@ubuntu:~/software/tar.gz/mysql-5.0.67$ cp support-files/my-medium.cnf /usr/local/webserver/mysql/my.cnf


安装mysql数据库

hqlong@ubuntu:/usr/local/webserver/mysql/bin$ sudo ./mysql_install_db \
--defaults-file=/usr/local/webserver/mysql/my.cnf \
--basedir=/usr/local/webserver/mysql \
--datadir=/usr/local/webserver/mysql/data \
--user=mysql \
--pid-file=/usr/local/webserver/mysql/mysql.pid \
--skip-locking --port=3306 \
--socket=/tmp/mysql.sock

编译安装php5(fastcgi模式)

hqlong@ubuntu:~/software/tar.gz/php-5.2.7$ ./configure \
--prefix=/usr/local/webserver/php \
--with-config-file-path=/usr/local/webserver/php/etc \
--with-mysql=/usr/local/webserver/mysql \
--with-pdo-mysql=/usr/local/webserver/mysql \
--with-gd --with-jpeg-dir=/usr \
--with-png-dir=/usr \
--enable-safe-mode \
--enable-fastcgi \
--enable-force-cgi-redirect
hqlong@ubuntu:~/software/tar.gz/php-5.2.7$ make && sudo make install

创建www用户和组

groupadd www -g 48
useradd -g 48 www

安装 Linghttpd’s spawn-fcgi用 Lighttpd 的 spawn-fcgi 来管理 PHP FastCGI 进程。

tar zxvf lighttpd-1.4.20.tar.bz2
cd lighttpd-1.4.20
./configure --without-bzip2
make
cp -a src/spawn-fcgi /usr/local/php-fcgi/bin/

启动php-cgi进程,监听127.0.0.1的10080端口,进程数为64(如果服务器内存小于3GB,可以只开启25个进程),用户为www

sudo ./spawn-fcgi -a 127.0.0.1 -p 10080 -C 64 -u www -f /usr/local/webserver/php/bin/php-cgi

安装nginx

tar zxvf nginx-0.6.34.tar.gz
cd nginx-0.6.34/
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module
make && make install
cd ../

创建nginx配制文件

rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf

输入以下内容

user www 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 {
use epoll;
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 80;
server_name localhost;
index index.html index.htm index.php;
root html;

#charset koi8-r;

#access_log logs/host.access.log main;

location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:10080;
fastcgi_index index.php;
include fcgi.conf;
}

#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 /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /\.ht {
# deny all;
#}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}

# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

在/usr/local/webserver/nginx/conf/目录中创建fcgi.conf文件
输入以下内容

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;

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_FILENAME $document_root$fastcgi_script_name;
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 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;

启动nginx

ulimit -SHn 51200
/usr/local/webserver/nginx/sbin/nginx

注意:如果是使用ubuntu系统,直接使用ulimit会提示没有权限执行该命令,但如果加上了sudo来执行,又会提示没有这个命令。这里因为ulimit是内建shell脚本,可采用如下方法执行:

sudo sh "ulimit -SHN 51200"

最后让开机自动运行nginx+php+mysql

sudo vim  /etc/rc.local

在文件末尾添加

/usr/local/webserver/mysql/bin/mysqld_safe --user=mysql &
ulimit -SHn 51200
/usr/local/webserver/nginx/sbin/nginx

机器人 2008-12-7 23:29 于 北京

此条目发表在 linux/server 分类目录,贴了 , , , , 标签。将固定链接加入收藏夹。

nginx0.6.34+php-5.27 fastcgi 安装》有 28 条评论

  1. 小黑米 说:

    ulimit -SHn 51200

    这个啥意思?

  2. 机器人 说:

    为nginx设置资源分配的极限值吧!!

  3. 小黑米 说:

    偶一直没敢设置这个 不大懂什么意思

  4. 机器人 说:

    具体影响有多大?没有测试过!

  5. 机器人 说:

    呵呵,升级也太快了吧!!哦,我也去看了一下。好像是在5.2.7里一些BUG修正有问题,所以这个版本才这么急的推出。。。

  6. effemnada 说:

    yo, hqlong.com great name for site)))

  7. hqlong 说:

    my nickname is hqlong!!thank you!

  8. tommy 说:

    Ccr2gm gIcbEw9n3n6JdaL72z0Fu

  9. Sherly Rusell 说:

    I really enjoyed your writing. The topic is one I have been trying to get info on.

  10. The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I do know it was my option to read, however I truly thought youd have something interesting to say. All I hear is a bunch of whining about something that you possibly can repair for those who werent too busy on the lookout for attention.

  11. It is legitimate happiness to study you blog!

  12. Pingback 引用通告: St Albans Van Rentals

  13. Pingback 引用通告: supplements for better memory

  14. buy steroids 说:

    interesting article but I’m not sure if the author is correct here.want ot learn about our website you should visit our website we are the top leader in the interest industry of online information and planning of ph@rma stuff, go to us

  15. 崔舍保食 说:

    杭州最好的夜场是杭州东方魅力www.dongfangmeili.cn

    杭州最好的ktv是哪儿?是杭州东方魅力www.dongfangmeili.cn

    杭州夜场招聘首选杭州东方魅力www.dongfangmeili.com.cn

    杭州最好的夜总会是杭州东方魅力www.dongfangmeili.com.cn

    杭州东方魅力官方网站欢迎你 联系电话:13666653761 官方微信:dongfangmeili

  16. Fausto Dubre 说:

    I like to have letters with U.S. commemorative stamps on them; I collect these. How are your letters stampedor are they metered (yech)?

  17. Pingback 引用通告: szkło bezpieczne piotrków

  18. Pingback 引用通告: best halloween creative ideas and horror artwork

  19. Pingback 引用通告: This is why this video will make you like Indie Euro Rock again!

  20. Pingback 引用通告: ingray band music videos live

  21. Pingback 引用通告: wordpress visual builder

  22. Pingback 引用通告: convert animated gif to video free

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>