首页 > 编程知识 正文

lnmp环境搭建有什么用,linux搭建测试环境步骤LNMP

时间:2023-05-06 02:03:53 阅读:260435 作者:1594

1.先准备一台虚拟机,并配好yum源

    我准备的是一台RedHat 7.4版本的虚拟机,使用的是redhat7的光盘镜像作为yum源


2.下载所需软件包

     点击此处下载lnmp_soft

3.解压lnmp_soft.tar.gz

     [root@localhost ~]# tar -xf  lnmp_soft.tar.gz

4.进入lnmp_soft目录,执行install_lnmp.sh脚本

     [root@localhost lnmp_soft]# ./install_lnmp.sh 

5.程序主页面

       

 6.安装nginx,mariadb,php等软件包

      6.1  按 “1” 安装nginx

        首先会安装依赖包,然后再源码安装nginx。

      6.2  按  “2” 安装mariadb


      6.3  按  “3” 安装php


   7.启动服务

        7.1 启动nginx服务    

       [root@localhost lnmp_soft]#   ln -s /usr/local/nginx/sbin/nginx /sbin/      //做一个软连接

       [root@localhost lnmp_soft]#   nginx                                                         //启动服务

          

        7.2 启动mariadb服务

        [root@localhost lnmp_soft]# systemctl restart mariadb.service 

    

           

        7.3启动php-fpm服务

        [root@localhost lnmp_soft]# systemctl restart php-fpm.service


       

8.修改nginx.conf主配置文件实现动静分离,修改完配置文件重启服务

       8.1  [root@localhost conf]# vim /usr/local/nginx/conf/nginx.conf 

    修改65-71行实现动静分离,先把65-71行的注释打开,然后对比下面进行更改。

65 location ~ .php$ { 66 root html; 67 fastcgi_pass 127.0.0.1:9000; 68 fastcgi_index index.php; 69 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; //把这一行注释 70 include fastcgi.conf;                                      //把后缀改为.conf 71 }

        8.2 修改完nginx.conf,需要让nginx重新读取配置文件(重启服务)

        [root@localhost html]# nginx -s stop

        [root@localhost html]# nginx

9.部署测试页面

        [root@localhost html]# cp /root/lnmp_soft/php_scripts/mysql.php /usr/local/nginx/html/    

        [root@localhost html]# ls

        50x.html  index.html  mysql.php

 10.浏览器测试LNMP环境是否搭建成功

        [root@localhost html]# firefox http://192.168.4.100/mysql.php        

                

       mysql.php脚本取出了mariadb中的mysql数据库user表中数据。证明LNMP环境搭建成功。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。