• CentOS7 安装LNMP(Linux+Nginx+MySQL+PHP)


        由于工作须要,须要学习php,本来想安装lamp的可是考虑到如今nginxserver有良好的性能且应用广泛。

    这里我决定搭建Linux(CentOS7+Nginx+MySQL+PHP)下的webserver。

    一、安装httpd。
    yum install -y httpd
    安装完毕之后使用以下命令启动httpd服务:
    systemctl start httpd.service #启动apache
    systemctl stop httpd.service #停止apache
    systemctl restart httpd.service #重新启动apache
    systemctl enable httpd.service #设置apache开机启动
        能够在浏览器中输入server所在的主机的IP就可以看到apache的欢迎界面。

    要在另外一台主机上实现这样的訪问,须要关闭系统的防火墙。

        在CentOS7中,改动防火墙的机制已经做了改动,在CentOS 6.x系统中能够使用以下命令:
    service iptables stop
    chkconfig iptables off // 开机禁止启动

        而在CentOS7中仅仅能使用以下命令。假设使用上面的命令并不会报不论什么错误。可是起不到关闭防火墙的效果:
    systemctl stop firewalld.service
    systemctl disable firewalld.service //禁止防火墙开机启动
    关闭SeLinux
        使用getenforce命令能够查看SeLinux的状态,SeLinux有三种状态。分别为enforcing、permissive和disabled。

    由于我们的server仅仅在内部使用。所以这里我们选择全然关闭(disabled)。

    详细的做法为改动/etc/sysconfig/selinux文件,详细操作能够看里面的说明。

        安装成功httpd(apache)的效果图为:
    这里写图片描写叙述
    二、安装MySQL数据库。
    MySQL数据库。新版本号已经更名为Mariadb。所以这里须要安装Mariadb,能够使用以下的命令进行安装:
    yum install -y mariadb
    安装完毕以后使用以下的命令开启数据库服务:
    systemctl start mariadb.service #启动MariaDB
    systemctl stop mariadb.service #停止MariaDB
    systemctl restart mariadb.service #重新启动MariaDB
    systemctl enable mariadb.service #设置开机启动
    三、安装PHP。

    使用以下的命令能够安装PHP:
    yum -y install php
    使用以下的命令安装php对Mariadb的支持:
    yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
    使用以下的命令重新启动Mariadb和httpd服务:
    systemctl restart mariadb.service #重新启动MariaDB
    systemctl restart httpd.service #重新启动apache
    四、安装nginx。

      这里使用的是nginx做反向代理,将其client通过80port请求的.php内容代理到apacheserver上。


    使用以下命令安装nginx:
    yum install -y nginx
    要想使用nginx做反向代理,须要改动Apache的httpd和nginx的配置文件,使其监听不同的port。这里我们使用nginx监听80port,使用Apache监听8080port,这里我们分别配置Apache和nginx的配置文件,改动结果例如以下:
    (1)Apache配置文件:/etc/httpd/conf/httpd.conf
    这里写图片描写叙述
    (2)nginx配置例如以下:
    这里写图片描写叙述

        这样。当用户在浏览器中訪问该server有关.php结尾的文件都会代理到监听8080port的Apacheserver。示比例如以下:
    (1)不指定8080port訪问:
    这里写图片描写叙述
    (2)指定訪问8080port。
    这里写图片描写叙述
  • 相关阅读:
    Input 银行卡验证
    记一次坑爹的加解密问题
    C# Html Agility Pack
    记一次坑爹的 “跨域” 问题
    FindControl的使用方法
    C#如何使用异步编程
    ReportViewer中设置ServerReport.ReportServerCredentials属性的方法
    C#中常用接口介绍
    谈谈C#中的接口
    DataTable与Linq相互转换
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/5245642.html
Copyright © 2020-2023  润新知