Nginx+PHP平台搭建(Linux+Nginx+Mysql+PHP)

前置条件:Nginx已安装好。Nginx安装很简单,只要安装好一些必要地依赖库就可以了

开始:

1. 下载php-5.6.2      wget http://cn2.php.net/distributions/php-5.6.2.tar.gz,然后解压并进入解压后的目录(因为php5.3.0以后版本默认集成了fpm包,所以直接下载即可,不需要另外下载fpm压缩包);

2.  安装php必要的一些准备库

3. 

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=mysqlnd --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir=/usr/local/libxml --with-gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=usr/local/png --with-freetype-di=/usr/local/fretype --with-zlib-dir=/usr/local/zlib --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-pear --with-curl --with-openssl

4. 

make && make install

5.  

cp php.ini-production /usr/local/php/etc/php.ini


6. 

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf


7. 测试配置文件是否正确:

 

8. 显示成功后,进入下一步,启动fpm:

 9. 提示找不到用户php-fpm的uid,此时应修改fpm的配置文件/etc/local/php/etc/php-fpm.conf,找到user和group这一行,修改为当前用户名,再次启动即可,若要开机自动启动,执行: chkconfig php-fpm on。可以使用命令查看是否已启动: netstat -ant | grep 9000

10. 修改nginx的配置文件:

[root@cent_Node1 conf]# vim nginx.conf


    log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'

    '$host "$request_uri" $status'

    '"$http_referer" "$http_user_agent"';

    sendfile on;

    tcp_nopush on;

    keepalive_timeout 30;

    client_header_timeout 3m;

    client_body_timeout 3m;

    send_timeout 3m;

    connection_pool_size 256;

    client_header_buffer_size 1k;

    large_client_header_buffers 8 4k;

    request_pool_size 4k;

    output_buffers 4 32k;

    postpone_output 1460;

    client_max_body_size 10m;

    client_body_buffer_size 256k;

    client_body_temp_path /Nginx_1711/nginx/client_body_temp;

    proxy_temp_path /Nginx_1711/nginx/proxy_temp;

    fastcgi_temp_path /Nginx_1711/nginx/fastcgi_temp;

    fastcgi_intercept_errors on;

    tcp_nodelay on;

    gzip on;

    gzip_min_length 1k;

    gzip_buffers 4 8k;

    gzip_comp_level 5;

    gzip_http_version 1.1;

    gzip_types text/plain application/x-javascript text/css text/htm application/xml;


server

{

    listen 3292;

    server_name localhost;

    index index.html index.htm index.php;

    root /Nginx_1711/nginx/html;


    location ~ \.php$ {

        include fastcgi_params;

        fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /Nginx_1711/nginx/html$fastcgi_script_name;

    }


}


}

11. 编写测试php的文件:

<?php

phpinfo();

?>

12 显示如下,成功配置好nginx和php:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值