Tomcat安装JPress
上线代码有两种方式,第一种方式是直接将程序目录放在webapps目录下面,这种方式大家已经明白了,就不多说了。第二种方式是使用开发工具将程序打包成war包,然后上传到webapps目录下面。下面让我们见识一下这种方式。
系统环境
[root@tomcat ~]# getenforce Disabled [root@tomcat ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Jul 19 08:39:10 centos7 systemd[1]: Starting firewalld - dynamic firewall daemon... Jul 19 08:39:11 centos7 systemd[1]: Started firewalld - dynamic firewall daemon. Jul 19 11:20:50 git systemd[1]: Stopping firewalld - dynamic firewall daemon... Jul 19 11:20:51 git systemd[1]: Stopped firewalld - dynamic firewall daemon. [root@tomcat ~]# ip a|grep eth1 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 172.16.1.70/24 brd 172.16.1.255 scope global eth1 [root@tomcat ~]#
什么是JPress?
JPress是一款和WordPress类似的程序,WordPress支持PHP语言,JPress则支持Java语言,更多关于JPress的介绍可以去JPress的官方网站查看:http://jpress.io/。JPress的安装包也可以在GitHub中下载:https://github.com/JpressProjects/jpress。也可以使用我提供的安装包:https://pan.baidu.com/s/1o8wSOQI 密码:8co8。
安装JPress
[root@tomcat webapps]# cd /application/tools/ [root@tomcat tools]# ll total 194204 -rw-r--r-- 1 root root 8491533 Jul 20 2017 apache-maven-3.3.9-bin.tar.gz -rw-r--r-- 1 root root 9128610 Jul 20 2017 apache-tomcat-8.0.27.tar.gz -rw-r--r-- 1 root root 181238643 Jul 20 2017 jdk-8u60-linux-x64.tar.gz [root@tomcat tools]# tar xf apache-maven-3.3.9-bin.tar.gz -C /application/ [root@tomcat tools]# ln -s /application/apache-maven-3.3.9 /application/maven [root@tomcat tools]# sed -i.ori2 '$a export MAVEN_HOME=/application/maven\nexport PATH="$MAVEN_HOME/bin:$PATH"' /etc/profile [root@tomcat tools]# source /etc/profile
检查是否安装成功:
[root@tomcat tools]# mvn -vsrsion Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00) Maven home: /application/maven Java version: 1.8.0_60, vendor: Oracle Corporation Java home: /application/jdk1.8.0_60/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-327.el7.x86_64", arch: "amd64", family: "unix" [root@tomcat tools]#
上传JPress的war包:(在我提供的百度云盘链接中有),可以通过ftp或者rz等各种方式上传。
安装JPress:
[root@tomcat tools]# cd /application/tomcat/webapps/ROOT/ [root@tomcat ROOT]# mv index.jsp /tmp/ [root@tomcat ROOT]# jar xf /application/tools/jpress-web-newest.war [root@tomcat ROOT]# ls asf-logo.png bg-middle.png bg-upper.png meminfo.jsp robots.txt tomcat.css tomcat-power.gif asf-logo-wide.gif bg-nav-item.png build.xml META-INF static tomcat.gif tomcat.svg bg-button.png bg-nav.png favicon.ico RELEASE-NOTES.txt templates tomcat.png WEB-INF [root@tomcat ROOT]#
开启一台mysql服务器,并创建对应的数据库和用户:
这里我开启一台ip为172.16.1.51的MySQL服务器作为JPress的数据库支持,也可以在当前服务器自行安装MySQL。
[root@mysql-db01 ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 112 Server version: 5.6.34-log Source distribution 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 jpress; Query OK, 1 row affected (0.00 sec) mysql> show create database jpress; +----------+-----------------------------------------------------------------+ | Database | Create Database | +----------+-----------------------------------------------------------------+ | jpress | CREATE DATABASE `jpress` /*!40100 DEFAULT CHARACTER SET utf8 */ | +----------+-----------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> mysql> grant all on jpress.* to jpress@"172.16.1.%" identified by '123456'; Query OK, 0 rows affected (0.00 sec) mysql>
数据库和授权用户创建完毕。(这里我创建的数据库为jpress,用户名为jpress,密码为123456)。
网页上初始化JPress
浏览器打开地址http://10.0.0.70:8080
点击下一步:
填写完相关信息,点击下一步:
设置网站名称、管理员账号密码之后点击完成即可。如果等待一会儿,网页没有自动刷新,可以手动重启一次Tomcat即可。
JPress后台登陆地址:http://10.0.0.70:8080/admin
输入管理员账号密码即可跳转到后台管理界面:
其实JPress跟WordPress的界面和操作非常相似,而且JPress比WordPress更加简洁,没有广告。