您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Web开发 >> 今天用ubuntu安装nginx+php5+mysql+fastcgi发现的问题

今天用ubuntu安装nginx+php5+mysql+fastcgi发现的问题

来源:网络整理     时间:2016/5/27 4:25:26     关键词:ubuntu安装,fastcgi

关于网友提出的“今天用ubuntu安装nginx+php5+mysql+fastcgi发现的问题”问题疑问,本网通过在网上对“今天用ubuntu安装nginx+php5+mysql+fastcgi发现的问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题:今天用ubuntu安装nginx+php5+mysql+fastcgi发现的问题
描述:

今天想学习一下WEB服务器的架设 

用的是 乌班图 12.04的版本

先安装了 mysql数据库之后安装了 nginx  php5   spawn-fcgi   

修改了相应的配置文件以后开始 做php-cgi的运营 但是问题出现了 执行完下面的语句以后

sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

提示spawn-fcgi:invalid port: 0  不知道什么原因 是因为我的配置文件有问题 还是 怎么的?

这是default文件的配置

server {
        listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6 ## listen for ipv6

        root /var/www;
        index index.html index.htm index.php;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }

        # Only for nginx-naxsi : process denied requests
        #location /RequestDenied {
                # For example, return an error code
                #return 418;
        #}

        #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 /usr/share/nginx/www;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
        #       fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #       # With php5-cgi alone:
                fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
        #       fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }
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         $request_filename;
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   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

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;

fastcgi_param   HTTPS                   $https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;
fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;

另外我想请教一下各位高手,spawn-fcgi和php5-fpm都是php-cgi的进程管理器 是不是安装其中之一 就可以的 而不需要两个同时都安装吧?


解决方案1:

location ~ \.php$ {
    root           /etc/nginx/sites-enabled/default;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /etc/nginx/sites-enabled/default$fastcgi_script_name;
    include        fastcgi_params;
}
回复 @我不明白 : 同时还要注意Nginx里的PHP解析配置。

解决方案2:

PHP现在已经有了自己的fastcgi管理器php-fpm,不需要spawn-fcgi了。

安装:
sudo apt-get install php5-fpm
服务管理:
sudo service php5-fpm {start|stop|status|restart|reload|force-reload}
配置文件:
/etc/php5/fpm/php-fpm.conf
/etc/php5/fpm/pool.d/www.conf


以上介绍了“今天用ubuntu安装nginx+php5+mysql+fastcgi发现的问题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1331925.html

相关图片

相关文章