专业的JAVA编程教程与资源

网站首页 > java教程 正文

centos 7 安装部署流程 最全最细包成功

temp10 2024-10-15 16:34:15 java教程 9 ℃ 0 评论

centos 7 安装部署流程

系统安装

选择最小安装

设置主机名

centos 7 安装部署流程 最全最细包成功

安装wget,vim

yum install -y wget
yum install -y vim

更换国内源

将yum安装源更换为阿里源

1. 备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

CentOS 8

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

3. 运行 yum makecache 生成缓存

 yum makecache

安装network-tools 查看网络

yum install -y net-tools

安装lnmp

wget http://soft.vpser.net/lnmp/lnmp1.7.tar.gz -cO lnmp1.7.tar.gz && tar zxf lnmp1.7.tar.gz && cd lnmp1.7 && ./install.sh lnmp

安装jdk

搜索下载jdk linux 64位版本

上传到指定目录

mkdir /usr/local/java
cd /usr/local/java
tar -zxvf jdk-8u271-linux-x64.tar.gz
rm -rf jdk-8u271-linux-x64.tar.gz

配置环境变量

vim /etc/profile

在末尾添加

export JAVA_HOME=/usr/local/java/jdk1.8.0_271
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin

刷新环境变量

source /etc/profile


安装tomcat

cd /usr/local
wget https://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.39/bin/apache-tomcat-9.0.39.tar.gz
tar -zxvf apache-tomcat-9.0.39.tar.gz
rm -rf apache-tomcat-9.0.39.tar.gz

设置tomcat开机启动

1、安装supervisor

yum install -y supervisor

2、创建sock

touch /tmp/supervisor.sock

chmod 777 /tmp/supervisor.sock

3、开机启动

systemctl enable supervisord

4、生成配置文件

mkdir -p /etc/supervisor/ 
echo_supervisord_conf > /etc/supervisord.conf           

5、修改配置文件,

vim /etc/supervisord.conf

添加:

[include]
files = /etc/supervisor/*.conf

6、运行

 systemctl start supervisord

7、在/etc/supervisor中新建tomcat.conf文件

vim /etc/supervisor/tomcat.conf


[program:tomcat]
directory=/usr/local/apache-tomcat-9.0.39
command=/usr/local/apache-tomcat-9.0.39/bin/catalina.sh run
environment=JAVA_HOME="/usr/local/java/jdk1.8.0_271",JAVA_BIN="/usr/local/java/jdk1.8.0_271/bin"
user=root
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log              

8、重启supervisor

systemctl restart supervisord

PS:重启tomcat命令 supervisorctl -c /etc/supervisord.conf restart tomcat

配置ipv6

开启lnmp nginx ipv6支持

vim /usr/local/nginx/conf/nginx.conf

去除listen [::]:80 default_server ipv6only=on;的注释

重启nginx

lnmp restart nginx

设置mysql用户,开启该用于远程访问

mysql -u root -proot

进入mysql后,创建需要的数据库

创建远程用户,分配权限

create database YOUR_DATABASE;
CREATE USER 'USER'@'%' IDENTIFIED BY 'PASSWORD';
grant all privileges on YOUR_DATABASE.* to 'USER'@'%' identified by 'PASSWORD'; 
flush privileges;

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表