CentOS 6.5 搭建PHP环境(Nginx+MariaDB+PHP7)(2)

# 配置文件
# cp php.ini-development /usr/local/php/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm

# 启动
# /etc/init.d/php-fpm

# 查看是否启动
ps aux | grep php

修改nginx配置,监听*.php的文件

# vim /usr/local/nginx/conf/nginx.conf

简单配置如下:

user  www www;

worker_processes 10;

#error_log  /data/logs/nginx_error.log  crit;


#pid        logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
{
    use epoll;

worker_connections 51200;
}

http
{
    include      mime.types;
    default_type  application/octet-stream;

#charset  gbk;
   
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    #client_max_body_size 8m;

server_tokens off;

expires      1h;

sendfile on;
    tcp_nopush    on;
    keepalive_timeout 60;
    tcp_nodelay on;

error_page  404  /404.jpg;

fastcgi_connect_timeout 20;
    fastcgi_send_timeout 30;
    fastcgi_read_timeout 120;
    fastcgi_buffer_size 256k;
    fastcgi_buffers 8 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_temp_path /dev/shm;

gzip on;
    gzip_min_length  2048;
    gzip_buffers    4 16k;
    gzip_http_version 1.1;
    gzip_types  text/plain  text/css application/xml application/x-javascript ;

log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" $http_x_forwarded_for';

server {
        listen      80;
        server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
            root  html;
            index  index.html index.htm index.php;
        }

#rewrite index.php/^(.*)$ idex.php?s=/$1 last ;

#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  html;
        }
location ~ \.php$
            {
        fastcgi_pass  127.0.0.1:9000;
              fastcgi_index index.php;
            include fastcgi.conf;
            }
}


#################  include  ###################

#    include block_ips.conf ;
#    include vhost/*.conf ;

#强制域名访问对应域名的conf
#    server {
#        listen 80 default ;
#        server_name _;
#        return 404;
#    }
}

最后phpinfo(),成功。

CentOS 6.5 搭建PHP环境(Nginx+MariaDB+PHP7)

更多Nginx相关教程见以下内容

CentOS 6.2实战部署Nginx+MySQL+PHP

使用Nginx搭建WEB服务器

搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程

CentOS 6.3下Nginx性能调优

CentOS 6.3下配置Nginx加载ngx_pagespeed模块

CentOS 6.4安装配置Nginx+Pcre+php-fpm

Nginx安装配置使用详细笔记

Nginx日志过滤 使用ngx_log_if不记录特定日志

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

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