测试环境搭建二

article/2025/9/18 21:43:35

一.在虚拟机上安装centos7
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
如果你的磁盘空间足够大,可以写大一些
最后在虚拟机界面上双击CD/DVD,选择使用ISO镜像文件,点击浏览,找到你镜像所下载的位置
在这里插入图片描述
然后开启虚拟机,进行相关的设置即可
你可以参考博客:
https://blog.csdn.net/hui_2016/article/details/68927487
二、lnmp环境搭建
所有安装文件放入到/root下的soft目录下
1、nginx 源码编译
软件目录上传解压
在这里插入图片描述
安装执行命令

shell > yum -y install gcc pcre-devel openssl-devel zlib-devel   //安装依赖文件
shell > tar xvf nginx-1.12.2.tar.gz
shell > cd /root/ruanjian/nginx-1.14.0
shell > ./configure --prefix=/usr/local/nginx --with-http_ssl_module --add-module=/root/soft/ngx-fancyindex-0.4.2/    //加载编译第三方模块
shell > make && make install

检测:

whereis nginx
nginx: /usr/local/nginx
[root@localhost nginx-1.14.0]# cd /usr/local/nginx
[root@localhost nginx]# ./nginx
-bash: ./nginx: 没有那个文件或目录
[root@localhost nginx]# ls
conf  html  logs  sbin
[root@localhost nginx]# cd sbin
[root@localhost sbin]# ./nginx
[root@localhost sbin]# ps aux|grep nginx
root      4050  0.0  0.0  45936  1120 ?        Ss   19:03   0:00 nginx: master process ./nginx
nobody    4051  0.0  0.1  46384  1896 ?        S    19:03   0:00 nginx: worker process
root      4053  0.0  0.0 112720   972 pts/0    S+   19:03   0:00 grep --color=auto nginx

启动:
cd /usr/local/nginx/sbin ./nignx
防火墙设置:
Systemctl stop firewalld.service (停止firewall)
Systemctl disable firewalld.service(禁止firewall开机启动)
打开浏览器 输入IP 地址 出现nginx的欢迎界面,安装成功
关闭 :
./nignx -s stop
查看状态:Status
重启服务:restart

2.mysql
参考https://www.cnblogs.com/jorzy/p/8455519.html
启动时报错:Access denied for user ‘root’@‘localhost’ (using password: NO)
1.停止mysql服务
systemctl stop mysqld.service
2.修改配置文件无密码登录
vim /etc/my.cnf
在最后加上
skip-grant-tables
保存
3.启动mysql
systemctl start mysqld.service
4.登录mysql
mysql -u root
注意这里不要加-p
5.修改密码,mysql5.7用此语法

use mysql;
update mysql.user set authentication_string=password('123456') where user='root' ;

6.回到第二步把刚加的那句删掉
保存,重启mysql就可以了
##################################################################
其实默认安装完了mysql后或在日志中生成一个默认的密码 /var/log/mysqld.log 中
拿到默认密码后登录mysql 进行密码重新设置
set pssword=password('your password');
如果密码级别与默认的级别要求不符时候会报
Your password does not satisfy the current policy requirements
此时需要修改级别与最小的默认密码位数
set global validate_password_policy=0;
set global validate_password_length=4;
然后在进行设置密码就好了
###################
远程连接时1130错误

mysql;use mysql;    
mysql;select 'host' from user where user='root';    
mysql;update user set host = '%' where user ='root';    
mysql;flush privileges;    
mysql;select 'host'   from user where user='root';  

3.php7
编译最新版本php 7.2
①上传文件包
在这里插入图片描述
②解压部署
shell > tar xvf php-7.2.7.tar.gz
shell > cd /root/soft/php-7.2.7
解决依赖文件问题
shell > yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
libmcrypt-devel需要epel源里安装,yum源需要提前配置好epel的源

configure参数
shell > ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
编译安装
shell > make && make install
在这里插入图片描述
配置
①php.ini phpfpm.conf www.conf.default 配置处理

shell > cp php.ini-production /usr/local/php/etc/php.ini
shell > cd /usr/local/php/etc
shell > cp php-fpm.conf.default php-fpm.conf
shell > cd /usr/local/php/etc/php-fpm.d/ 
shell > cp www.conf.default www.conf

②创建允许phpfpm的 www用户
shell > useradd www -s /sbin/nologin -M
③php命令行方便使用加path

shell > echo 'PATH=/usr/local/php/bin:$PATH' >> /etc/profile
shell > echo 'export PATH' >> /etc/profile
shell > source /etc/profile

