linux安装环境

安装gcc

yum install cpp

yum install binutils

yum install glibc

yum install glibc-kernheaders

yum install glibc-common

yum install glibc-devel

yum install gcc

yum install make

yum -y install centos-release-scl

yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

scl enable devtoolset-9 bash

yum install zlib (系统默认已经装上)

yum install zlib-devel 

yum -y install perl-CPAN

安装nginx

wget http://nginx.org/download/nginx-1.20.1.tar.gz
tar -zvxf nginx-1.20.1.tar.gz
进入解压后的目录 nginx-1.20.1进行预编译
./configure --prefix=/opt/nginx 
注意:--prefix是指定安装目录(建议指定)可选
如果执行不成功,可能是由于没有gcc环境造成的,先安装gcc相关包
apt-get install gcc
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g zlib1g-dev
# 如果仓库中没有发现openssl-dev,由下面openssl和libssl-dev替代
#apt-get install openssl openssl-dev
sudo apt-get install openssl 
sudo apt-get install libssl-dev
如果报错
./configure: error: the HTTP rewrite module requires the PCRE library
执行yum -y install pcre-devel,安装pcre-devel
make
make install
./nginx

安装jdk

rpm安装

下载rpm包
https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
rpm -ivh jdk-11.0.6_linux-x64_bin.rpm

压缩包安装

解压缩
tar -zxvf jdk-11.0.14_linux-x64_bin.tar.gz
配置环境变量
vim /etc/profile
export JAVA_HOME=/usr/environments/jdk11
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
刷新配置文件
source /etc/profile
验证是否安装成功
javac -version

安装redis

wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar -xzf redis-5.0.3.tar.gz
cd redis-5.0.3
make
make install
$ cd redis-5.0.3
$ vim redis.conf
bind 127.0.0.1 #限制只有本机可以连接redis服务连接
bind 0.0.0.0   #允许任意计算机都可以连接redis服务连接
protected-mode yes #保护模式,需配置bind ip或者设置访问密码
protected-mode no  #外部网络可以直接访问
daemonize no  #redis在当前终端显示输出,并运行,exit强制退出或者关闭连接工具
daemonize yes #redis在后台运行,此时redis将一直运行,除非手动kill该进程
# requirepass foobared #默认无密码
requirepass password   #看个人需求设置你喜欢得密码
logfile "" #默认无输出
logfile "/var/log/redis/6379.log" #看情况设置
mkdir /etc/redis
cp /root/redis-5.0.3/redis.conf /etc/redis/redis.conf
redis-server
redis-server /etc/redis/redis.conf

使用systemctl启动redis

/etc/systemd/system 下新建redis.service文件,并添加一下内容

[Unit]
Description=Redis
After=network.target

[Service]
Type=forking
ExecStart=/opt/redis/redis-5.0.3/src/redis-server /opt/redis/redis-5.0.3/redis.conf
ExecReload=/opt/redis/redis-5.0.3/src/redis-server -s reload
ExecStop=/opt/redis/redis-5.0.3/src/redis-server -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

保存之后可以使用systemctl操作redis服务了

systemctl daemon-reload #重新加载服务配置
systemctl enable redis  #设置开机自启动
systemctl start redis   #启动redis服务
systemctl status redis  #查看服务当前状态

安装git

访问可查看你需要下载的版本:git下载地址

查看git版本
git --version
yum remove git
wget https://www.kernel.org/pub/software/scm/git/git-2.14.0.tar.gz
tar -zxvf git-2.14.0.tar.gz
cd git-2.14.0
./configure --prefix=/opt/git
make && make install
配置环境变量
$ echo "export PATH=$PATH:/opt/git/bin" >> /etc/bashrc
$ source /etc/bashrc

安装maven

tar -zxvf apache-maven-3.8.5-bin.tar.gz
vim maven3.8/conf/setting.xml
配置阿里镜像仓库
<mirror>
  <id>aliyunmaven</id>
  <mirrorOf>*</mirrorOf>
  <name>阿里云公共仓库</name>
  <url>https://maven.aliyun.com/repository/public</url>
</mirror>
自定义依赖下载路径
<localRepository>/opt/.m2/repo</localRepository>
配置环境变量
vim /etc/profile
export JAVA_HOME=/usr/local/envpackage/jdk11
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export MAVEN_HOME=/opt/maven3.8
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin

source /etc/profile

安装MySQL5.7

下载安装包:wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
安装:rpm -ivh mysql57-community-release-el7-10.noarch.rpm
安装server:yum -y install mysql-server

问题:
linux安装环境_第1张图片
执行命令:rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
再次执行:yum -y install mysql-server
再启动MySQL:systemctl start mysqld
检查运行状态:systemctl status mysqld
查询默认密码:grep 'temporary password' /var/log/mysqld.log
登录修改密码:mysql -u root -p
修改密码:ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';–密码规则:大小写字母数字特殊符号最少8位数
允许远程登录:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;

安装MySQL8

# 下载mysql仓库
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm

# 安装仓库
yum -y install mysql80-community-release-el7-3.noarch.rpm

# 安装MySQL
yum -y install mysql-community-server --nogpgcheck

# 启动MySQL
systemctl start mysqld

# 查看默认密码
cat /var/log/mysqld.log | grep password

# 使用mysq -u root -p命令登录MySQL,修改密码
# 密码策略默认为大小写字母数字特殊符号组成
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root_123';

# 可选 设置密码最小长度
set global validate_password.length=4;
# 可选 设置密码复杂度
set global validate_password.policy=0;

# 设置允许远程登录
create user 'root'@'%' identified with mysql_native_password by '123456'; 
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;

安装抓包工具tcpdump(离线安装)

m4(bison依赖)地址:http://ftp.gnu.org/gnu/m4/
bison地址:http://ftp.gnu.org/gnu/bison/
flex地址:https://github.com/westes/flex/releases
tcpdump地址:https://www.tcpdump.org/
libpcap地址:https://www.tcpdump.org/
tcpdump地址和libpcap地址是同一个地址
linux安装环境_第2张图片

# 分别解压
tar zxvf 压缩包名
# 分别进入解压后的文件夹
# 依次执行,./configure不要设置--prefix,否则要自己设置全局命令
# 执行顺序:m4、bison、flex、libpcap、tcpdump
./configure
make && make install

在线安装只需依次执行yum install 命令即可

扩展

systemctl daemon-reload #重新加载服务配置
systemctl enabl .service #设置服务开机自启动
systemctl disabl .service #取消服务开机自启动
systemctl status .service #查看服务状态
systemctl start .service #启动服务
systemctl stop .service #停止服务
systemctl restart .service #重启服务
systemctl reload .service #重新加载服务配置

你可能感兴趣的:(Linux,nginx,linux,服务器,1024程序员节)