nginx+php部署

(1) 下载并安装nginxphp

 mkdir nginx-src && cd nginx-src
 wget http://nginx.org/download/nginx-1.7.3.tar.gz
 tar xzf nginx-1.7.3.tar.gz 
 cd nginx-1.7.3
 ./configure --prefix=/home/cyw/tools/nginx/source
 make
 make install

其中,--prefix表示了安装的目录。就像在window中选择安装文件的路径同样。安装完成后,在source文件夹下能够看到以下的文件结构:html

 

(2) 下载并安装phpnginx

wget http://cn2.php.net/distributions/php-5.4.7.tar.gz
tar zvxf php-5.4.7.tar.gz
cd php-5.4.7
./configure  --prefix=/home/oduyub/tools/php/source --enable-fastcgi --enable-debug --enable-fpm
make
make install

make步骤要花费比较长的时间。安装完成后,能够在文件夹下面看到以下的文件夹列表。安装完成后,能够在source文件夹下看到以下的文件结构:服务器

安装完成后,能够在source文件夹下看到以下的文件目录:php-fpm

(3) 启动php服务测试

  采用的是php-fpm的启动方式。url

启动命令为:.net

> cd /sbin/

> ./php-fpm

启动后,执行debug

  ps -ef|grep php

能够看到输出以下:3d

(4) 启动nginx服务

启动以前须要先修改nginx.conf文件

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  html$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

【注意】须要将上面的#去掉。

注意root行的html和fasstcgi_param中的/html须要对应。代表php寻找的路径

> cd /sbin/

>sudo ./nginx -s reload

输入 http://服务器地址:端口号/

若是能出现Nginx的首页,说明nginx安装成功

 

(5) 测试是否能够启动

写一个简单的php的测试文件index.php

<?php

  phpinfo()

>

在url中输入以下的连接: http://服务器地址:端口号/index.php。

若是出现php的统计网页,就代表能够在Php中执行指令了。  

 

(5) 错误列表

相关文章
相关标签/搜索