以上过程php已经配置完成
启动php-fpm
在这里插入图片描述
nginx和php-fpm进行关联
改nginx的配置文件
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
建立phpinfo,查看php的配置
在这里插入图片描述
在这里插入图片描述

三.将项目打包放到服务器
第一步,将jcf.jar包放在/usr/local/nginx/html里
解压
tar -xvf jcf.jar
然后配置nginx.conf,设置一下域名,项目地址
在这里插入图片描述

#定义Nginx运行的用户和用户组
#user  nobody;
#nginx进程数,建议设置为等于CPU总核心数
worker_processes  1;
#全局错误日志定义类型
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#进程文件
#pid        logs/nginx.pid;
events {
#单个进程最大连接数(最大连接数=连接数*进程数worker_connections  1024;
}
#设定http服务器
http {include       mime.types;#文件扩展名与文件类型映射表default_type  application/octet-stream;#默认文件类型log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';#access_log  logsaccess.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#开启Gzipgzip  on;##http协议版本gzip_http_version 1.0;##禁止IE 6以下使用gzip_disable 'MSIE [1-6]';gzip_types image/jpeg image/jpg;# server {#     listen       10086;#     server_name  localhost;#     root html/port;#     location / {#         proxy_pass http://172.16.1.140:3000;#         proxy_set_header Host $host;#         }# }server {listen       80;#监听端口server_name  www.ml.com; #域名可以有多个,用空格隔开#charset koi8-r;access_log  logs/host.access.log  main;root   html/jcf/public;#项目地址index index.php index.html index.htm;#Thinkphp rewrite支持,如果没有,浏览器会报错404找不到网页location / {if (!-e $request_filename) {rewrite ^(.*)$ /index.php?s=$1 last;break;}}#location ~ \.(jpeg|jpg|png)$ {#expires 1d;#}#location / {# root   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   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#location ~ \.php$ {#    root           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;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}
}

第二步,配置数据库
找到数据库配置的相关代码,修改库名和ip地址
Sql语句导入到指定库中,然后用浏览器打开指定域名即可


http://chatgpt.dhexx.cn/article/09n7GNyC.shtml

相关文章

软件测试之测试环境

背景 当设计的测试用例通过评审后,测试人员会依据测试用例来测试开发人员开发出的软件系统,那待测试的软件系统会部署在哪里呢?测试人员肯定不会在开发环境测试,开发人员也不会在测试环境开发,因为开发人员开发完成后…

如何搭建测试环境?搭建测试环境的步骤跟注意事项(视频教程版)

什么是测试环境 测试环境,指为了完成软件测试工作所必需的计算机硬件、软件、网络设备、历史数据的总称,简而言之,测试环境硬件软件网络数据准备测试工具。 硬件:指测试必需的服务器、客户端、网络连接等辅助设备。 软件&#…

SpringCloudAlibaba:Nacos实现原理详解

欢迎关注方志朋的博客,回复”666“获面试宝典 Nacos 架构 Provider APP:服务提供者 Consumer APP:服务消费者 Name Server:通过VIP(Virtual IP)或DNS的方式实现Nacos高可用集群的服务路由 Nacos Server&…

Spring Boot入门

1.什么是Spring Boot Spring 诞生时是 Java 企业版的轻量级代替品。通过依赖注入和面向切面编程,用简单的Java 对象实现了 EJB 的功能。 虽然 Spring 的组件代码是轻量级的,但它的配置却是重量级的。一开始,Spring 用 XML 配置,而…

Java NIO?看这一篇就够了!

点击上方“方志朋”,选择“置顶或者星标” 你的关注意义重大! ✎前言 现在使用NIO的场景越来越多,很多网上的技术框架或多或少的使用NIO技术,譬如Tomcat,Jetty。学习和掌握NIO技术已经不是一个JAVA攻城狮的加分技能&am…

今日头条技术架构分析

点击上方“方志朋”,选择“设为星标” 回复”666“获取新整理的面试资料 来源:blog.csdn.net/mucaoyx/article/details/84498468 一、产品背景1、文章抓取与分析2、用户建模3、新用户的“冷启动”4、推荐系统5、数据存储6、消息推送 二、今日头条系统架构…

写了 5 年 Java,这些坑还是没躲过……

我常常在想,一个人具备怎样的素质和能力,才称得上高级工程师?估计有不少人会说,“基础过硬、熟练掌握一门编程语言、至少看过一个优秀开源项目的源代码、有过高并发工作经验、沟通能力强”。 上面这些都很对,这些也都是…

