美文网首页
Centos7部署与配置PHP+Nginx+mysql

Centos7部署与配置PHP+Nginx+mysql

作者: 龟仙人_9103 | 来源:发表于2020-04-08 20:58 被阅读0次

    一、安装epel-release

    [root@ssd~]# yum -y install epel-release
    

    EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS和Scientific Linux,这个软件包会自动配置[yum]的软件仓库。

    二、获取PHP的yum源

    [root@ssd~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    [root@ssd~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    

    三.推荐安装以下,命令:yum install 扩展名。

    [root@ssd~]# yum install php72w php72w-fpm php72w-cli php72w-common php72w-devel php72w-gd php72w-pdo php72w-mysql php72w-mbstring php72w-bcmath
    

    安装完成以后,启动服务

    systemctl enable php-fpm.service
    systemctl start php-fpm.service
    

    四.安装php redis 扩展

    查看yum库包含的redis

    [root@ssd~]# yum list |grep php72w-pecl-redis
    

    没有发现yum没有redis扩展,所有不同直接通过yum直接安装redis扩展

    [root@ssd~]# yum -y install php72w-pecl-redis
    

    五.nginx已经安装完毕

    打开80端口
    查看firewalld 服务状态

    [root@ssd~]# systemctl status firewalld
    

    开启、重启、关闭、firewalld.service服务

    # 开启
    service firewalld start
    # 重启
    service firewalld restart
    # 关闭
    service firewalld stop
    

    查询、开放、关闭端口

    # 查询端口是否开放
    firewall-cmd --query-port=8080/tcp
    # 开放80端口
    firewall-cmd --permanent --add-port=80/tcp
    # 移除端口
    firewall-cmd --permanent --remove-port=8080/tcp
    
    #重启防火墙(修改配置后要重启防火墙)
    firewall-cmd --reload
    
    # 参数解释
    1、firwall-cmd:是Linux提供的操作firewall的一个工具;
    2、--permanent:表示设置为持久;
    3、--add-port:标识添加的端口;
    

    Install the prerequisites:

    sudo yum install yum-utils
    To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/releasever/basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    module_hotfixes=true

    [nginx-mainline]
    name=nginx mainline repo
    baseurl=http://nginx.org/packages/mainline/centos/releasever/basearch/
    gpgcheck=1
    enabled=0
    gpgkey=https://nginx.org/keys/nginx_signing.key
    module_hotfixes=true
    By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command:

    sudo yum-config-manager --enable nginx-mainline
    To install nginx, run the following command:

    sudo yum install nginx
    When prompted to accept the GPG key, verify that the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, and if so, accept it.

    六、配置nginx

    根据nginx不同安装找到他的配置路径,yum安装的默认配置地址一般在
    /etc/nginx/

    相关文章

      网友评论

          本文标题:Centos7部署与配置PHP+Nginx+mysql

          本文链接:https://www.haomeiwen.com/subject/xnqxmhtx.html