centos7安装lnmp

1.安装nginx

1、Centos7系统库中默认是没有nginx的rpn包的,所以我们需要先更新下rpm依赖库

 (1):使用yum安装nginx,安装nginx库

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

 (2):使用下面命令安装nginx

yum -y install nginx

 (3):启动nginx

service nginx start   #centos6
或
systemctl start nginx.service   #centos7

 (4):防火墙允许通过80端口-

         手动添加暴露的端口
         # nginx默认的80端口
         firewall-cmd --permanent --zone=public --add-port=80/tcp
         # MySQL的3306端口
         firewall-cmd --permanent --zone=public --add-port=3306/tcp
         # 查看已开发的端口
         firewall-cmd --zone=public --list-ports
 

 (5):重启防火墙

systemctl restart firewalld 
systemctl status firewalld.service

 (6):访问网站,查看是否出现 'Welcome To Nginx',如果想更改网站根目录,修改地址:vim /etc/nginx/conf.d/default.conf,修改Root 后面的路径,详细请参考:Liscookie

2.安装mysql

https://www.cnblogs.com/jpfss/p/12013325.html

 

3.安装php

 

3.安装php
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

//查看
yum search php71w

//安装php以及扩展
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath

//开启服务
service php-fpm start

//修改/etc/nginx/nginx.conf 使其支持php 见下
//重启nginx
service nginx restart
---------------------配置

 

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index index.php index.html index.htm;
    }
    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #不改配置fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;访问的时候    
    #会显示file not found
    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;
    }
    
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

装php出现epel-release = 6 is needed by remi-release-6.5-1.el6.remi.noarch 解决办法

如果报冲突,可以把冲突的包删除

yum remove epel-release

然后

yum install epel-release

https://www.jianshu.com/p/1882cd3b2295 

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值