Centos7 安装Nginx,MySQL,Redis,JDK1.8

  • Nginx安装

1、添加CentOS 7 Nginx yum资源库

[root@localhost ~]# rpm -Uvh  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2、安装nginx

[root@localhost ~]# yum -y install nginx   //安装nginx

3、启动nginx

[root@localhost ~]# systemctl start nginx   //启动nginx

4、安装完成,可以在浏览器访问到如下页面即为成功

 

Centos7 安装Nginx,MySQL,Redis,JDK1.8_第1张图片

5、yum方式安装的默认地址和配置的默认地址

/etc/nginx/nginx.conf  //yum方式安装后默认配置文件的路径

/usr/share/nginx/html  //nginx网站默认存放目录

/usr/share/nginx/html/index.html //网站默认主页路径

拓展:

nginx基本操作

[root@localhost ~]# yum -y instal nginx  //安装nginx

[root@localhost ~]# service nginx start  //启动nginx

[root@localhost ~]# service nginx stop  //停止nginx

[root@localhost ~]# service nginx reload  //重载nginx

[root@localhost ~]# ps -ef | grep nginx  //查看进程apache/httpd

[root@localhost ~]# netstat -anpl | grep 'nginx'  //查看服务端口

[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.18.0-1.el7.ngx.x86_64.rpm  // rpm方式升级并安装某个版本的Nginx
  •  MySQL安装

1.检查yum仓库是否有mysql5.7包

查看当前yum仓库是否包含mysql-server相关包,如果提示no match found 则仓库没有相应包
[root@localhost ~]# yum whatprovides mysql-server

2.下载 mysql的yum仓库文件包

[root@localhost ~]# wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm

[root@localhost ~] rpm -ivh mysql57-community-release-el7-10.noarch.rpm

3.开始使用yum安装mysql

[root@localhost ~]# yum -y install mysql-server

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering "
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql57-community-release-el7-10.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


Public key for mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm is not installed


 Failing package is: mysql-community-libs-compat-5.7.37-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

可能出现如上错误,这个报错是指mysql密钥过期了,需要更新一下密钥,更新完密钥之后,重新安装即可。

[root@localhost ~]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022   //更新密钥

[root@localhost ~]# yum -y install mysql-server

4.设置开机自启

[root@localhost ~]# systemctl enable mysqld  //设置开机自启动

[root@localhost ~]# systemctl start mysqld     //启动mysql

[root@localhost ~]# systemctl status mysqld   //查看mysql状态

[root@localhost ~]# systemctl restart mysqld   //重启mysql

5.查看mysql临时密钥并登录MySQL修改密码

[root@localhost ~]# cat /var/log/mysqld.log |grep password
[root@localhost ~]# mysql -uroot -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'P@ssword123';
GRANT ALL PRIVILEGES ON *.* TO 'bigdata'@'%' IDENTIFIED BY 'P@ssword123' WITH GRANT OPTION;
GRANT select,Insert,UPDATE,delete ON *.* TO 'test1'@'%' IDENTIFIED BY 'P@ssword123' WITH GRANT OPTION;
GRANT select,Insert,UPDATE,delete ON *.* TO 'test2'@'%' IDENTIFIED BY 'P@ssword123' WITH GRANT OPTION;

6.mysql安装后的相关文件在如下路径

可以配置忽略大小写,以及groupBy

配置文件:/etc/my.cnf
日志文件: /var/log/mysqld.log
服务启动脚本: /usr/lib/systemd/system/mysqld.service
socket文件: /var/run/mysqld/mysqld.pid
  • Redis安装

1.下载epel仓库

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


2.安装redis

[root@localhost ~]# yum install redis -y

3.启动Redis

[root@localhost ~]# systemctl start redis
 

4.Redis 常用命令

[root@localhost ~]# systemctl status redis    //查看服务状态
[root@localhost ~]# systemctl stop redis    //停止服务
[root@localhost ~]# systemctl restart redis    //重启服务
[root@localhost ~]# ps -ef | grep redis     //查看reids服务信息
[root@localhost ~]# systemctl enable redis redis    //开机启动

5.设置redis 远程连接和密码

[root@localhost ~]# vim /etc/redis.conf    如果没有vim先yum install -y vim

  1. 注释 #bind 127.0.0.1
  2. 修改protected-mode no
  3. 修改 daemonize yes
  4. 修改 requirepass Dd123=123
  • 安装JDK1.8

1.下载JDK安装包

[root@localhost ~]wget https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz

2.解压缩

[root@localhost ~]tar -zxvf jdk-8u202-linux-x64.tar.gz

3.编辑/etc/profile 文件,末尾追加

[root@localhost home]# vim /etc/profile

export JAVA_HOME=/usr/java/jdk1.8 export 

CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar export

PATH=$PATH:$JAVA_HOME/bin

https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz

4.刷新profile

[root@localhost home]# source /etc/profile

出现以下结果说明成功

[root@localhost home]# java -version
 

java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

你可能感兴趣的:(nginx,java,mysql,nginx,mysql,redis)