zoukankan      html  css  js  c++  java
  • Linux 配置 Nginx + PHP 7 环境

    配置 Nginx

    • 系统更新
    sudo yum -y install epel-release
    sudo yum update -y
    
    • 使用 yum 安装 nginx ,并设置开机启动
    yum install -y nginx
    systemctl start nginx
    systemctl enable nginx
    
    • 查看 nginx 版本
    nginx -v
    
    • 查看 nginx 运行状态
    ps -ef | grep nginx
    

    配置 PHP

    • 安装 yum 源
    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    
    
    
    • 安装 PHP 及组件
    yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-ldap
    
    • 启动 PHP 并设置为开机启动
    systemctl start php-fpm
    systemctl enable php-fpm
    
    • 查看 PHP 版本及运行状态
    php -v
    
    • 查看 PHP 运行状态
    ps -ef | grep php-fpm
    

    修改 Nginx 配置

    vim /etc/nginx/conf.d/default.conf
    
    找到第一个location中的这一行
        index  index.html index.htm;
        修改为:
        index  index.php index.html index.htm; #添加index.php
            
        把FastCGI server这行下面的location的注释去掉,并修改成下面这样子
         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
         #
         location ~ .php$ {
             root            /usr/share/nginx/html;  #网站根目录
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             include        fastcgi_params;
         }
    
    
    service nginx restart   #重启nginx
    service php-fpm start   #开启php-fpm
    
    • 在网站根目录新建 index.php 文件
    vim /usr/share/nginx/html/index.php
    <?php
    phpinfo();
    ?>
    
    • 在浏览器中输入虚拟机ip,已经可以看到phpinfo的信息了
  • 相关阅读:
    HDU 1213 How Many Tables 并查集 寻找不同集合的个数
    哈哈哈哈哈
    P2251 质量检测(ST表)
    poj3264Balanced Lineup(倍增ST表)
    bzoj1088扫雷(搜索)
    P2258 子矩阵(dp)
    codevs1369 xth 砍树(线段树)
    5.3QBXT模拟赛
    codevs1690 开关灯(线段树)
    zhw大神线段树姿势
  • 原文地址:https://www.cnblogs.com/nethrd/p/10951088.html
Copyright © 2011-2022 走看看