配置Tomcat的虚拟主机,并搭建java应用(上)

需求:使用Tomcat部署一个Java应用(zrlog博客)。

添加一个虚拟主机
[root@dl-001 src]# vim /usr/local/tomcat/conf/server.xml         //添加以下配置

<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>

下载zrlog-1.7.1,并cp到指定目录

[root@dl-001 src]# wget http://dl.zrlog.com/release/zrlog-1.7.1-baaecb9-release.war

[root@dl-001 src]# ls /usr/local/tomcat/webapps/
docs  examples  host-manager  manager  ROOT

[root@dl-001 src]# ls
 zrlog-1.7.1-baaecb9-release.war

[root@dl-001 src]# cp zrlog-1.7.1-baaecb9-release.war /usr/local/tomcat/webapps/

[root@dl-001 src]# ls /usr/local/tomcat/webapps/        //查看可以看出多了一个目录,自动解压了
docs      host-manager  ROOT                         zrlog-1.7.1-baaecb9-release.war
examples  manager       zrlog-1.7.1-baaecb9-release

修改zrlog的名字
[root@dl-001 webapps]# mv zrlog-1.7.1-baaecb9-release zrlog    //为了防止再次自动解压,修改名字即可。
[root@dl-001 webapps]# ls
docs      host-manager  ROOT   zrlog-1.7.1-baaecb9-release
examples  manager       zrlog  zrlog-1.7.1-baaecb9-release.war

使用浏览器访问zrlog

QQ截图20180109193654.png

说明:如上图需要使用mysql用户


查看Mysql是否启动
[root@dl-001 webapps]# ps aux |grep mysql
root      1430  0.0  0.1 115392  1484 ?        S    10:40   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/dl-001.pid
mysql     1775  0.0 44.5 1038596 449452 ?      Sl   10:40   0:19 /usr/local/mysql/bin/mysqd --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/dl-001.err --pid-file=/data/mysql/dl-001.pid --socket=/tmp/mysql.sock
root      3625  0.0  0.0 112680   972 pts/0    R+   19:37   0:00 grep --color=auto mysql

创建zrlog相关数据库和用户
[root@dl-001 webapps]# mysql -uroot -p'mysqldl991124'    //进入mysql
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> create database zrlog;        //创建zrlog数据库;
Query OK, 1 row affected (0.00 sec)


mysql> grant all on zrlog.* to 'zrlog'@'127.0.0.1' identified by 'mysqldl991124';        //创建用户
Query OK, 0 rows affected (0.13 sec)

mysql> quit
Bye

查看创建的用户是否正确
[root@dl-001 webapps]# mysql -uzrlog -h127.0.0.1 -p'mysqldl991124'        //正确
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 3
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.

在浏览器上填写信息

QQ截图20180109194704.png

说明:填写完之后,点击下一步


QQ截图20180109194903.png

说明:填写密码和标题,之后点击下一步

QQ截图20180109194959.png

说明:可以点击查看


QQ截图20180109195106.png

说明:此时搭建的博客就可以写帖子了!!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值