在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
装完了nginx和php-5.5,配置好了nginx调用php后,就开始启动php-fpm。 使用下面的命令 复制代码 代码如下: /usr/local/php/sbin/php-fpm 就可以启动了。 在nginx的目录中创建个php的检测脚本index.php 结果在打开http://localhost/index.php 悲剧的发现居然无法打开 。查看日志文件,看了下报错原因 复制代码 代码如下: 2013/07/01 22:34:26 [error] 3214#0: *64 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.168.19, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.168.140" 查看下端口 。看到php-fpm的9000端口已经打开了,说明php-fpm是没什么问题的,问题出在了nginx上了。可能是我的配置文件有问题。 找到nginx加载php配置的那块。另外参考了下网上nginx的配置文件。 在第69行有一个调用脚本路径 复制代码 代码如下: fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 我把路径改下,改成下面的就可以了。 复制代码 代码如下: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; http://localhost/index.php 可以出现php的版本信息了。 php-fpm不用再依赖其它的fastcgi启动器,比如lighttpd的spawn-fcgi。 一.下载php-fpm 二.编译好php后,修改配置文件 复制代码 代码如下: user www www; worker_processes 10; error_log logs/error.log notice; 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 mime.types; default_type application/octet-stream; charset gb2312; 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; { listen 80; server_name 192.168.1.2; index index.html index.htm index.php; root /EBS/www; if (-d $request_filename) { rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent; } location ~ .*\.php?$ { include fcgi.conf fastcgi_pass 127.0.0.1:9000; 新建配置文件 复制代码 代码如下: /usr/local/nginx/conf/fcgi.conf 注:nginx自带了一个配置文件,/usr/local/nginx/conf/fastcgi_params,该配置文件缺少粗体字体的部分,会造成访问php文件时报404错误。 复制代码 代码如下: 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; 四 配置XCache 添加: 复制代码 代码如下: [xcache-common] zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so [xcache.admin] ; Change xcache.admin.user to your preferred login name xcache.admin.user = "admin" ; Change xcache.admin.pass to the MD5 fingerprint of your password ; Use md5 -s "your_secret_password" to find the fingerprint xcache.admin.pass = "5f4dcc3b5aa765d61d8327deb882cf99" [xcache] ; Change xcache.size to tune the size of the opcode cache xcache.size = 24M xcache.shm_scheme = "mmap" xcache.count = 2 xcache.slots = 8K xcache.ttl = 0 xcache.gc_interval = 0 ; Change xcache.var_size to adjust the size of variable cache xcache.var_size = 8M xcache.var_count = 1 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 xcache.test = Off xcache.readonly_protection = On xcache.mmap_path = "/tmp/xcache" xcache.coredump_directory = "" xcache.cacher = On xcache.stat = On xcache.optimizer = Off [xcache.coverager] xcache.coverager = On xcache.coveragedump_directory = "" 5、重启PHP模块 6、另外两种加速模块: 复制代码 代码如下: wget http://pecl.php.net/get/APC-3.0.19.tgz cd APC-3.0.19 /usr/local/php/bin/phpize ./configure --enable-apc --enable-apc-mmap --with-apxs=/EBS/apache/bin/apxs --with-php-config=/EBS/php/bin/php-config make make install 6.2 eaccelerator wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.zip cd eaccelerator-0.9.5.3 /usr/local/php/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=/EBS/php/bin/php-config make make install vi php.ini zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-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" 五、使用nginx对应多台facgi服务器 |
请发表评论