Directory
- 1. Preface
- 2. Yum Install Tomcat
- 2. Yum install MySQL
- 3. Download Jpress and install
- 4. Configure Tomcat so that it can deploy multiple Web sites
- 5. Install Nginx and configure
- 6. Pack the jpress already installed
- Resources
1. Preface
Tomcat is an open source software, is running the Java back-end program, is simply to execute .jsp
the program, Tomcat itself can also run static resources, such as HTML,CSS, but usually Tomcat will still cooperate with Appache or nginx use, To achieve better performance. Its official website istomcat.apache.org
Jpress claims to be Java version of WordPress (a PHP-based Open source blog program), and was developed by the Chinese, but I do not know why the current official website is not open.
The installation environment I use is as follows:
- Windows-10
- Vmware-workstation-12-pro
- CentOS-7.5
- Xshell-5-free for Home
Overview of overall Operating procedures:
- Download the
jpress-web-newest.war
installation package (
- Can be downloaded here to Gitee.com/fuhai/jpress/tree/alpha/wars
- Yum Install tomcat-7.0 (Epel source Ready)
- Yum Install MySQL5.7 (official source)
- Create a remote Connection account password
- Create a jpress library in advance
- Installing jpress
- Browser Access
10.0.0.7:8080/jpress-web-newest
Installation
- Configure Tomcat so that it can deploy multiple Web sites
- Transfer the jpress to
/usr/share/tomcat/webapps-jpress
- Modify
/usr/share/tomcat/conf/server.xml
- Yum Install nginx-1.14 (official source)
- Some basic optimizations for Nginx
- Configuring Nginx jpress.conf to implement proxy tomcat
jpress-web-newest.war
is a Java compression package, which contains the jpress source code, we will say how to decompress.
2. Yum Install Tomcat
[[email protected] ~]# hostname -I10.0.0.7 172.16.1.7 [[email protected] ~]# yum install tomcat tomcat-webapps tomcat-admin-webapps -y[[email protected] ~]# systemctl restart tomcat[[email protected] ~]# netstat -lntup | grep 8080
Tomcat is listening on port 8080 by default, note that there is no conflict, the default code location is /usr/share/tomcat/webapps/
, you can see the default page directly in the browser after the installation is complete:
2. Yum install MySQL
New Installation MySQL5.7, authorizing remote connection users, creating the Jpress database:
[[email protected] ~]# hostname -I10.0.0.51 172.16.1.51 [[email protected] ~]# yum install mysql-community-server -y[[email protected] ~]# mysql -uroot -p$(awk '/temporary password/ {print $NF}' /var/log/mysqld.log) --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'As4k.top'";#创建账号并授权(这里把权限打满)[[email protected] ~]# mysql -uroot -pAs4k.top -e 'GRANT ALL PRIVILEGES ON *.* TO "as4k"@"%" IDENTIFIED BY "As4k.top"';#创建jpress数据库[[email protected] ~]# mysql -uroot -pAs4k.top -e "CREATE DATABASE jpress";
My database here is stored separately on one machine, if it is a local machine, then the MySQL native root account password can be prepared.
3. Download Jpress and install
1 You can download the 0.4 version of the war package here.
https://gitee.com/fuhai/jpress/blob/alpha/wars/jpress-web-newest.war
2 jpress-web-newest.war
move to /usr/share/tomcat/webapps/
, and refresh 10.0.0.7:8080
, then you will see the war package is automatically extracted by Tomcat.
[[email protected] webapps]# ls -lh /usr/share/tomcat/webapps/total 20Mdrwxr-xr-x 8 tomcat tomcat 127 Oct 3 16:24 examplesdrwxr-xr-x 5 root tomcat 87 Oct 3 16:24 host-managerdrwxr-xr-x 7 tomcat tomcat 102 Oct 3 16:42 jpress-web-newest-rw-r--r-- 1 root root 20M Sep 19 2016 jpress-web-newest.wardrwxr-xr-x 5 root tomcat 103 Oct 3 16:24 managerdrwxr-xr-x 3 tomcat tomcat 306 Oct 3 16:24 ROOTdrwxr-xr-x 5 tomcat tomcat 86 Oct 3 16:24 sample
jpress-web-newest.war
We moved here. The jpress-web-newest
directory is tomcat to help us extract, the other directories are already exist before, no tube.
3 Browser access to 10.0.0.7:8080/jpress-web-newest
start installation jpress
The installation process and other products are basically consistent, no more than to provide database information and create a webmaster account.
After installation, you need to restart Tomcat for normal access.
[[email protected] ~]# systemctl restart tomcat
Jpress Homehttp://10.0.0.7:8080/jpress-web-newest/
Jpress Background Management pagehttp://10.0.0.7:8080/jpress-web-newest/admin/
So far, our jpress has been able to be used alone, then we use the Nginx proxy forwarding function, configure nginx let them work together.
4. Configure Tomcat so that it can deploy multiple Web sites
If the reader is familiar with nginx use, there may be a question, each visit to jpress blog, you need to enter 10.0.0.7:8080/jpress-web-newest/
such a large string, the default port does not have to say 80, also need to enter their own input directory structure, obviously not very reasonable, and to do so, Nginx Configuration agent forwarding will not play, so we need to move the jpress to a suitable location.
We know that the direct access to 10.0.0.7:8080
Open is the Tomcat default page, the code of this page is written in the /usr/share/tomcat/webapps/ROOT/
directory, of course, you can delete all of this content, and then put the jpress code mv
in, obviously this is not the best solution, if you need to install other products, It's not going to play again.
Finally, we decided to deploy the 2nd product in the following scenario (the default is 1th, Jpress is 2nd):
- Duplicate a copy
/usr/share/tomcat/webapps/
- Modify
/usr/share/tomcat/conf/server.xml
, add the 2nd set of configurations
The detailed procedure is as follows:
1 copy an WebApps and name it webapps-jpress
[[email protected] ~]# cp -rp /usr/share/tomcat/webapps/ /usr/share/tomcat/webapps-jpress
Note Directory attributes, user identities, need to remain unchanged
2 Move the jpress code all to/usr/share/tomcat/webapps-jpress
[[email protected] webapps-jpress]# cd /usr/share/tomcat/webapps-jpress; pwd/usr/share/tomcat/webapps-jpress[[email protected] webapps-jpress]# rm -rf ROOT/*[[email protected] webapps-jpress]# mv jpress-web-newest/* ROOT/[[email protected] webapps-jpress]# ls -l /usr/share/tomcat/webapps-jpress/ROOT/total 4drwxr-xr-x 3 tomcat tomcat 38 Oct 3 16:42 META-INF-rw-r--r-- 1 tomcat tomcat 96 Jul 27 2016 robots.txtdrwxr-xr-x 11 tomcat tomcat 139 Oct 3 16:42 staticdrwxr-xr-x 4 tomcat tomcat 31 Oct 3 16:42 templatesdrwxr-xr-x 6 tomcat tomcat 75 Oct 3 16:42 WEB-INF
3 modifications/usr/share/tomcat/conf/server.xml
Need to /usr/share/tomcat/conf/server.xml
add a pair of service tag, to be the webapps-jpress file to take effect, the file already has a default service tag is defined by default home page, we just copy it, and then change the listening port, it can be used for their own use, Here is a post-comment, which can be used as a control:
[[email protected] ~]# cat/usr/share/tomcat/conf/server.xml.....<!--BEGIN jpress Config--><service Name= "Webapps-jpress" > <connector port= "7070" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "7443"/> <connector port= "7009" protocol= "ajp/1.3" redirectport= "7443"/> <Engine N Ame= "webapps-jpress" defaulthost= "localhost" > <realm classname= "Org.apache.catalina.realm.LockOutRealm" > <realm classname= "Org.apache.catalina.realm.UserDatabaseRealm" resourcename= "Userdatabase"/> </real m>
4 Accessing in the browser10.0.0.7:7070
Can first check the lower port monitoring is normal, the port in the beginning of 7, is our jpress listening port:
It's better to restart Tomcat again.
[Email protected] ~]# systemctl restart Tomcat
At this point the browser access 10.0.0.7:7070
can see the jpress page directly:
5. Install Nginx and configureHere is the configuration of Nginx proxy tomcat for direct access to the domain name jpress
1 Install Nginx and perform some basic optimizations
[[email protected] ~]# hostname -I10.0.0.7 172.16.1.7 [[email protected] ~]# yum install nginx -y#添加虚拟用户wwwgroupadd -g 666 wwwuseradd -u666 -g666 -s /sbin/nologin -M www#设置nginx运行用户为wwwsed -i '/^user/c user www;' /etc/nginx/nginx.conf#设置nginx上传文件大小为2Ggrep 'client_max_body_size' /etc/nginx/nginx.conf[ $? -eq 1 ] && sed -i '/^http/a client_max_body_size 2048M;' /etc/nginx/nginx.conf
2 Configuring Nginx jpress.conf
[[email protected] ~]# cat /etc/nginx/conf.d/jpress.conf server { listen 80; server_name jpress.as4k.com; location / { proxy_pass http://127.0.0.1:7070/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 30; proxy_send_timeout 60; proxy_read_timeout 60; proxy_buffering on; proxy_buffer_size 32k; proxy_buffers 4 128k; }}[[email protected] ~]# nginx -t[[email protected] ~]# systemctl restart nginx
The most important thing is this line.proxy_pass http://127.0.0.1:7070/;
3 Setting up the Windows Hosts file resolution
C:\Windows\System32\drivers\etc\hosts10.0.0.7 jpress.as4k.com
4 Browser Accessjpress.as4k.com
Access to the Background management page
6. Pack the jpress already installedThis step is optional, mainly in order to facilitate the deployment of jpress on multiple machines, where the package is the compression package on Linux, it is .tar.gz
relatively simple to use Tomcat to .war
extract after the decompression package for later use. But I prefer a more thorough packaging, the whole /usr/share/tomcat/webapps-jpress/
package, and the database backup, and then install the direct decompression, import database, done.
If the database connection information changes during this installation, you need to modify the database connection information and use the following command to find out where the Jpress database connection information is:
[[email protected] ~]# grep -R 'As4k.top' /usr/share/tomcat/webapps-jpress//usr/share/tomcat/webapps-jpress/ROOT/WEB-INF/classes/db.properties:db_password=As4k.top
The package directory uses the TAR command:
[[email protected] ~]# cd /usr/share/tomcat/; pwd/usr/share/tomcat/[[email protected] tomcat]# tar -zcf webapps-jpress.tar.gz webapps-jpress/
Don't forget /usr/share/tomcat/conf/server.xml
to keep a copy too.
To back up the Jpress database:
[[email protected] ~]# mysqldump -uroot -p'As4k.top' --databases jpress > /root/jpress.sql
Import Database availablemysql -uroot -pAs4k.top < /root/jpress.sql
ResourcesBuild jpress on Linux (Java edition wordpress)
https://www.jianshu.com/p/c0b3be596860
http://tomcat.apache.org/
Https://www.cnblogs.com/naaoveGIS/p/5478208.html
https://www.howtoing.com/run-deploy-multiple-web-applications-instances-tomcat-centos-ubuntu/
Author: Alpha 4 K
Source: https://www.cnblogs.com/asheng2016/p/tomcat.html
jpress-with Nginx and Tomcat installation