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 于 北京
ulimit -SHn 51200
这个啥意思?
为nginx设置资源分配的极限值吧!!
偶一直没敢设置这个 不大懂什么意思
具体影响有多大?没有测试过!
PHP 5.2.8发布了~
呵呵,升级也太快了吧!!哦,我也去看了一下。好像是在5.2.7里一些BUG修正有问题,所以这个版本才这么急的推出。。。
yo, hqlong.com great name for site)))
my nickname is hqlong!!thank you!
Hi, I used to buy just
google
Ccr2gm gIcbEw9n3n6JdaL72z0Fu