CentOS 8安装Nginx并配合Tomcat搭建反向服务器
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CentOS 8安装Nginx并配合Tomcat搭建反向服务器,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2989字,纯文字阅读大概需要5分钟。
内容图文
![CentOS 8安装Nginx并配合Tomcat搭建反向服务器](/upload/InfoBanner/zyjiaocheng/942/1bc4e631277b45ed8719b7f21d846069.jpg)
######### Overview ##########
#Search for Nginx package:
sudo yum search nginx
#Install nginx package using the yum command on CentOS 8:
sudo yum update
sudo yum install nginx
#Update firewall settings and open TCP port 80 and 443. Run:
sudo firewall-cmd --permanent --zone=public --add-service=https --add-service=http
sudo firewall-cmd --reload
######### DETAILS ##########
######### 详细步骤参考以下命令 ##########
#Step 1 Update the system
#步骤1 更新系统
#Keeping your system, kernel, and the installed application is an essential sysadmin task.
#So update the system, run:
sudo yum updateinfo
sudo yum update
sudo reboot
#Step 2 Search for Nginx package
#步骤2 寻找可下载的nginx包
sudo yum search nginx
sudo yum list nginx
#Get Nginx version information that you are going to install, execute:
#查询即将下载的nginx包版本信息
sudo yum info nginx
#Step 3 Install Nginx on CentOS 8
#步骤3 安装Nginx
sudo yum install nginx
#Step 4 Enable nginx server
#步骤4 使nginx服务器有效
sudo systemctl enable nginx
#Run command as per your needs.
#nginx可选命令行
#sudo systemctl start nginx ## <-- start the server ##
#sudo systemctl stop nginx ## <-- stop the server ##
#sudo systemctl restart nginx ## <-- restart the server ##
#sudo systemctl reload nginx ## <-- reload the server ##
#sudo systemctl status nginx ## <-- get status of the server ##
#Start the service, run:
#启动服务器
sudo systemctl start nginx
#Step 5 Open port 80 and 443 using firewall-cmd
#步骤5 打开80和443端口,permanent代表永久,http.https代表80,443端口。打开后重新加载防火墙
sudo firewall-cmd --permanent --zone=public --add-service=http --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --list-services --zone=public
#Step 6 Test it
#步骤 6 测试,运行以下command查看80,443端口是否启动
#Verify that port 80 or 443 opened using ss command command:
sudo ss -tulpn
#Step 7 Configure Nginx server
#步骤7 配置服务器,配置文件目录如下
#CentOS 8 Nginx Config directory - /etc/nginx/
#Master/Global config file - /etc/nginx/nginx.conf
#TCP ports opened by Nginx - 80 (HTTP), 443 (HTTPS)
#Document root directory - /usr/share/nginx/html
#To edit files use a text editor such as vi command/nano command:
#编辑配置文件
sudo vi /etc/nginx/nginx.conf
#修改http块
server {
listen 443 ssl; #监听443端口
server_name example.com; #公网域名
ssl_certificate /etc/nginx/ssl/example.com.crt; #绑定ssl证书
ssl_certificate_key /etc/nginx/ssl/example.com.key; #绑定ssl证书
ssl_session_cache shared:SSL:1m;
ssl_prefer_server_ciphers on;
}
server {
listen 80; #监听80端口
server_name example.com; #公网域名
# Redirect all HTTP requests to HTTPS
# 重定向至443端口
location / {
return 301 https://$server_name$request_uri;
}
}
#更多详细请参考如下url
#https://docs.nginx.com/nginx/deployment-guides/load-balance-third-party/apache-tomcat/
内容总结
以上是互联网集市为您收集整理的CentOS 8安装Nginx并配合Tomcat搭建反向服务器全部内容,希望文章能够帮你解决CentOS 8安装Nginx并配合Tomcat搭建反向服务器所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。