精选列表

搜索[centos7],共1059篇文章
优秀的个人博客,低调大师

5招详解linux之openEuler /centos7防火墙基本使用指南

防火墙是一种防火墙管理解决方案,可用于许多 Linux 发行版,它充当 Linux 内核提供的 iptables 数据包筛选系统的前端。在本指南中,将介绍如何为服务器设置防火墙,并向你展示使用管理工具管理防火墙的基础知识 注:你可能正在使用比本指南发布时可用的较新版本的防火墙,或者你的服务器设置与本指南中使用的示例服务器略有不同。因此,本指南中解释的一些命令的行为可能因你的特定配置而异。 防火墙中的基本概念 在我们开始介绍如何实际使用实用程序来管理防火墙配置之前,我们应该熟悉该工具介绍的一些基本概念。firewall-cmd 区域 守护进程使用称为"区域"的实体管理规则组。区域基本上是一组规则,根据计算机连接到的网络的信任级别,规定应允许哪些流量。网络接口被分配一个区域,以指示防火墙应允许的行为。 无论你所处的网络环境有多动态,熟悉每个预定义区域仍然很有用。从最不信任 到最受信任的顺序,中的预定义区域是 drop(丢弃):最低信任级别。所有传入连接在没有回复的情况下丢弃,并且只能进行传出连接。 block(限制):与上述类似,但传入请求不是简单地丢弃连接,而是使用 或 消息被拒绝。icmp-host-prohibited icmp6-adm-prohibited public(公共):表示公共、不受信任的网络。您不信任其他计算机,但可能会根据情况允许选定的传入连接。 external(外部):使用防火墙作为网关时的外部网络。它配置为 NAT 伪装,以便你的内部网络保持私有但可访问。 internal(内部):外部区域的另一侧,用于网关的内部部分。计算机是相当值得信赖的,一些额外的服务是可用的。 dmz: 用于位于 DMZ 中的计算机(无法访问网络其余部分的隔离计算机)。仅允许某些传入连接。 work(工作):用于工作机器。信任网络中的大多数计算机。可能允许使用更多服务。 home(家):家庭环境。它通常意味着你信任大多数其他计算机,并且将接受更多服务。 trusted(受信任):信任网络中的所有计算机。最开放的可用选项,应谨慎使用。 要使用防火墙,我们可以创建规则并更改区域的属性,然后将网络接口分配给最合适的区域。 永久性规则 在防火墙中,规则可以指定为永久规则或即时规则。如果添加或修改了规则,默认情况下,将修改当前运行的防火墙的行为。在下次启动时,将恢复旧规则。 大多数操作都可以采取该标志来指示非临时防火墙应作为目标。这将影响启动时重新加载的规则集。这种分离意味着您可以在活动防火墙实例中测试规则,然后在出现问题时重新加载。还可以使用标志来构建一整组规则,这些规则将在发出重载命令时同时应用。firewall-cmd --permanent --permanent 安装并启用防火墙启动 firewalld默认情况下安装在某些 Linux 发行版上,包括 openEuler/CentOS 7 的许多映像。但是,您可能有必要自行安装防火墙: sudo yum install firewalld sudo systemctl enable firewalld sudo reboot 验证防火墙服务是否正在运行: sudo firewall-cmd --state 修改防火墙规则 在开始修改之前,我们应该熟悉守护进程提供的默认环境和规则。 浏览默认值 通过键入以下类型,我们可以看到当前选择哪个区域为默认值: firewall-cmd --get-default-zone 由于我们没有给出任何指定区域的命令,并且我们的接口都没有配置为绑定到另一个区域,因此该区域也将是唯一的"活动"区域(控制我们接口的流量的区域)。我们可以通过键入以下类型来验证这一点: firewall-cmd --get-active-zones 输出:interfaces: eth0 eth1 我们可以看到,我们的示例服务器有两个网络接口由防火墙控制。它们目前都按照为公共区域定义的规则进行管理。 我们怎么知道哪些规则与公共区域相关?我们可以通过键入以下类型打印出默认区域的配置: sudo firewall-cmd --list-all 输出: public (default, active) target: default icmp-block-inversion: no interfaces: eth0 eth1 sources: services: ssh dhcpv6-client ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: 我们可以从输出中判断此区域是默认的和活跃的,并且和接口与此区域关联,我们也可以看到,此区域允许与 DHCP 客户端(用于 IP 地址分配)和 SSH(用于远程管理)关联的正常操作。 为你的接口选择区域 除非已配置网络接口,否则在启动防火墙时,每个接口都将置于默认区域。 更改接口区域 可以在会话期间将接口与参数结合使用,在会话期间在区域之间转换接口。与修改防火墙的所有命令一样,您需要使用 。 例如,可以通过键入以下内容将接口转换为"主"区域:eth0 sudo firewall-cmd --zone=home --change-interface=eth0 输出:success 可以通过再次请求活动区域来验证这是否成功: firewall-cmd --get-active-zones 输出: home interfaces: eth0 public interfaces: eth1 调整默认区域 如果所有接口由单个区域处理,则只需选择最佳默认区域,然后将它用于配置可能更容易。 可以使用参数更改默认区域。这将立即更改已返回默认到新区域的任何接口:--set-default-zone= sudo firewall-cmd --set-default-zone=home 输出:success 为应用程序设置规则 向区域添加服务 最简单的方法是将所需的服务或端口添加到您使用的区域。同样,您可以使用以下选项获取可用服务的列表:--get-services firewall-cmd --get-services 输出: RH-Satellite-6 amanda-client amanda-k5-client bacula bacula-client bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine condor-collector ctdb dhcp dhcpv6 dhcpv6-client dns docker-registry dropbox-lansync elasticsearch freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master high-availability http https imap imaps ipp ipp-client ipsec iscsi-target kadmin kerberos kibana klogin kpasswd kshell ldap ldaps libvirt libvirt-tls managesieve mdns mosh mountd ms-wbt mssql mysql nfs nrpe ntp openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius rpc-bind rsh rsyncd samba samba-client sane sip sips smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server 例如,如果我们运行一个为常规 HTTP 流量服务的 Web 服务器,我们可以通过键入以下方式,为此会话的"公共"区域中的接口允许此流量: sudo firewall-cmd --zone=public --add-service=http 可以通过使用 或 操作验证操作是否成功:--zone= --list-all --list-services sudo firewall-cmd --zone=public --list-services 输出:dhcpv6-client http ssh 测试到所有内容都正常工作后,如果想要修改永久防火墙规则,以便重新启动后服务仍然可用。我们可以通过键入: sudo firewall-cmd --zone=public --permanent --add-service=http 输出:success 可以通过向操作添加标志来验证这是否成功。需要用于任何操作:--permanent--list-servicessudo``--permanent sudo firewall-cmd --zone=public --permanent --list-services 输出:dhcpv6-client http ssh 现在你的"公共"区域现在将允许端口 80 上的 HTTP Web 流量。如果你的 Web 服务器配置为使用 SSL/TLS,还需要添加该服务。我们可以通过键入以下类型将其添加到当前会话和永久规则集中:https sudo firewall-cmd --zone=public --add-service=https sudo firewall-cmd --zone=public --permanent --add-service=https 创建属于自己的区域 虽然预定义区域对于大多数用户来说可能已经足够了,但定义自己的区域可以更描述其功能会很有帮助。 例如,你可能希望为 Web 服务器创建一个区域,称为"公共网站"。但是,你可能希望为专用网络上提供 DNS 服务配置其他区域。为此,需要建一个名为"私有 DNS"的区域。 添加区域时,必须将其添加到永久防火墙配置中。然后可以重新加载以将配置引入正在运行的会话中。例如,我们可以通过键入以下两个区域来创建上面讨论的两个区域: sudo firewall-cmd --permanent --new-zone=publicweb sudo firewall-cmd --permanent --new-zone=privateDNS 可以通过键入以下类型来验证这些配置是否存在于永久配置中: sudo firewall-cmd --permanent --get-zones 输出:block dmz drop external home internal privateDNS public publicweb trusted work 如之前所述,这些在防火墙的当前实例中尚不可用: firewall-cmd --get-zones 输出:block dmz drop external home internal public trusted work 需要重新加载防火墙以将这些新区域引入活动配置: sudo firewall-cmd --reload firewall-cmd --get-zones 输出:block dmz drop external home internal privateDNS public publicweb trusted work 现在,你可以开始为区域分配适当的服务和端口。通过调整活动实例,然后在测试后将这些更改传输到永久配置。例如,对于"公共 web"区域,如果你需要添加 SSH、HTTP 和 HTTPS 服务: sudo firewall-cmd --zone=publicweb --add-service=ssh sudo firewall-cmd --zone=publicweb --add-service=http sudo firewall-cmd --zone=publicweb --add-service=https sudo firewall-cmd --zone=publicweb --list-all 输出: publicweb target: default icmp-block-inversion: no interfaces: sources: services: ssh http https ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: 同样,我们可以将 DNS 服务添加到我们的"私有 DNS"区域: sudo firewall-cmd --zone=privateDNS --add-service=dns sudo firewall-cmd --zone=privateDNS --list-all 输出: privateDNS interfaces: sources: services: dns ports: masquerade: no forward-ports: icmp-blocks: rich rules: 然后,我们可以将接口更改为这些新区域以测试它们: sudo firewall-cmd --zone=publicweb --change-interface=eth0 sudo firewall-cmd --zone=privateDNS --change-interface=eth1 来测试运行配置。调试完成后(即符合自己的要求)需要向永久配置添加相同的规则。可以通过使用标志重新应用规则来做到这一点:--permanent sudo firewall-cmd --zone=publicweb --permanent --add-service=ssh sudo firewall-cmd --zone=publicweb --permanent --add-service=http sudo firewall-cmd --zone=publicweb --permanent --add-service=https sudo firewall-cmd --zone=privateDNS --permanent --add-service=dns 永久应用这些规则后,重启防火墙服务: sudo systemctl restart network sudo systemctl reload firewalld 验证是否分配了正确的区域: firewall-cmd --get-active-zones 输出: privateDNS interfaces: eth1 publicweb interfaces: eth0 并验证两个区域都提供相应的服务: sudo firewall-cmd --zone=publicweb --list-services 输出:http https ssh sudo firewall-cmd --zone=privateDNS --list-services 输出:dns 这是就成功地设置了自己的区域,如果要使这些区域之一成为其他接口的默认区域之一,请记住使用这个参数配置该行为:--set-default-zone= sudo firewall-cmd --set-default-zone=publicweb 总结 防火墙服务允许你配置可维护的规则和规则集,这些规则和规则集可以考虑你的网络环境。你可以通过使用区域在不同防火墙策略之间无缝切换,并允许管理员将端口管理抽象为更友好的服务。 点击关注,第一时间了解华为云新鲜技术~

