网站首页 > 技术教程 正文
?Nginx 服务器的反向代理服务是其最常用的重要功能,由反向代理服务也可以衍生出很多与此相关的 Nginx 服务器重要功能。
一、安装依赖包
yuminstall-y gccgcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
依赖包说明:
1、编译依赖 gcc 环境,所以需要:gcc gcc-c++;
2、PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库,所以需要:pcre pcre-devel ;
3、zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库,所以需要:zlib zlib-devel ;
4、OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库,所以需要:openssl openssl-devel ;
二、从官网下载安装包
wgethttps://nginx.org/download/nginx-1.16.0.tar.gz
三、解压并安装
tarzxvf nginx-1.16.0.tar.gz
cd nginx-1.16.0
./configure --prefix=/usr/local/nginx —user=www —group=www
make&&makeinstall
四、测试安装是否成功
[root@localhost ~]# nginx -V
nginx version: nginx/1.16.0
built bygcc4.8.520150623(Red Hat4.8.5-36) (GCC)
configure arguments:--prefix=/usr/local/nginx
五、启动nginx服务
cd /usr/local/nginx/sbin
./nginx
六、验证服务是否启动成功
[root@localhost sbin]# netstat -ntlp |grepnginx
tcp 0 00.0.0.0:80 0.0.0.0:* LISTEN 349/nginx: master
七、访问一下
[root@localhost sbin]# curl 172.17.1.151
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
八、下载tomcat
https://tomcat.apache.org/download-80.cgi
解压:
[root@localhost opt]# tar -vxf apache-tomcat-8.5.43.tar
改名:
[root@localhost opt]# mv apache-tomcat-8.5.43 /usr/local/tomcat
[root@localhost opt]# cd /usr/local/tomcat/
[root@localhost tomcat]# ls
bin CONTRIBUTING.md logs RELEASE-NOTES webapps
BUILDING.txt lib NOTICE RUNNING.txt work
conf LICENSE README.md temp
九、配置java环境
[root@localhost tomcat]# yum install java-1.8.0* -y
[root@localhost tomcat]# java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
十、启动查看tomcat
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
十一、tomcat是个java进程
[root@localhost bin]# netstat -tunlp|grep tomcat
[root@localhost bin]# netstat -tunlp|grep java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 17248/java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 17248/java
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 17248/java
http://172.17.1.151:8080
十二、反向代理:之前的注释掉
十三、重启nginx
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ls
nginx
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost sbin]# ./nginx -s reload
十四、访问80端口可以直接访问tomcat
http://172.17.1.151
关于运维学习、分享、交流,笔者开通了微信公众号【运维猫】,感兴趣的朋友可以关注下,欢迎加入,建立属于我们自己的小圈子,一起学运维知识。
猜你喜欢
- 2024-10-10 译荐|Nginx: 高性能与规模化的设计逻辑
- 2024-10-10 终于有人把「编程软件安装和环境配置」的教程整理成了一个文档
- 2024-10-10 破解 非root用户禁止使用1024以下端口限制
- 2024-10-10 在Linux中通过expect工具实现脚本的自动交互
- 2024-10-10 我在自己腾讯云服务器上更改nginx配置的操作指引
- 2024-10-10 NGINX内部工作原理:我们如何设计性能和规模
- 2024-09-11 Linux下玩转nginx系列(六)---nginx实现cache(缓存)服务
- 2024-09-11 Nginx从理论到实践超详细笔记(nginx 原理与架构)
- 2024-09-11 还在为Root用户启动程序的安全警告而烦恼吗?试试setcap
- 2024-09-11 Ngnix的root和alias指令(alias nginx)
你 发表评论:
欢迎- 最近发表
-
- linux日志文件的管理、备份及日志服务器的搭建
- Linux下挂载windows的共享目录操作方法
- Linux系统中的备份文件命令(linux系统中的备份文件命令有哪些)
- 麒麟KYLINOS|通过不同方法设置用户访问文件及目录权限
- 「Linux笔记」系统目录结构(linux目录的结构及含义)
- linux中修改归属权chown命令和chgrp命令
- 工作日报 2021.10.27 Android-SEAndroid权限问题指南
- Windows和Linux环境下,修改Ollama的模型默认保存路径
- 如何强制用户在 Linux 上下次登录时更改密码?
- 如何删除Linux文件夹中除某些扩展名之外的所有文件?
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)