首页 > 其他分享 >33_web服务

33_web服务

时间:2024-03-13 10:59:01浏览次数:25  
标签:web 服务 tomcat 33 share nginx usr root stream9

1.nginx
# 1. 查看虚拟机系统和版本
[root@stream9 ~]# cat /etc/os-release
NAME="CentOS Stream"
VERSION="9"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="9"
PLATFORM_ID="platform:el9"
PRETTY_NAME="CentOS Stream 9"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:centos:centos:9"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

# 2. 安装 => centos stream 虚拟机
[root@stream9 ~]# yum -y install nginx

# 3.启动nginx
[root@stream9 ~]# systemctl start nginx
[root@stream9 ~]# systemctl enable nginx # 设置开机自启
[root@stream9 ~]# systemctl status nginx # 查看nginx服务状态
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
     Active: active (running) since Tue 2023-10-31 20:18:30 CST; 42s ago
   Main PID: 38057 (nginx)
      Tasks: 3 (limit: 11125)
     Memory: 2.8M
        CPU: 48ms
     CGroup: /system.slice/nginx.service
             ├─38057 "nginx: master process /usr/sbin/nginx"
             ├─38059 "nginx: worker process"
             └─38060 "nginx: worker process"

Oct 31 20:18:29 stream9 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 31 20:18:29 stream9 nginx[38043]: nginx: the configuration file /etc/nginx/nginx.conf syntax >
Oct 31 20:18:29 stream9 nginx[38043]: nginx: configuration file /etc/nginx/nginx.conf test is suc>
Oct 31 20:18:30 stream9 systemd[1]: Started The nginx HTTP and reverse proxy server.
lines 1-16/16 (END)

# 4. 查看配置文件 所有服务的配置文件目录 => /etc/服务名/xxx
[root@stream9 ~]# cat /etc/nginx/nginx.conf

# 5. 改页面内容
[root@stream9 ~]# cat /usr/share/nginx/html/index.html
123
[root@stream9 ~]# systemctl restart nginx.service # 重启服务

# 6. 访问页面
http://IP/

# 7. 查看nginx版本
[root@stream9 ~]# nginx -V
nginx version: nginx/1.22.1
built by gcc 11.3.1 20221121 (Red Hat 11.3.1-4) (GCC)
built with OpenSSL 3.0.7 1 Nov 2022
TLS SNI support enabled

# 8. 查看nginx安装包
[root@stream9 ~]# rpm -qa | grep nginx
nginx-filesystem-1.22.1-2.el9.noarch
nginx-core-1.22.1-2.el9.x86_64
nginx-1.22.1-2.el9.x86_64

# 9. 查看包装的位置及文件
[root@stream9 ~]# rpm -ql nginx-1.22.1-2.el9.x86_64
/usr/bin/nginx-upgrade
/usr/lib/systemd/system/nginx.service
/usr/share/man/man3/nginx.3pm.gz
/usr/share/man/man8/nginx-upgrade.8.gz
/usr/share/man/man8/nginx.8.gz
/usr/share/nginx/html/404.html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/icons
/usr/share/nginx/html/icons/poweredby.png
/usr/share/nginx/html/index.html
/usr/share/nginx/html/nginx-logo.png
/usr/share/nginx/html/poweredby.png
/usr/share/nginx/html/system_noindex_logo.png
/usr/share/vim/vimfiles/ftdetect/nginx.vim
/usr/share/vim/vimfiles/ftplugin/nginx.vim
/usr/share/vim/vimfiles/indent/nginx.vim
/usr/share/vim/vimfiles/syntax/nginx.vim
[root@stream9 ~]#
[root@stream9 ~]# ls /usr/share/nginx/html
404.html  50x.html  icons  index.html  nginx-logo.png  poweredby.png  system_noindex_logo.png
[root@stream9 ~]#
[root@stream9 ~]# cat /usr/share/nginx/html/index.html
This is my first web!