优秀的个人博客,低调大师

阿里云 Centos7 部署Java web [jar/war/virmach+vps+域名服务]

(一)第一部分:最基本的jar包运行(无需配置tomcat) [http://60.205.183.114:8081/] 1、配置阿里云(Esc学生服务器、镜像Centos7.7),并远程连接进入终端。 2、安装并配置JDK(参考https://www.jianshu.com/p/093413f2a04f)a)安装jdk。 b)寻找jdk路径配置环境变量。c)简单的Java hello world测试确保安装成功。 3、安装并配置mysql(mariadb)(参考https://blog.csdn.net/DaSo_CSDN/article/details/54754936)a)安装mysql、mariadb server。 b)systemctl 开启服务。c) 打开端口。(阿里云要在控制台打开,参考https://yq.aliyun.com/articles/701181)d) 更改mysql 的root密码,对应于项目配置文件中的密码。 4、利用scp进行文件传输(参考https://www.cnblogs.com/tugenhua0707/p/8278772.html)a)传输spring maven 的快照版本用于测试。 b)传输数据库sql文件。 5、导入数据库a)创建sql文件对应的数据库。 b)利用文件重定向运行sql文件。c)检查数据库是否导入成功 6、运行jar文件,控制台获取公网IP,本机输入IP:8081测试。 7、设置后台运行(已设置:http://60.205.183.114:8081/)a)contrl+c中止。 b)然后通过nohup 和 & 来后台运行。c)ps通过pid来停止后台运行进程。 运行结果整体过程: [root@iZ2ze4r3b4xcztbcsey08cZ ~]# history 1 MAKRER=SHOW_LOCALE;printf $MAKRER""; locale; MAKRER=SHOW_LOCALE;printf $MAKRER""; 2 yum install -y mysql 3 yum install -y mariadb-server mariadb 4 systemctl start mariadb 5 systemctl enable mariadb 6 yum install -y mysql-devel 7 firewall-cmd --zone=public --add-port=3306/tcp --permanent 8 CHECK_TYPE=SHELL; echo "INFO=${CHECK_TYPE} PID=$$ PPID=$PPID TTY=$(tty) SHELL=$0 HOME=$HOME PWD=$PWD| CHECK_SHELL_END" 9 ls 10 ifconfig 11 ls 12 yum list 13 java -version 14 ls 15 yum search java-1.8 16 yum -y install java-1.8.0-openjdk-devel.x86_64 17 java -version 18 cd /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/ 19 pwd 20 vim /etc/profile 21 . /etc/profile 22 vim Demo.java 23 javac Demo.java 24 java Demo 25 su 26 MAKRER=SHOW_LOCALE;printf $MAKRER""; locale; MAKRER=SHOW_LOCALE;printf $MAKRER""; 27 CHECK_TYPE=SHELL; echo "INFO=${CHECK_TYPE} PID=$$ PPID=$PPID TTY=$(tty) SHELL=$0 HOME=$HOME PWD=$PWD| CHECK_SHELL_END" 28 mysql -u root 29 ls 30 pwd 31 ifconfig 32 ls 33 mysql 34 mysql -u root jpetstore < jpetstore.sql 35 mariadb 36 mysql 37 java -jar mypetstore-0.0.3-SNAPSHOT.jar 38 nohup java -jar mypetstore-0.0.3-SNAPSHOT.jar & 39 ps 40 history [root@iZ2ze4r3b4xcztbcsey08cZ ~]# 控制台开端口 利用scp传文件 运行mysql 文件 [root@iZ2ze4r3b4xcztbcsey08cZ ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 5.5.65-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database jpetstore; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> quit Bye [root@iZ2ze4r3b4xcztbcsey08cZ ~]# mysql -u root jpetstore < jpetstore.sql [root@iZ2ze4r3b4xcztbcsey08cZ ~]# mariadb -bash: mariadb: command not found [root@iZ2ze4r3b4xcztbcsey08cZ ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 5 Server version: 5.5.65-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | jpetstore | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec) MariaDB [(none)]> use jpetstore; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [jpetstore]> show tables; +---------------------+ | Tables_in_jpetstore | +---------------------+ | account | | addlog | | bannerdata | | browselog | | cart | | cartitem | | category | | inventory | | item | | lineitem | | orders | | orderstatus | | product | | profile | | sequence | | signon | | supplier | +---------------------+ 17 rows in set (0.00 sec) 访问http://60.205.183.114:8081/ (二)第二部分:利用Tomcat容器对war包进行处理(需要Tomcat) [http://60.205.183.114:8080/myJPetStore_war/index.jsp] 1、安装Tomcat(参考https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-centos-7)a)本地下载tomcat,然后利用scp文件传输 b)设置访问权限c)设置服务配置d)输入IP:8080测试是否已经开启服务 2、数据库/端口配置a)数据库root 密码 和服务器对应 b)端口配置,在上面已经开启了8080端口 3、利用scp传输war包,放到webapp里边(直接会解析出文件) 4、重启tomcat服务a)bin下的shutdown.sh b)bin下的startup.sh 5、本机测试访问a)注意要添加访问的资源的路径/myJPetStore_war/index.jsp,然后tomcat容器会自动到webapp下去寻找 b) 已设置tomcat容器:http://60.205.183.114:8080/myJPetStore_war/index.jsp 运行结果整体过程 52 ls 53 sudo mkdir /opt/tomcat 54 sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1 55 cd /opt/tomcat 56 sudo chgrp -R tomcat /opt/tomcat 57 sudo chmod -R g+r conf 58 sudo chmod g+x conf 59 sudo chown -R tomcat webapps/ work/ temp/ logs/ 60 sudo vi /etc/systemd/system/tomcat.service 61 sudo systemctl daemon-reload 62 sudo systemctl start tomcat 63 sudo systemctl status tomcat 64 sudo systemctl enable tomcat 65 ls 66 cd webapps/ 67 pwd 68 ls 69 sudo systemctl restart tomcat 70 cd ../bin/ 71 ls 72 sh shutdown.sh 73 sh startup.sh 74 history [root@iZ2ze4r3b4xcztbcsey08cZ bin]# 利用systemctl查看tomcat的状态 验证是否开启tomcat服务 将war包直接传入webapp中 然后webapp会自动解析war包(即myJPetStore_war) [root@iZ2ze4r3b4xcztbcsey08cZ webapps]# pwd /opt/tomcat/webapps [root@iZ2ze4r3b4xcztbcsey08cZ webapps]# ls docs examples host-manager manager myJPetStore_war myJPetStore_war.war ROOT 访问http://60.205.183.114:8080/myJPetStore_war/index.jsp (三)第三部分:指定域名进行访问 [http://crf.codes/] 1、配置virmach vps,达到可以通过IP进行访问a)过程同第一步,最后设置为后台运行。 b) 已配置:http://198.12.120.212:8081/ 2、服务器安装web server (安装nginx,参考http://blog.kenyang.net/2019/02/26/upgrade-nginx-to-latest-version-on-centos) 3、在域名提供商 name(或者cloudflare)进行DNS域名解析,进行请求中转。a)ping 域名(ping crf.codes)查看是否绑定成功。 4、修改nginx 配置文件a)Web server 设定域名 b)Location 配置index界面c)开放Linux系统防火墙d)访问crf.code http://crf.codes/ 运行结果域名提供商(name)配置dns 验证dns是否配置成功ping crf.codes,可以看到 修改nginx配置文件 server { listen 80; server_name crf.codes; #charset koi8-r; access_log /var/log/nginx/host.access.log main; location / { # root /usr/share/nginx/html; index index.html index.htm; proxy_pass http://127.0.0.1:8081/; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } 访问crf.codes

优秀的个人博客,低调大师

阿里云 Centos7 部署Java web [jar/war/nginx+域名服务]

(一)第一部分:最基本的jar包运行(无需配置tomcat) [http://60.205.183.114:8081/] 1、配置阿里云(Esc学生服务器、镜像Centos7.7),并远程连接进入终端。 2、安装并配置JDK(参考https://www.jianshu.com/p/093413f2a04f) a)安装jdk。b)寻找jdk路径配置环境变量。c)简单的Java hello world测试确保安装成功。 3、安装并配置mysql(mariadb)(参考https://blog.csdn.net/DaSo_CSDN/article/details/54754936) a)安装mysql、mariadb server。b)systemctl 开启服务。c) 打开端口。(阿里云要在控制台打开,参考https://yq.aliyun.com/articles/701181)d) 更改mysql 的root密码,对应于项目配置文件中的密码。 4、利用scp进行文件传输(参考https://www.cnblogs.com/tugenhua0707/p/8278772.html) a)传输spring maven 的快照版本用于测试。b)传输数据库sql文件。 5、导入数据库 a)创建sql文件对应的数据库。b)利用文件重定向运行sql文件。c)检查数据库是否导入成功 6、运行jar文件,控制台获取公网IP,本机输入IP:8081测试。 7、设置后台运行(已设置:http://60.205.183.114:8081/) a)contrl+c中止。b)然后通过nohup 和 & 来后台运行。c)ps通过pid来停止后台运行进程。 运行结果整体过程: [root@iZ2ze4r3b4xcztbcsey08cZ ~]# history 1 MAKRER=SHOW_LOCALE;printf $MAKRER""; locale; MAKRER=SHOW_LOCALE;printf $MAKRER""; 2 yum install -y mysql 3 yum install -y mariadb-server mariadb 4 systemctl start mariadb 5 systemctl enable mariadb 6 yum install -y mysql-devel 7 firewall-cmd --zone=public --add-port=3306/tcp --permanent 8 CHECK_TYPE=SHELL; echo "INFO=${CHECK_TYPE} PID=$$ PPID=$PPID TTY=$(tty) SHELL=$0 HOME=$HOME PWD=$PWD| CHECK_SHELL_END" 9 ls 10 ifconfig 11 ls 12 yum list 13 java -version 14 ls 15 yum search java-1.8 16 yum -y install java-1.8.0-openjdk-devel.x86_64 17 java -version 18 cd /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/ 19 pwd 20 vim /etc/profile 21 . /etc/profile 22 vim Demo.java 23 javac Demo.java 24 java Demo 25 su 26 MAKRER=SHOW_LOCALE;printf $MAKRER""; locale; MAKRER=SHOW_LOCALE;printf $MAKRER""; 27 CHECK_TYPE=SHELL; echo "INFO=${CHECK_TYPE} PID=$$ PPID=$PPID TTY=$(tty) SHELL=$0 HOME=$HOME PWD=$PWD| CHECK_SHELL_END" 28 mysql -u root 29 ls 30 pwd 31 ifconfig 32 ls 33 mysql 34 mysql -u root jpetstore < jpetstore.sql 35 mariadb 36 mysql 37 java -jar mypetstore-0.0.3-SNAPSHOT.jar 38 nohup java -jar mypetstore-0.0.3-SNAPSHOT.jar & 39 ps 40 history [root@iZ2ze4r3b4xcztbcsey08cZ ~]# 控制台开端口 利用scp传文件 运行mysql 文件 [root@iZ2ze4r3b4xcztbcsey08cZ ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 5.5.65-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database jpetstore; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> quit Bye [root@iZ2ze4r3b4xcztbcsey08cZ ~]# mysql -u root jpetstore < jpetstore.sql [root@iZ2ze4r3b4xcztbcsey08cZ ~]# mariadb -bash: mariadb: command not found [root@iZ2ze4r3b4xcztbcsey08cZ ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 5 Server version: 5.5.65-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | jpetstore | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec) MariaDB [(none)]> use jpetstore; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [jpetstore]> show tables; +---------------------+ | Tables_in_jpetstore | +---------------------+ | account | | addlog | | bannerdata | | browselog | | cart | | cartitem | | category | | inventory | | item | | lineitem | | orders | | orderstatus | | product | | profile | | sequence | | signon | | supplier | +---------------------+ 17 rows in set (0.00 sec) 访问http://60.205.183.114:8081/ (二)第二部分:利用Tomcat容器对war包进行处理(需要Tomcat) [http://60.205.183.114:8080/myJPetStore_war/index.jsp] 1、安装Tomcat(参考https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-centos-7) a)本地下载tomcat,然后利用scp文件传输b)设置访问权限c)设置服务配置d)输入IP:8080测试是否已经开启服务 2、数据库/端口配置 a)数据库root 密码 和服务器对应b)端口配置,在上面已经开启了8080端口 3、利用scp传输war包,放到webapp里边(直接会解析出文件) 4、重启tomcat服务 a)bin下的shutdown.shb)bin下的startup.sh 5、本机测试访问 a)注意要添加访问的资源的路径/myJPetStore_war/index.jsp,然后tomcat容器会自动到webapp下去寻找b) 已设置tomcat容器:http://60.205.183.114:8080/myJPetStore_war/index.jsp 运行结果整体过程 52 ls 53 sudo mkdir /opt/tomcat 54 sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1 55 cd /opt/tomcat 56 sudo chgrp -R tomcat /opt/tomcat 57 sudo chmod -R g+r conf 58 sudo chmod g+x conf 59 sudo chown -R tomcat webapps/ work/ temp/ logs/ 60 sudo vi /etc/systemd/system/tomcat.service 61 sudo systemctl daemon-reload 62 sudo systemctl start tomcat 63 sudo systemctl status tomcat 64 sudo systemctl enable tomcat 65 ls 66 cd webapps/ 67 pwd 68 ls 69 sudo systemctl restart tomcat 70 cd ../bin/ 71 ls 72 sh shutdown.sh 73 sh startup.sh 74 history [root@iZ2ze4r3b4xcztbcsey08cZ bin]# 利用systemctl查看tomcat的状态 验证是否开启tomcat服务 将war包直接传入webapp中 然后webapp会自动解析war包(即myJPetStore_war) [root@iZ2ze4r3b4xcztbcsey08cZ webapps]# pwd /opt/tomcat/webapps [root@iZ2ze4r3b4xcztbcsey08cZ webapps]# ls docs examples host-manager manager myJPetStore_war myJPetStore_war.war ROOT 访问http://60.205.183.114:8080/myJPetStore_war/index.jsp (三)第三部分:指定域名进行访问 [http://crf.codes/] 1、配置virmach vps,达到可以通过IP进行访问 a)过程同第一步,最后设置为后台运行。b) 已配置:http://198.12.120.212:8081/ 2、服务器安装web server (安装nginx,参考http://blog.kenyang.net/2019/02/26/upgrade-nginx-to-latest-version-on-centos) 3、在域名提供商 name(或者cloudflare)进行DNS域名解析,进行请求中转。a)ping 域名(ping crf.codes)查看是否绑定成功。 4、修改nginx 配置文件 a)Web server 设定域名b)Location 配置index界面c)开放Linux系统防火墙d)访问crf.code http://crf.codes/ 运行结果域名提供商(name)配置dns 验证dns是否配置成功ping crf.codes,可以看到 修改nginx配置文件 server { listen 80; server_name crf.codes; #charset koi8-r; access_log /var/log/nginx/host.access.log main; location / { # root /usr/share/nginx/html; index index.html index.htm; proxy_pass http://127.0.0.1:8081/; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } 访问crf.codes

资源下载

更多资源
优质分享Android(本站安卓app)

优质分享Android(本站安卓app)

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario,低调大师唯一一个Java游戏作品

Mario,低调大师唯一一个Java游戏作品

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Apache Tomcat7、8、9(Java Web服务器)

Apache Tomcat7、8、9(Java Web服务器)

Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为目前比较流行的Web 应用服务器。

Sublime Text 一个代码编辑器

Sublime Text 一个代码编辑器

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。