Connector port="8080" protocol="HTTP/1.1"修改为Connector port="80" protocol="HTTP/1.1"
[root@hf-01 ~]# vim /usr/local/tomcat/conf/server.xml
搜索 /8080
这里是控制监听端口的,将这里的 8080 改为 80
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
保存退出
[root@hf-01 ~]# /usr/local/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.8
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@hf-01 ~]# /usr/local/tomcat/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/local/jdk1.8
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@hf-01 ~]#
[root@hf-01 ~]# netstat -lntp |grep java
tcp6 0 0 :::80 :::* LISTEN 3113/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 3113/java
tcp6 0 0 :::8009 :::* LISTEN 3113/java
[root@hf-01 ~]#
<Host name="www.123.cn" appBase=""
unpackWARs= "true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/data/wwwroot/123.cn/" debug="0" reloadable="true" crossContext="true"/>
</Host>
[root@hf-01 ~]# vim /usr/local/tomcat/conf/server.xml
搜索 /<Host
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" //日志相关
prefix="localhost_access_log" suffix=".txt" //日志相关
pattern="%h %l %u %t "%r" %s %b" /> //日志相关
</Host>
<Host name="www.123.cn" appBase=""
##域名为www.123.cn,appbase后为空,就不会于docBase相互干扰
unpackWARs= "true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/data/wwwroot/123.cn/" debug="0" reloadable="true" crossContext="true"/>
## 自定义站点路径,不使用自动安装war的方式
</Host>
保存退出
[root@hf-01 ~]# cd /usr/local/src
[root@hf-01 src]# wget http://dl.zrlog.com/release/zrlog-1.7.1-baaecb9-release.war
[root@hf-01 src]# ls /usr/local/tomcat/webapps/
docs examples host-manager manager ROOT
[root@hf-01 src]#
[root@hf-01 src]# cp zrlog-1.7.1-baaecb9-release.war /usr/local/tomcat/webapps/
[root@hf-01 src]# ls /usr/local/tomcat/webapps/
docs host-manager manager zrlog-1.7.1-baaecb9-release
examples logs ROOT zrlog-1.7.1-baaecb9-release.war
[root@hf-01 src]#
[root@hf-01 src]# cd /usr/local/tomcat/webapps/
[root@hf-01 webapps]# mv zrlog-1.7.1-baaecb9-release zrlog
[root@hf-01 webapps]# ls
docs host-manager manager zrlog
examples logs ROOT zrlog-1.7.1-baaecb9-release.war
[root@hf-01 webapps]# ls
docs logs zrlog
examples manager zrlog-1.7.1-baaecb9-release
host-manager ROOT zrlog-1.7.1-baaecb9-release.war
[root@hf-01 webapps]#
[root@hf-01 webapps]# ps aux |grep mysql
root 1313 0.0 0.1 115388 1680 ? S 1月21 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/hf-01.pid
mysql 1653 0.0 45.1 1039104 456604 ? Sl 1月21 0:20 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/hf-01.err --pid-file=/data/mysql/hf-01.pid
root 4744 0.0 0.0 112676 984 pts/0 R+ 06:16 0:00 grep --color=auto mysql
[root@hf-01 webapps]#
[root@hf-01 webapps]# mysql -uroot -phanfeng
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zrlog;
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> grant all on zrlog.* to 'zrlog'@127.0.0.1 identified by 'hanfeng1';
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
[root@hf-01 webapps]# mysql -uzrlog -h127.0.0.1 -phanfeng1
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
| zrlog |
+--------------------+
3 rows in set (0.01 sec)
mysql>
<Host name="www.123.cn" appBase=""
##域名为www.123.cn,appbase后为空,就不会于docBase相互干扰
unpackWARs= "true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/data/wwwroot/123.cn/" debug="0" reloadable="true" crossContext="true"/>
## 自定义站点路径,不使用自动安装war的方式
</Host>
[root@hanfeng webapps]# mkdir /data/wwwroot/123.cn/
[root@hanfeng webapps]#
[root@hanfeng webapps]# mv /usr/local/tomcat/webapps/zrlog/* /data/wwwroot/123.cn/
[root@hanfeng webapps]#
192.168.202.130 www.123.cn
[root@hanfeng webapps]# /usr/local/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.8/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@hanfeng webapps]# /usr/local/tomcat/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/local/jdk1.8/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@hanfeng webapps]#
[root@hanfeng webapps]# netstat -lntp |grep 80
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 3484/java
tcp6 0 0 :::8009 :::* LISTEN 3484/java
tcp6 0 0 :::80 :::* LISTEN 3484/java
[root@hanfeng webapps]#
[root@hf-01 webapps]# ls /usr/local/tomcat/logs
catalina.2018-01-19.log localhost.2018-01-19.log
catalina.out localhost_access_log.2018-01-19.txt
host-manager.2018-01-19.log manager.2018-01-19.log
[root@hf-01 webapps]#
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="123.cn_access" suffix=".log"
pattern="%h %l %u %t "%r" %s %b" />