• Centos7 Lnmp的环境搭建


     

     centos  版本

    [root@localhost ~]# cat /etc/redhat-release

    CentOS Linux release 7.2.1511 (Core)

    关闭防火墙

     systemctl stop firewalld
     setenforce 0

    1配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有nginx软件包)

    wget http://www.atomicorp.com/installers/atomic

    sh ./atomic #执行下载的yum源脚本

    yum check-update 

    2、安装开发包和库文件

    yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng

     

    yum -y install libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel

     

    yum -y install gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2

     

    yum -y install  libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

    3、安装nginx

     

    yum -y install nginx

     

    systemctl start nginx

     

    chkconfig --levels 235 nginx on (假如开机自启)

     

    4、安装mysql

    yum install mysql mysql-server mysql-devel

     

    systemctl start mariadb

     

    systemctl enable mariadb.service

    5、安装php

    yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap

     

    yum -y install php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap

     

    //安装php和所需组件使PHP支持MySQL、FastCGI模式

     

    yum -y install php-tidy php-common php-devel php-mysql

    yum -y install  php-fpm

    systemctl start php-fpm

    systemctl enable php-fpm.service

    #假如开机自启

    6、配置nginx支持php

    mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak

    //将配置文件改为备份文件

    cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf

    //由于原配置文件要自己去写因此可以使用默认的配置文件作为配置文件

    //修改nginx配置文件,添加fastcgi支持

    vi /etc/nginx/nginx.conf

    index index.php index.html index.htm;

     

    //加入index.php

    location ~ .php$ {

                root           /usr/share/nginx/html;

                fastcgi_pass   127.0.0.1:9000;

                fastcgi_index  index.php;

                fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;

                include        fastcgi_params;

            }

    //将以上代码注释去掉,并修改成nginx默认路径

    7、配置php

    //编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1

     vi /etc/php.ini

    cgi.fix_pathinfo = 1

    8、重启nginx php-fpm

    systemctl restart nginx.service

    systemctl restart php-fpm

     

    9、建立info.php文件

    vi /usr/share/nginx/html/info.php

    <?php

       phpinfo();

    ?>

    10、测试nginx是否解析php

    本地浏览器输入:192.168.159.142/info.php

    显示php界面  环境搭建成功

  • 相关阅读:
    调用接口直接下载文件
    Oracle函数简单使用
    JAVA面试题刷题资料
    跨域
    ORACLE JOB
    C# 面试知识点网络文档整理
    GetBuffer 与ToArray区别,解决问题场景
    JQuery选择器分类
    C#判断字符串中含有多少个汉字
    XPATH中text()和string()的使用区别
  • 原文地址:https://www.cnblogs.com/AZhuang/p/7382455.html
Copyright © 2020-2023  润新知