linux centos 安装JDK、tomcat、nginx教程记录
以下是在CentOS上安装JDK、Tomcat和Nginx的简要步骤:
安装JDK
下载JDK:
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" \ http://download.oracle.com/otn-pub/java/jdk/8u151-b12/jdk-8u151-linux-x64.rpm
安装JDK:
sudo yum localinstall -y jdk-8u151-linux-x64.rpm
配置环境变量:
echo 'export JAVA_HOME=/usr/java/latest' | sudo tee -a /etc/profile echo 'export PATH=$PATH:$JAVA_HOME/bin' | sudo tee -a /etc/profile
应用环境变量更改:
source /etc/profile
验证安装:
java -version
安装Tomcat
下载Tomcat:
wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.37/bin/apache-tomcat-9.0.37.tar.gz
解压Tomcat:
sudo tar xzf apache-tomcat-9.0.37.tar.gz -C /opt
创建软链接:
sudo ln -s /opt/apache-tomcat-9.0.37 /opt/tomcat
启动Tomcat:
sudo /opt/tomcat/bin/startup.sh
验证Tomcat是否启动:
ps -ef | grep tomcat
设置Tomcat开机自启动:
sudo chmod +x /etc/rc.d/rc.local echo '/opt/tomcat/bin/startup.sh' | sudo tee -a /etc/rc.d/rc.local
安装Nginx
安装Nginx:
sudo yum install epel-release -y sudo yum install nginx -y
启动Nginx:
sudo systemctl start nginx
设置Nginx开机自启动:
sudo systemctl enable nginx
配置Nginx代理Tomcat:
sudo tee /etc/nginx/conf.d/tomcat.conf <<EOF upstream tomcat_server { server 127.0.0.1:8080; } server { listen 80; server_name your_domain_or_IP; location / { proxy_pass http://tomcat_server; proxy_set_header Host \$host; proxy_set_header X-Real-IP \$remote_addr; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; } } EOF
重新加载Nginx配置:
sudo nginx -s reload
以上步骤提供了在CentOS系统上安装JDK、Tomcat和Nginx的基本过程。根据具体的系统环境和版本,可能需要调整命令和文件路径。
评论已关闭