# 10. 卸载nginx
[root@stream9 ~]# yum -y remove nginx
[root@stream9 ~]# rpm -qa | grep nginx
[root@stream9 ~]#
[root@stream9 ~]# systemctl status nginx
Unit nginx.service could not be found.
[root@stream9 ~]# ps -aux | grep 80
root       24187  0.0  0.3  18060  6216 pts/0    R+   21:50   0:00 ps -aux
root       24188  0.0  0.1   6408  2124 pts/0    S+   21:50   0:00 grep --color=auto 80
2.httpd 服务
[root@stream9 ~]# yum -y install httpd
[root@stream9 ~]# rpm -qa | grep httpd
httpd-tools-2.4.57-5.el9.x86_64
httpd-filesystem-2.4.57-5.el9.noarch
centos-logos-httpd-90.4-1.el9.noarch
httpd-core-2.4.57-5.el9.x86_64
httpd-2.4.57-5.el9.x86_64
[root@stream9 ~]#
[root@stream9 ~]# rpm -ql httpd-2.4.57-5.el9.x86_64  查看关于httpd的部分常用包的路径
/etc/httpd/conf.modules.d/00-brotli.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/usr/lib/.build-id
/usr/lib/.build-id/a8
/usr/lib/.build-id/a8/4ef0b427863d9631a252966f625d8712420d94
/usr/lib/.build-id/b4
/usr/lib/.build-id/b4/b37ec4829dd8bf8a3210bd55fe01ab42be08ec
/usr/lib/systemd/system/htcacheclean.service
/usr/lib/systemd/system/httpd.service
/usr/lib/systemd/system/httpd.socket
/usr/lib/systemd/system/[email protected]
/usr/lib64/httpd/modules/mod_brotli.so
/usr/lib64/httpd/modules/mod_systemd.so
/usr/share/man/man5/httpd.conf.5.gz
/usr/share/man/man8/apachectl.8.gz
/usr/share/man/man8/fcgistarter.8.gz
/usr/share/man/man8/htcacheclean.8.gz
/usr/share/man/man8/htcacheclean.service.8.gz
/usr/share/man/man8/httpd.8.gz
/usr/share/man/man8/httpd.service.8.gz
/usr/share/man/man8/httpd.socket.8.gz
/usr/share/man/man8/[email protected]
/usr/share/man/man8/rotatelogs.8.gz
/usr/share/man/man8/suexec.8.gz
[root@stream9 ~]# systemctl start httpd
[root@stream9 ~]#
[root@stream9 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
     Active: active (running) since Tue 2023-10-31 21:55:20 CST; 6s ago
       Docs: man:httpd.service(8)
   Main PID: 24687 (httpd)
     Status: "Started, listening on: port 80"
      Tasks: 213 (limit: 11125)
     Memory: 39.5M
        CPU: 297ms
     CGroup: /system.slice/httpd.service
             ├─24687 /usr/sbin/httpd -DFOREGROUND
             ├─24688 /usr/sbin/httpd -DFOREGROUND
             ├─24689 /usr/sbin/httpd -DFOREGROUND
             ├─24690 /usr/sbin/httpd -DFOREGROUND
             └─24691 /usr/sbin/httpd -DFOREGROUND

Oct 31 21:55:08 stream9 systemd[1]: Starting The Apache HTTP Server...
Oct 31 21:55:14 stream9 httpd[24687]: AH00558: httpd: Could not reliably determine the server\'s fully qualified domain name, using 10.10.10.129. Set the 'ServerName' di>
Oct 31 21:55:20 stream9 httpd[24687]: Server configured, listening on: port 80
Oct 31 21:55:20 stream9 systemd[1]: Started The Apache HTTP Server.
[root@stream9 ~]#
[root@stream9 ~]# curl 127.0.0.1
123
[root@stream9 ~]# cat /var/www/html/index.html
123
[root@stream9 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.10.10.129  netmask 255.255.255.0  broadcast 10.10.10.255
        inet6 fe80::5054:ff:feba:3ee  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:ba:03:ee  txqueuelen 1000  (Ethernet)
        RX packets 13195  bytes 31168624 (29.7 MiB)
        RX errors 0  dropped 1066  overruns 0  frame 0
        TX packets 10684  bytes 1390937 (1.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 10  bytes 860 (860.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 860 (860.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@stream9 ~]# curl 10.10.10.129:80
123
[root@stream9 ~]# grep -Ev "^#|^$|^[ \+]"  /etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
<Directory />
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
</Directory>
<Directory "/var/www/html">
</Directory>
<IfModule dir_module>
</IfModule>
<Files ".ht*">
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
</IfModule>
<IfModule alias_module>
</IfModule>
<Directory "/var/www/cgi-bin">
</Directory>
<IfModule mime_module>
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
[root@stream9 ~]#
[root@stream9 ~]# grep "apache" /etc/passwd
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
[root@stream9 ~]#
[root@stream9 ~]# id apache
uid=48(apache) gid=48(apache) groups=48(apache)

# 卸载
[root@stream9 ~]# yum -y remove httpd
[root@stream9 ~]# rpm -qa | grep httpd
3.tomcat
[root@stream9 ~]# yum -y install tomcat
[root@stream9 ~]# rpm -qa | grep tomcat
tomcat-el-3.0-api-9.0.62-37.el9.noarch
tomcat-servlet-4.0-api-9.0.62-37.el9.noarch
tomcat-jsp-2.3-api-9.0.62-37.el9.noarch
tomcat-lib-9.0.62-37.el9.noarch
tomcat-9.0.62-37.el9.noarch
[root@stream9 ~]# rpm -ql tomcat-9.0.62-37.el9.noarch
/etc/logrotate.d/tomcat.disabled
/etc/sysconfig/tomcat
/etc/tomcat
/etc/tomcat/Catalina
/etc/tomcat/Catalina/localhost
/etc/tomcat/catalina.policy
/etc/tomcat/catalina.properties
/etc/tomcat/conf.d
/etc/tomcat/conf.d/README
/etc/tomcat/conf.d/java-9-start-up-parameters.conf
/etc/tomcat/context.xml
/etc/tomcat/jaspic-providers.xml
/etc/tomcat/jaspic-providers.xsd
/etc/tomcat/logging.properties
/etc/tomcat/server.xml
/etc/tomcat/tomcat-users.xml
/etc/tomcat/tomcat-users.xsd
/etc/tomcat/tomcat.conf
/etc/tomcat/web.xml
/usr/bin/tomcat-digest
/usr/bin/tomcat-tool-wrapper
/usr/lib/systemd/system/tomcat.service
/usr/lib/systemd/system/[email protected]
/usr/libexec/tomcat
/usr/libexec/tomcat/functions
/usr/libexec/tomcat/preamble
/usr/libexec/tomcat/server
/usr/sbin/tomcat
/usr/share/doc/tomcat
/usr/share/doc/tomcat/LICENSE
/usr/share/doc/tomcat/NOTICE
/usr/share/doc/tomcat/RELEASE-NOTES
/usr/share/tomcat
/usr/share/tomcat/bin/bootstrap.jar
/usr/share/tomcat/bin/catalina-tasks.xml
/usr/share/tomcat/conf
/usr/share/tomcat/lib
/usr/share/tomcat/logs
/usr/share/tomcat/temp
/usr/share/tomcat/webapps
/usr/share/tomcat/work
/var/cache/tomcat
/var/cache/tomcat/temp
/var/cache/tomcat/work
/var/lib/tomcat
/var/lib/tomcat/webapps
/var/lib/tomcats
/var/log/tomcat
[root@stream9 ~]# systemctl start tomcat.service
[root@stream9 ~]#
[root@stream9 ~]# systemctl enable tomcat.service
Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /usr/lib/systemd/system/tomcat.service.
[root@stream9 ~]#
[root@stream9 ~]# systemctl status tomcat.service
● tomcat.service - Apache Tomcat Web Application Container
     Loaded: loaded (/usr/lib/systemd/system/tomcat.service; enabled; preset: disabled)
     Active: active (running) since Tue 2023-10-31 22:37:18 CST; 12s ago
   Main PID: 25617 (java)
      Tasks: 28 (limit: 11125)
     Memory: 54.5M
        CPU: 3.423s
     CGroup: /system.slice/tomcat.service
             └─25617 /usr/lib/jvm/jre/bin/java -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar: ->

Oct 31 22:37:19 stream9 server[25617]: 31-Oct-2023 22:37:19.925 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/var/cache/tomcat/temp
Oct 31 22:37:19 stream9 server[25617]: 31-Oct-2023 22:37:19.926 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/share/tomcat/conf/logg>
Oct 31 22:37:19 stream9 server[25617]: 31-Oct-2023 22:37:19.926 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogM>
Oct 31 22:37:19 stream9 server[25617]: 31-Oct-2023 22:37:19.933 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found o>
Oct 31 22:37:20 stream9 server[25617]: 31-Oct-2023 22:37:20.577 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
Oct 31 22:37:20 stream9 server[25617]: 31-Oct-2023 22:37:20.651 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1207] milliseconds
Oct 31 22:37:20 stream9 server[25617]: 31-Oct-2023 22:37:20.781 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
Oct 31 22:37:20 stream9 server[25617]: 31-Oct-2023 22:37:20.782 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.62]
Oct 31 22:37:20 stream9 server[25617]: 31-Oct-2023 22:37:20.796 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
Oct 31 22:37:20 stream9 server[25617]: 31-Oct-2023 22:37:20.841 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [188] milliseconds

# 目录
[root@stream9 ~]# cat /usr/share/tomcat/webapps/ROOT/index.html
123

# 查看网页内容
[root@stream9 ~]# curl 127.0.0.1:8080
123

# 服务端 使用 python 起一个http服务
[root@stream9 ckh]# python -m http.server 8090
Serving HTTP on 0.0.0.0 port 8090 (http://0.0.0.0:8090/) ...
10.10.10.1 - - [31/Oct/2023 22:54:48] "GET / HTTP/1.1" 200 -
10.10.10.1 - - [31/Oct/2023 22:55:23] "GET / HTTP/1.1" 200 -
10.10.10.1 - - [31/Oct/2023 22:55:24] "GET / HTTP/1.1" 200 -
10.10.10.1 - - [31/Oct/2023 22:55:25] "GET / HTTP/1.1" 200 -
10.10.10.1 - - [31/Oct/2023 22:55:26] "GET / HTTP/1.1" 200 -
10.10.10.1 - - [31/Oct/2023 22:55:26] "GET / HTTP/1.1" 200 -
10.10.10.1 - - [31/Oct/2023 22:55:27] "GET / HTTP/1.1" 200 -
^C
Keyboard interrupt received, exiting.
[root@stream9 ckh]# ls
index.html
[root@stream9 ckh]# cat index.html
789
[root@stream9 ckh]# pwd
/root/ckh

# 客户端访问
[root@kvm ~]# curl 10.10.10.129:8090
789

标签:web,服务,tomcat,33,share,nginx,usr,root,stream9
From: https://www.cnblogs.com/ckh2023/p/18070130

相关文章

  • aardio 背景透明的3种方式(透明窗体1 webview2,透明窗体2-win-region-bitmap,透明窗体3-w
    3种透明模式我给起个名字,也好记忆。透明模式1:浏览器模式透明模式2:位图遮罩模式透明模式3:背景透明模式aardio背景透明的3种方式(透明窗体1webview2,透明窗体2-win-region-bitmap,透明窗体3-winform-transparent-color)3种透明窗体,主要分成是否可以穿透,遮罩组件,全部显示。透明......
  • 《安富莱嵌入式周报》第334期:开源SEM扫描电子显微镜,自制编辑器并搭建嵌入式环境,免费产
    周报汇总地址:http://www.armbbs.cn/forum.php?mod=forumdisplay&fid=12&filter=typeid&typeid=104 视频版:https://www.bilibili.com/video/BV1om411Z714/目录1、开源SEM扫描电子显微镜,数字图像采集解决方案2、Microchip专家为客户提供免费的产品设计审查服务3、开源植......
  • (一)Web功能测试下的安全测试如何进行?
        想到安全测试很多功能测试人员都很难入手,以为都是专业的安全测试人员去做。比如经常碰到的任务:某某某测试下系统有哪些安全问题,而对于经历过长达五六年的web功能、性能、接口测试人员来说,面对该任务就一头雾水。     万事开头难,难在第一步如何走?没有知......
  • 关于征集参与《智慧能源服务评价技术要求》团体标准起草单位的通知
    根据2023年团体标准管理制修订计划安排,为使标准更具专业性、实用性和可操作性,吸纳行业内有代表性的骨干企业和专家作为起草单位和起草人,现就我单位牵头申报的《智慧能源服务评价技术要求》团体标准公开征集起草单位和起草人。一、申请标准起草单位的机构必须具备以下条......
  • JavaWeb-Maven基础
    Maven是专门用于管理和构建Java项目的工具,是Apache下的一个纯Java开发的开源项目,基于项目对象模型(POM)概念。先来学习一下Maven基础,等后面学完开发框架后再学Maven高级,这次的内容如下一、概述1、简介Maven是专门用于管理和构建Java项目的工具,主要功能1)提供了一套标......
  • CF-933(已更新:B-D)
    CF-933当天晚上舍友在玩剧本杀,不得不说那剧情实在是太狗血了,想不通他们是怎么能玩得那么起劲的但也不能当作这次发挥不好的借口/_\A题最开始没看到数据范围(D也是),B一开始就想到了思路,但调了二十多分钟,甚至因为数组开小了白白多了一次RE……D题才是最难绷的,把题看懂后自己就用......
  • SpringBoot Web开发
    JAR:webapp!自动装配在进行一个springboot项目开发前需要解决的问题:导入静态资源。。首页jsp,模版引擎Thymeleaf装配扩展springMVC增删改查拦截器国际化!静态资源1.在springboot,我们可以使用一下方式处理静态资源webjarslocalhost:8080/webjarspublic,static,/**,res......
  • Codeforces Round 933 (Div. 3)
    CodeforcesRound933(Div.3)AA-RudolfandtheTicket暴力查看代码voidsolve(){intn,m,k;cin>>n>>m>>k;vector<int>b(n),c(m);for(inti=0;i<n;++i)cin>>b[i];for(inti=0;i<m;++i)cin>>c[i];......
  • zabbix直接ip访问web前端
    1、修改配置文件, sudovim/etc/apache2/sites-available/000-default.conf把之前的DocumentRoot/var/www/html这行注释掉,另起一行输入 DocumentRoot/usr/share/zabbix 2、重启Apache、zabbix-server服务sudosystemctlrestartapache2.servicezabbix-server.serv......
  • Codeforces Round 933 (Div. 3)
    CodeforcesRound933(Div.3)A-RudolfandtheTicket解题思路:暴力。代码:#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;usingpii=pair<ll,ll>;#definefifirst#definesesecondusingpiii=pair<ll,pair<ll,ll>&......