Apache Tomcat For Mac

I mainly do web development on my 15 in Macbook Pro. Mac runs on base Unix foundation so mainly you could install almost all Linux/Unix software on Mac very easily.

Mac OS X comes by default with ApacheWeb Server and PHP. In this tutorial we will go over steps on how to enable those on Mac.

Let’s get started:

How to Install Apache Tomcat 9 on Mac OS X Installing Tomcat 9 on Mac OS X El Capitan is actually quite easy. The Mac OS X installation process is fairly painless and straight forward, but there are a few rough spots along the way. Installing Tomcat. Here are the easy to follow steps to get it up and running on your Mac. Download a binary distribution of the core module: apache-tomcat-9.0.13 from here.I picked the tar.gz in Binary Distributions / Core section. Installing Tomcat 6.0 on Linux, Mac OS X and Windows Apache Tomcat is a flexible, powerful, and widely popular application server and servlet container, which the Apache Software Foundation has developed since 1999, first under the Jakarta project, and now as its own top-level project. Users value Tomcat for its fast start-up, reliable, mature, and fully open codebase, and highly extensible. Oct 21, 2019  Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. Apache Tomcat powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations.

Apache Tomcat (or simply Tomcat) is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages ( JSP ) specifications from Oracle Corporation, and provides a “pure Java” HTTP web server environment for Java code to run. Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

In order to Install Apache Tomcat version 8.x.x (Supports Servlet 3.1 specifications) on your Mac OS X running Yosemite. OS 10.10.x you must have java version 7 or later installed on your Mac.

Enable Apache Web Server

Step-1

Open terminal App and run below command:

Step-2

Open browser and check with URL: http://localhost

Enable PHP Module and verify Perl module

Step-1

Open Terminal App. Mac OS X comes by default with Perl library. Just type below commands to check Perl and PHP Setup.

Terminal Commands
2
4
6
8
10
12
14
16
18
/usr/bin/perl
bash-3.2# pwd
total120
-rw-r--r--1root wheel13077Sep92014magic
drwxr-xr-x14root wheel476Sep92014extra
-rw-r--r--1root wheel20786Sep92014httpd.conf
-rw-r--r--1root wheel20786Jun913:55httpd.conf.bak
bash-3.2# vi httpd.conf

Step-2

Tomcat for mac download

Open file httpd.conf file. You may use any Text Editor also.

Uncomment the following line (remove #): LoadModule php5_module libexec/apache2/libphp5.so

Step-3

Restart Apache Web Server:

Step-4

  • Find DocumentRoot from httpd.conf file. In my case it’s /Users/crunchify/Documents/Blogs/MAMP as I’m using MAMP on my Mac.
  • You may have diff folder something like /Library/WebServer/Documents/.
  • Create below file crunchify-php-on-mac.php under your DocumentRoot folder.
  • If you don’t see folder Web Server then just create it 🙂

Install Apache On Mac

Apache tomcat 8 for mac os x
crunchify-php-on-mac.php
2
4
6
8
<head>
</head>
<?phpecho'<p>Hello World - PHP Testcase on Mac OS X by Crunchify.com...</p><br>Have a fun.. Enjoy..';?>
</html>

Step-5

Now visit this URL: http://localhost/crunchify-php-on-mac.php and you should see php file loaded successfully on browser.

How to Kill Apache httpd process on Mac?

Download Apache Tomcat For Mac

Just incase if you need to kill apache httpd process on Mac then you could use below commands.

2
sudo launchctl unload/System/Library/LaunchDaemons/org.apache.httpd.plist

Enjoy and Happy coding…

Join the Discussion

Share & leave us some comments on what you think about this topic or if you like to add something.

Other Popular Articles...

Apache Tomcat (or simply Tomcat) is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle Corporation, and provides a “pure Java” HTTP web server environment for Java code to run.

If you have any of below questions then you are at right place:

  • Several ports (8080, 8081, 8082) required by Tomcat Server at localhost are already in use
  • Tomcat Server Error – Port 8080 already in use
  • port 8080 required is in use
  • port 8080 already in use eclipse
  • how to stop port 8080 in windows

I’ve setup tomcat as Windows Service. Running Tomcat as a Windows Service provides a number of benefits that are essential when moving from a development set-up to a production environment.

Benefit-1) Setup reliable automatic startup on boot

  • Essential in an environment where you may want to remotely reboot a Java System after maintenance without worrying about whether your server will come back online.

