zoukankan      html  css  js  c++  java
  • centos7 搭建 php7 + nginx (2)

    • 安装php

    php下载地址

    # 避免出错,先安装下面
    yum install libzip libzip-devel libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl-devel libjpeg-devel libpng libpng-devel freetype-devel gmp-devel readline-devel libxslt-devel
    
    # 下载
    wget https://www.php.net/distributions/php-7.3.11.tar.gz
    
    # 解压
    tar -zxvf  php-7.3.11.tar.gz
    
    cd /data/source/php-7.3.11
    
    # 编译
    ./configure 
     --prefix=/usr/local/php7
     --with-config-file-path=/usr/local/php7/conf
     --enable-fpm
     --with-fpm-user=www
     --with-fpm-group=www
     --disable-rpath
     --enable-soap
     --with-libxml-dir
     --with-xmlrpc
     --with-openssl
     --with-mhash
     --with-pcre-regex
     --with-zlib
     --enable-bcmath
     --with-bz2
     --enable-calendar
     --with-curl
     --enable-exif
     --with-pcre-dir
     --enable-ftp
     --with-gd
     --with-openssl-dir
     --with-jpeg-dir
     --with-png-dir
     --with-zlib-dir
     --with-freetype-dir
     --enable-gd-jis-conv
     --with-gettext
     --with-gmp
     --with-mhash
     --enable-mbstring
     --with-onig
     --with-mysqli=mysqlnd
     --with-pdo-mysql=mysqlnd
     --with-zlib-dir
     --with-readline
     --enable-shmop
     --enable-sockets
     --enable-sysvmsg
     --enable-sysvsem 
     --enable-sysvshm 
     --with-libxml-dir
     --with-xsl
     --enable-zip
     --with-pear
     --enable-wddx
    
    # 编译的时候,可能会有各种未知错误出现。直接百度就好,基本都很容易找到解决方案
    
    # 安装
    make && make install
    
    
    • 配置php

    # 将源码包配置文件拷贝到安装目录
    mkdir -p /usr/local/php7/conf
    cp php.ini-development /usr/local/php7/conf/php.ini
    
    # 拷贝php-fpm配置文件
    cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
    cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
    
    # 添加用户
    groupadd www
    useradd -g www www
    
    • 设置php-fpm开机启动

    vi /lib/systemd/system/php-fpm.service
    

    内容如下,路径改成自己的php路径

    [Unit]
    Description=php-fpm
    After=network.target
    [Service]
    Type=forking
    ExecStart=/usr/local/php7/sbin/php-fpm
    PrivateTmp=true
    [Install]
    WantedBy=multi-user.target
    
    # 设置开机启动
    systemctl enable php-fpm.service
    
    # 停止开机自启动
    systemctl disable php-fpm.service         
    
    # 启动nginx服务
    systemctl start php-fpm.service          
     
    # 停止服务
    systemctl stop php-fpm.service           
     
    # 重新启动服务
    systemctl restart php-fpm.service        
     
    # 查看所有已启动的服务
    systemctl list-units --type=service     
     
    # 查看服务当前状态
    systemctl status php-fpm.service          
    
    • 配置nginx解析php

    vi /usr/local/nginx/conf/nginx.conf
    
    
    # 内容如下
            location ~ .php$ {
                root           html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    
    # 重启nginx就可以了
    
  • 相关阅读:
    关于剪切板
    编译器选项
    【转】预编译头没有使用的问题
    【转】fatal error C1900: “P1”(第“20081201”版)和“P2”(第“20080116”版)之间 Il 不匹配
    pImpl
    HIVE 2.3.4 本地安装与部署 (Ubuntu)
    计算机网络 自顶向下 复习提要 数据链路层
    计算机网络 自顶向下 复习提要 网络层2
    计算机网络 自顶向下 复习提要 网络层
    计算机网络 自顶向下 复习提要 传输层(TCP)
  • 原文地址:https://www.cnblogs.com/qq917937712/p/11792024.html
Copyright © 2011-2022 走看看