Tomcat Installation & configuration &80 default port settings under Mac

Source: Internet
Author: User
Tags tomcat server

Preamble: When you are learning tomcat, when you deploy a virtual service host, you experience an unresponsive situation. Originally thought to be tomcat default port 8080 in the Adjust to (port forwarding settings) default port 80 and Mac comes with Apache conflict. But there are also classmates who use the Mac but get a response. I'll record it again.

1 Installation of Tomcat

    1. Go to Apache official website http://tomcat.apache.org/(preferably click which version to determine which edition you need)

2. I use 8.5.23 version compatible with JAVA7 and later versions (due to the fact that in most cases the company uses JAVA6 or JAVA7)

Click Tar.gz under Core to start the download

3. The file will be downloaded with the name Tomcat for easy follow-up

4. Go to the library under Mac (/library/) to place the folder where

5 entering terminal (Terminal) Enter the following command line

~$ cd/library/tomcat/bin~$./startup. SH

./startup.sh indicates that the Tomcat server is turned on

At this point in the page address bar enter localhost:8080 (127.0.0.1 tomcat default port is 8080) will appear cute kitten that tomcat page

./shutdown.sh means shutting down the server

Note: Since the Mac is UNIX, same as Linux 1024 the following port is not listening permission, when the Tomcat is set to the default 80 port is not responding

2 Setting the default 80 port

8080-port to 80-port forwarding under Mac
MAC OS is essentially a UNIX system, and UNIX systems are mostly non-root users that are not able to use a common port less than 1024 by default. This time if you need to use 80 ports in your development, such as Tomcat, for example, under Vitualbox, you build a HTTP service, you need to do some system port forwarding if you want to access it directly from the browser's localhost (without adding the inexplicable ": Port").

MAC OS 10.10 On Pfctl can do this thing, for details, see

1. Create File:

sudo vim/etc/pf.anchors/eclipse.tomcat.forwarding

File contents:

RDR Pass on Lo0 inet Proto TCP from all to 127.0.0.1 port, 127.0.0.1 port 8080
RDR Pass on Lo0 inet Proto TCP from all to 127.0.0.1 port 443-127.0.0.1 Port 8443
2. Create file:

sudo vim/etc/pf-tomcat.conf
File contents:

Rdr-anchor "Forwarding"
Load Anchor "forwarding" from "/etc/pf.anchors/eclipse.tomcat.forwarding"
3. Start
sudo pfctl-ef/etc/pf-tomcat.conf
Execution results
Copy Code
[email protected] etc# sudo pfctl-ef/etc/pf-tomcat.conf
Pfctl:use of-f option, could result in flushing of rules
Present in the main ruleset added by the system at startup.
See/etc/pf.conf for further details.

No ALTQ Support in kernel
ALTQ related functions Disabled
PF Enabled
Copy Code
Assuming your project http://localhost/myDemo.html this time to access your Web project, you will find that http://localhost/myDemo.html this does not require a 8080 port to access, plus/HTTP Localhost:8080/mydemo.html can't access it.

4. Close
sudo pfctl-d
Execution results
[email protected] etc# sudo pfctl-d
No ALTQ Support in kernel
ALTQ related functions Disabled
PF Disabled
When you visit your Web project, you will find that http://localhost/myDemo.html cannot access it, plus http://localhost:8080/myDemo.html can access it.

or close all
Pfctl-f all-f/etc/pf.conf

But the egg himself still cannot use the 80 port localhost display It works is the Apache server uses

Enter the following code to see the occupancy of Port 80

