Ubuntu下安装Nginx+PHP+MySQL+FastCGI(3)

接着配置虚拟主机,默认虚拟主机路径是/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   ;

#}

# 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();

?>

在浏览器访问

Ubuntu下安装Nginx+PHP+MySQL+FastCGI


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

好了,安装到此结束。

linux

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wydddx.html