专访方志朋:2018年仍然是微服务飞速发展的一年

方志朋,毕业于武汉理工大学硕士学位。 CSDN博客专家、Spring Cloud中国社区联合创始人。 《深入理解Spring Cloud与微服务构建》作者。 Spring Cloud作为Java语言的微服务落地框架,在Spring开源社区和Pivatol、Netflix两大公司的推动下飞速发展&#xf…

顶配版阿里大佬面试笔记+300道硬核面试题,跪着啃完了。。。。

金九银十刚过去,有一部分朋友在这期间肯定经历了一番大厂面试的洗礼,不知道大家是经受住了考验如愿以偿了,还是折戟沉沙无功而返呢? 身边已经有技术大佬顺利通过了阿里P6/P7的面试,在30岁之前成功跳槽进大厂&#xff1…

我是一个线程池

点击上方蓝色“方志朋”,选择“设为星标” 回复“666”获取独家整理的学习资料! 线程池的自我介绍 我是一个线程池(ThreadPoolExecutor),我的主要工作是管理在我这的多个线程(Thread)&#xff0…

好用到爆的 Java 技巧

点击上方“方志朋”,选择“设为星标” 回复”666“获取新整理的面试文章 来自:Lrwin的技术博客链接:http://lrwinx.github.io/2017/03/04/细思极恐-你真的会写java吗/ 本文不是一个吹嘘的文章,不会讲很多高深的架构,相…

Spring Cloud和Spring Boot高级视频

内容是之前发过的,大家说找不到,重新发一次 spring cloud 视频内容: spring boot 视频内容: 下载方式: 微信公众平台回复“C”免费获取springcloud,回复“B"免费获取springboot 4000G java高级架构师进阶 视频下载…

华为最美小姐姐,被外派墨西哥后...

欢迎关注方志朋的博客,回复”666“获面试宝典 来源丨《华为人》、心声社区 作者丨潘昱 2018年,坐在UCLA大学教室里,我和华为进行了一场视频面试。去投行从事对冲基金业务,还是去四大会计师事务所做一名税务咨询师?当时…

Java 和 C 长期霸权结束

欢迎关注方志朋的博客,回复”666“获面试宝典 TIOBE 公布了 2021 年 10 月的编程语言排行榜。 在进行了几个月的追逐之后,Python 成功在 10 月份超越了霸榜已久的 C 语言,夺得了 TIOBE 编程语言排行榜首的位置。TIOBE CEO Paul Jansen 评价称…

Spring Cloud之路---1.注册中心eureka与服务提供者

根据方志鹏大神的观点而来,他的博客地址: http://blog.csdn.net/forezp/article/details/70148833 简介:Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路…

SpringBoot 生产中 16 条最佳实践

欢迎关注方志朋的博客,回复”666“获面试宝典 Spring Boot是最流行的用于开发微服务的Java框架。在本文中,我将与你分享自2016年以来我在专业开发中使用Spring Boot所采用的最佳实践。这些内容是基于我的个人经验和一些熟知的Spring Boot专家的文章。 在…

SpringBoot快速开发利器:CLI 属实真牛逼!

欢迎关注方志朋的博客,回复”666“获面试宝典 来源:blog.csdn.net/qq_31635851/article/details/120411711/ 安装 Spring Boot CLI演示项目结构用 Spring Boot CLI 创建 Hello World 示例使用 Grab 注释Spring Boot CLI 测试应用程序使用 Spring Boot CL…

一个程序员的水平能差到什么程度?

欢迎关注方志朋的博客,回复”666“获面试宝典 来源:www.zhihu.com/question/314644210 逛知乎的时候,看到一个有意思的话题:一个程序员的水平能差到什么程度? 看了下面的回答,不得不说,真是小刀…

spring boot面试问题集锦

方志鹏 2019/09/06 Q: 什么是spring boot? A:多年来,随着新功能的增加,spring变得越来越复杂。只需访问页面https://spring.io/projects,我们将看到所有在应用程序中使用的不同功能的spring项目。如果必须启动一个新…

五分钟体验分布式事务框架Seata

Seata 是一款开源的分布式事务解决方案,致力于提供高性能和简单易用的分布式事务服务。Seata 将为用户提供了 AT、TCC、SAGA 和 XA 事务模式,为用户打造一站式的分布式解决方案。本教程旨在为读者提供一个快速入门seata的案例,详细使用请参考…