Benefit-2) Setup Tomcat server startup without active user login

  • In a data center, it is not reasonable to expect an active login from the system just to run Tomcat. In fact, Tomcat is often run on blade servers that may not even have an active monitor connected to them. Windows Services are owned by the System, and can be started without an active user.

Benefit-3) Better Security

Recently I wanted to start/stop my Tomcat Server via command line as wanted to create quick shall script to do it. Official documentation provided below commands in the form of //XX// ServiceName

Available command line options are:

  • //TS// Run the service as console application This is the default operation. It is called if the no option is provided. The ServiceName is the name of the executable without exe suffix, meaning Tomcat6
  • //RS// Run the service Called only from ServiceManager
  • //SS// Stop the service
  • //US// Update service parameters
  • //IS//Install service
  • //DS// Delete service Stops the service if running

But rather doing it this way I found below commands very useful and simple.

Apache Tomcat 8 For Mac

1) Windows (if Tomcat is setup as Windows Service)

  • To Start server: <Tomcat Root>/bin>Tomcat8.exe start
  • To Stop server: <Tomcat Root>/bin>Tomcat8.exe stop

2) Windows (if you have downloaded binaries as .zip)

  • To Start server: <Tomcat Root>/bin>catalina.bat start
  • To Stop server: <Tomcat Root>/bin>catalina.bat stop

3) Mac/Linux/Unix (if you have downloaded binaries as .zip)

  • To Start server: <Tomcat Root>/bin>./catalina.sh start
  • To Stop server: <Tomcat Root>/bin>./catalina.sh stop

Below are all catalina.sh command parameters:

catalina.sh
2
4
6
8
10
12
14
commands:
debug-security Debug Catalina withasecurity manager
run Start Catalina inthe current window
run-security Start inthe current window with security manager
start-security Start inaseparate window with security manager
stop Stop Catalina,waiting up to5seconds forthe process toend
stopnStop Catalina,waiting up tonseconds forthe process toend
stop-force Stop Catalina,wait up to5seconds andthenusekill-KILL ifstill running
stopn-force Stop Catalina,wait up tonseconds andthenusekill-KILL ifstill running
configtest Runabasic syntax check on server.xml-check exit code forresult

Startup Screenshot:

How to check if Tomcat is already running and kill existing tomcat process.

Step-1) Find out the process using command ps -ef | grep tomcat

2
50256188107:31PMttys0010:04.23/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java-Djava.util.logging.config.file=/Users/appshah/Downloads/apache-tomcat-8.5.4/conf/logging.properties-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager-Djdk.tls.ephemeralDHKeySize=2048-classpath/Users/appshah/Downloads/apache-tomcat-8.5.4/bin/bootstrap.jar:/Users/appshah/Downloads/apache-tomcat-8.5.4/bin/tomcat-juli.jar-Dcatalina.base=/Users/appshah/Downloads/apache-tomcat-8.5.4-Dcatalina.home=/Users/appshah/Downloads/apache-tomcat-8.5.4-Djava.io.tmpdir=/Users/appshah/Downloads/apache-tomcat-8.5.4/temp org.apache.catalina.startup.Bootstrap start

Here 2nd column value is a process ID. In our case it’s 56188.

Apache Tomcat Server For Mac

You could visit link http://localhost:8080 and you should see welcome page.

Step-2) Kill process using command kill -9 <process ID>

kill tomcat process

Here, 56188 is a process ID which we got it from step-1.

Now, link http://localhost:8080/ shouldn’t be working for you.

Join the Discussion

Share & leave us some comments on what you think about this topic or if you like to add something.

Other Popular Articles...