Fuck PHP (2) Linux+Nginx+PHP配置

1、安装Nginx

(1)下载源码

(2)./configure

(3)make

(4)sudo make install


2、安装PHP

(1)sudo aptitude install php5-cli php5-cgi spawn-fcgi


3、配置Nginx


如果:

(1)网站的php文件在/data1/mediawiki/index.php

(2)端口80;

(3)访问 http://127.0.0.1/wiki 得到 /data1/mediawiki/index.php 页面;

(3)访问 http://127.0.0.1/wiki/index.php 得到 /data1/mediawiki/index.php 页面,则如下配置:


43 server {
44 listen 80;
45 server_name 127.0.0.1;
46
47 location /wiki {
48 root /data1/mediawiki;
49 index index.php index.html index.htm;
50 }
51
52 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
53
54 location ~ \.php$ {
55 root /data1/mediawiki;
56 fastcgi_pass 127.0.0.1:9000;
57 fastcgi_index index.php;
58 fastcgi_param SCRIPT_FILENAME /data1/mediawiki/$fastcgi_script_name;
59 include fastcgi_params;
60 }
61
62 }


4、重启生效

(1)/usr/local/nginx $ sudo ./sbin/nginx -s reload

(2)spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -f /usr/bin/php-cgi


5、测试

(1)访问 http://127.0.0.1/wiki

你可能感兴趣的:(linux)