[参考]搭建Nginx 0.5.35 + php 5.2.5 (ArchLinux)
时间:2008-04-06
来源:互联网
pacman -S php
增加php5扩展模块
pacman -S gd vi /etc/php/php.ini
安装Zend Optimizer,到Zend官方网站下载相应CPU的版本,解压后运行./install
pacman -S php-eaccelerator vi /etc/php/php.ini
zend_extension=/usr/lib/php/20060613/eaccelerator.so eaccelerator.shm_size=16 eaccelerator.cache_dir=/tmp/eaccelerator eaccelerator.enable=1 eaccelerator.optimizer=1 eaccelerator.check_mtime=1 eaccelerator.debug=0 eaccelerator.filter="" eaccelerator.shm_max=0 eaccelerator.shm_ttl=0 eaccelerator.shm_prune_period=0 eaccelerator.shm_only=0 eaccelerator.compress=1 eaccelerator.compress_level=9 |
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so |
创建web服务用户
groupadd www useradd -md /home/httproot -g www -p Insecure0 nginx chmod +w /home/httproot
pacman -S lighttpd
启动php-cgi进程,监听127.0.0.1的10080端口,进程数为16,用户为nginx:
spawn-fcgi -a 127.0.0.1 -p 10080 -C 16 -u nginx -f php-cgi
pacman -S nginx
vi /etc/nginx/conf/nginx.conf
user nginx; worker_processes 10; error_log logs/error.log crit; #pid logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include conf/mime.types; default_type application/octet-stream; charset gb18030; server_names_hash_bucket_size 128; #sendfile on; #tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; gzip on; gzip_min_length 1k; gzip_buffers 4 8k; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/html application/xml; server { listen 80; server_name localhost; index index.html index.php; root /home/httproot; if (-d $request_filename) { rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent; } location ~ .*\.php?$ { root /home/httproot; include conf/fastcgi_params; fastcgi_pass 127.0.0.1:10080; fastcgi_index index.php; } 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 /data1/logs/access.log main; } |
ulimit -SHn 51200 /etc/rc.d/nginx start
su nginx vi /home/httproot/index.php
phpinfo();
?>
netstat -l
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:10080 *:* LISTEN
tcp 0 0 *:cvspserver *:* LISTEN
tcp 0 0 *:http *:* LISTEN
优化Linux内核参数
vi /etc/sysctl.conf
net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.ip_local_port_range = 5000 65000 |
使配置立即生效:
/sbin/sysctl -p
vi /etc/rc.conf
DAEMONS=(................nginx); |
vi /etc/profle
ulimit -SHn 51200 spawn-fcgi -a 127.0.0.1 -p 10080 -C 16 -u nginx -f php-cgi |
参考文献:http://hi.baidu.com/vincent%5Fluo/bl...1b21bba6a.html
http://techpush.com/archives/install...slicehost-vps/
作者: store88 发布时间: 2008-04-06
作者: cwjiof 发布时间: 2008-04-06
作者: jarryson 发布时间: 2008-04-07
作者: gogonkt 发布时间: 2008-04-13
照的你方法安装好nginx后,没办法启动啊,所示如下:
:: Checking configuration [BUSY] [emerg]: getgrnam("nginx") failed in /etc/nginx/conf/nginx.conf:1 configuration file /etc/nginx/conf/nginx.conf test failed [FAIL]
作者: lwkyy 发布时间: 2009-10-11
作者: lwkyy
不懂为什么要通过安装 lighttpd 来得到spawn-fcgi,AUR中有个spawn-fcgi 1.6.3-1难到不能使用吗?
|
如果用AUR中的spawn-fcgi的话,教程里面就要讲解aur和makepkg的知识(当然对archer来说,一般都知道aur)。
作者: jqxl0205 发布时间: 2009-10-11
作者: lwkyy 发布时间: 2009-10-11
WEB目录我设置为/home/httproot 目录的权限是700,
drwx------ 2 http http 4096 10月 11 02:05 httproot
问题是这样的:在浏览器里访问静态文件时正常,但一访问php文件时就无任何显示,看access.log文件得知访问都是500请求,而访问像html这样的文件时是正常的200。
nginx.conf设置是这样的
user http http; worker_processes 8; error_log logs/error.log crit; #pid logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; #charset utf-8; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; #access_log logs/access.log main; sendfile on; tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; #vhosts settings include vhosts.conf; }
server { listen 80; server_name localhost; index index.html index.php; root /home/httproot; autoindex on; #error_page 404 /404.html; location / { root /home/httproot; index index.html index.php; } location ~ .*\.php?$ { root /home/httproot; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } 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 /var/log/nginx/access.log main; }
127.0.0.1 - - [11/Oct/2009:02:13:05 +0000] "GET /index.php HTTP/1.1" 500 5 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.8 Safari/532.2" -
spawn-fcgi -a 127.0.0.1 -p 9000 -c 16 -u http -f php-cgi
感觉问题还是出在nginx与PHP之间的通信上,但不知如何解决。请高人教我看看!
作者: lwkyy 发布时间: 2009-10-13
sudo pacman -S php php-cgi
这样就可以了
作者: gfreezy 发布时间: 2009-11-01
作者: cwjiof 发布时间: 2009-11-01
作者: gfreezy 发布时间: 2009-11-01
作者: leitian 发布时间: 2009-11-17
不过我一直用 lighttp + php + mysql
留个脚印,方便以后查阅
作者: carbonjiao 发布时间: 2009-11-18
我平时也用的是lighttpd, 看到网上到处都说nginx牛B
看了网上的一个BLOG,把lighttpd的 epoll模式打开,速度一样很快的
平时用httpd的目的就为了arch pkgs共享用,最近用来做gitweb来用
找个时间试一下nginx看看,看了一下配置,好像挺容易上手的
作者: axlrose 发布时间: 2009-11-18
作者: sanyork 发布时间: 2009-11-18
我只在本机上使用,连接数非常有限。
作者: zswlb9999 发布时间: 2009-11-18
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
其中的$document_root是在何处定义的?
我将$document_root改为我的PHP文件所在目录, 如改为/data 即
/data/$fastcgi_script_name;
就正常了。
作者: zswlb9999 发布时间: 2009-12-02
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28