~$ lsof-i:
Siegdemacbook-pro:bin sieg$ lsof-i: theCOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE Namegoogle theSieg63uIPv40x2fa1ca9090a3144f0t0 TCP192.168.1.101:63417-47.95.49.160: http (established) Google theSieg64uIPv40x2fa1ca909bced7770t0 TCP192.168.1.101:63325-117.122.217.19: http (established) Google theSieg95uIPv40x2fa1ca90883bd7770t0 TCP192.168.1.101:63386-117.122.217.19: http (established) Google theSieg124uIPv40x2fa1ca90883b97770t0 TCP192.168.1.101:62863-58.218.215.168: http (established) Google theSieg133uIPv40x2fa1ca9090a2f06f0t0 TCP192.168.1.101:63080-58.218.215.161: http (established) Google theSieg134uIPv40x2fa1ca90909d544f0t0 TCP192.168.1.101:63081-58.218.215.161: http (established) Google theSieg136uIPv40x2fa1ca90883f344f0t0 TCP192.168.1.101:63422-101.201.169.146: http (established) Google theSieg137uIPv40x2fa1ca909bd947770t0 TCP192.168.1.101:63423-47.95.49.160: http (established) Google theSieg142uIPv40x2fa1ca909c2ba9670t0 TCP192.168.1.101:63424-47.95.49.160: http (established) Google theSieg145uIPv40x2fa1ca909bd69e7f0t0 TCP192.168.1.101:62869-58.218.215.161: http (established) Google theSieg151uIPv40x2fa1ca909c2307770t0 TCP192.168.1.101:63427-117.122.217.6: http (established) Google theSieg152uIPv40x2fa1ca90909d144f0t0 TCP192.168.1.101:63428-117.122.217.6: http (established) Google theSieg153uIPv40x2fa1ca909bd7306f0t0 TCP192.168.1.101:63429-117.122.217.6: http (established) Google theSieg159uIPv40x2fa1ca909bda844f0t0 TCP192.168.1.101:63430-117.122.217.6: http (established) Google theSieg174uIPv40x2fa1ca9090eebe7f0t0 TCP192.168.1.101:62984-58.218.215.161: http (established) Google theSieg185uIPv40x2fa1ca909bd20b570t0 TCP192.168.1.101:63432-124.14.23.249: http (established) Google theSieg186uIPv40x2fa1ca9090eaf25f0t0 TCP192.168.1.101:63433-124.14.23.249: http (established) Google theSieg187uIPv40x2fa1ca909bd70b570t0 TCP192.168.1.101:63434-124.14.23.249: http (established) Google theSieg188uIPv40x2fa1ca909bdb0e7f0t0 TCP192.168.1.101:63436-61.135.186.152: http (close_wait) Google theSieg189uIPv40x2fa1ca909bd13b570t0 TCP192.168.1.101:63435-61.135.162.115: http (close_wait) Google theSieg192uIPv40x2fa1ca908834125f0t0 TCP192.168.1.101:62906-117.122.217.6: http (established) Google theSieg193uIPv40x2fa1ca909be1644f0t0 TCP192.168.1.101:62905-58.218.215.161: http (established) Google theSieg194uIPv40x2fa1ca9090a38b570t0 TCP192.168.1.101:62907-124.14.23.249: http (established) Google theSieg201uIPv40x2fa1ca909bd197770t0 TCP192.168.1.101:63084-58.218.215.168: http (established) Google theSieg206uIPv40x2fa1ca909bd2c25f0t0 TCP192.168.1.101:63089-117.122.217.6: http (established) Google theSieg239uIPv40x2fa1ca9090ef106f0t0 TCP192.168.1.101:62989-124.14.14.215: http (established) Lantern442Sieg37uIPv40x2fa1ca909c22a25f0t0 TCP192.168.1.101:50602->a23- A- the- -. Deploy.static.akamaitechnologies.com:http (established) Lantern442Sieg42uIPv40x2fa1ca909c0de44f0t0 TCP192.168.1.101:65367->a23- A- the- -. Deploy.static.akamaitechnologies.com:http (established) Lantern442Sieg47uIPv40x2fa1ca9090ef47770t0 TCP192.168.1.101:62995-101.201.170.241: http (established)
    • The author shuts down the lantern and shuts down the Apache server

Close Apache

~$ sudo launchctl unload-w /system/library/launchdaemons/org.apache.httpd.plist

Launch Apache

~$ sudo launchctl load-w /system/library/launchdaemons/org.apache.httpd.plist
    • After Apache is turned off, check port 80 is now out of use.

Reset 80 Port Forwarding

sudo pfctl-ef/etc/pf-tomcat.conf

Then go to the browser and enter localhost to see

It worked!!!

Tomcat Installation & configuration &80 default port settings under Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.