zoukankan      html  css  js  c++  java
  • 安装php并使用nginx连接PHP

    版本是5.6.31

    安装前需要安装的包:

    yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel  freetype-devel -y

    编译如下:

    ./configure --prefix=/usr/local/php-5.6.31
    --with-config-file-path=/usr/local/php-5.6.31/etc --with-bz2 --with-curl
    --enable-ftp --enable-sockets --disable-ipv6 --with-gd
    --with-jpeg-dir=/usr/local --with-png-dir=/usr/local
    --with-freetype-dir=/usr/local --enable-gd-native-ttf
    --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar
    --with-gettext --with-libxml-dir=/usr/local --with-zlib
    --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd
    --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath --with-xpm-dir=/usr

    如果报错,可以参考:http://www.linuxidc.com/Linux/2014-05/102327.htm 或者 http://blog.sina.com.cn/s/blog_75a07c3b0101kcwb.html

    make 

    make install

    安装完成后需要配置Php,打开php.ini配置文件,修改如下参数为如下值,否则zabbix安装不了

    把安装源文件中的php.ini-production复制到/usr/local/php-5.6.31/etc下面,改名为php.ini

    修改如下参数:

    max_execution_time = 300
    memory_limit = 128M
    post_max_size = 16M
    upload_max_filesize = 2M
    max_input_time = 300
    date.timezone PRC
     
    然后:cp /usr/local/php-5.6.31/etc/php-fpm.conf.default /usr/local/php-5.6.31/etc/php-fpm.conf
     
    启动php-fpm
    [root@zabbixserver sbin]# ./php-fpm 
    [root@zabbixserver sbin]# netstat -lnt|grep 9000
    tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN   

    配置nginx连接php

    mkdir -p /data/logs/nginx/ # 用于存放nginx日志

    mkdir -p /data/site/zabbixserver.com/ # 站点根目录
    vim /data/site/zabbixserver.com/info.php
    <?php
    phpinfo();
    ?>

    在nginx.conf的http断中加上如下内容:

    ####################################start##############################
    
    server {
    listen 80;
    server_name zabbixserver.com;
    access_log /data/logs/nginx/zabbixserver.com.access.log main;
    
    index index.php index.html index.html;
    root /data/site/zabbixserver.com;
    
    location /
    {
    try_files $uri $uri/ /index.php?$args;
    }
    
    location ~ .*.(php)?$
    {
    expires -1s;
    try_files $uri =404;
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:9000;
    
    }
    }
    
    ################################end################################

    启动nginx的时候会报错,把以下取消注释就可以了

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

    启动nginx后

    补充一个地方:此时在zabbserver服务器上使用浏览器打开http://localhost,会打开nginx的欢迎页面,但是http://zabbixserver.com会报403;在其它机器上访问都是403,如果要访问nginx欢迎页面,可以修改下配置文件的端口号,然后加端口号访问。

    不过这时候在zabbixserver服务器上http://localhost:801

    具体为什么?过段时间再学这个

  • 相关阅读:
    SQL语句集(转)
    Oracle 数据库 for update / for update nowait 的区别
    XML 关键字
    JAVA 操作 DBF 文件数据库
    Hibernate 懒加载和 Json 序列化冲突
    MYSQL 语法大全自己总结的
    php-laravel中间件使用
    php-表单验证
    php-laravel安装与使用
    iOS 关于权限设置的问题
  • 原文地址:https://www.cnblogs.com/cq90/p/7230968.html
Copyright © 2011-2022 走看看