手机版
你好,游客 登录 注册
背景:
阅读新闻

Ubuntu下安装Nginx+PHP+MySQL+FastCGI

[日期:2010-08-05] 来源:Ubuntu社区  作者:damnyoulove [字体:大 中 小]

接着配置虚拟主机,默认虚拟主机路径是/etc/nginx/sites-available/default

vi /etc/nginx/sites-available/default

 

[...]

server {

        listen   80;

        server_name  _;

 

        access_log  /var/log/nginx/localhost.access.log;

 

        location / {

                root   /var/www/nginx-default;

                index  index.php index.html index.htm;

        }

 

        location /doc {

                root   /usr/share;

                autoindex on;

                allow 127.0.0.1;

                deny all;

        }

 

        location /images {

                root   /usr/share;

                autoindex on;

        }

 

        #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   /var/www/nginx-default;

        }

 

        # 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$ {

                fastcgi_pass   127.0.0.1:9000;

                fastcgi_index  index.php;

                fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;

                include        /etc/nginx/fastcgi_params;

        }

 

        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        location ~ /\.ht {

                deny  all;

        }

}

[...]

 

可以直接复制过去,以免修改过程中出现错误。

修改好了,重启nginx

/etc/init.d/nginx restart

在默认目录/var/www/nginx-default建立PHP文件info.php

 

vi /var/www/nginx-default/info.php

 

<?php

phpinfo();

?>

 

在浏览器访问http://www.6688.cc/info.php


在 Server API 行里会看到PHP通过FastCGI运行。支持MySQL

好了,安装到此结束。

linux
相关资讯       Ubuntu服务器  Nginx 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款