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.
Step 2: Configure Tomcat Server. Read this to Configure Tomcat Server. Step 3: Start the Tomcat Server. To start the Tomcat server, open a new “Terminal” (Go ⇒ Utilities ⇒ Terminal) and issue. Download Tomcat from the official website (tomcat.apache.org), select Tar.gz format under the Core section. Extract the Tomcat to directory: /Library, in order to facilitate the use, rename the folder to 'Tomcat' 3. Open Terminal, modify folder permissions. Sudo chmod 755 /Library/Tomcat/bin/.sh. 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. You are currently using you encounter a problem with this mirror, please select another mirror. If all mirrors are failing, there.
Sep 17, 2021 The configuration of the Apache Tomcat server is complete. Start the Apache Tomcat server. To start the Apache Tomcat server, open a new terminal and change the working directory as follows. How To Download Apache Tomcat For Mac Windows 10. Next type the following command in order to start the server. For more information concerning Tomcat Native, see the Tomcat Native site. Source (please choose the correct format for your platform) Native 1.2.31 Source Release tar.gz (e.g. Unix, Linux, Mac OS). The Tomcat configuration files, among other things, may list the applications that should be deployed at the server start. If this checkbox is selected, all the applications so listed will be deployed on the server in addition to the artifacts specified on the Deployment tab.
Let’s get started:
Tomcat; APR; modperl. Sponsorship; Downloading the Apache HTTP Server¶ Use the links below to download the Apache HTTP Server from one of our mirrors.
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.
4 8 12 16 | bash-3.2# pwd -rw-r--r--1root wheel13077Sep92014magic -rw-r--r--1root wheel20786Sep92014httpd.conf bash-3.2# vi httpd.conf |
Step-2
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
fromhttpd.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 🙂
4 8 | </head> <?phpecho'<p>Hello World - PHP Testcase on Mac OS X by Crunchify.com..</p><br>Have a fun. Enjoy.';?> |
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?
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
If you liked this article, then please share it on social media or leave us your comments. Limited time 3 months free WPEngine hosting.
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 and configurable functionality.
Apache Tomcat 6 has the ability to run either as a stand alone web server, or as a pure servlet container or cluster of containers behind an HTTP web server proxy or load balancer. This makes Tomcat a favorite choice for a broad spectrum of different scenarios, from small, one-server websites to large-scale, high-availability enterprise production environments. Tomcat 6 implements the Servlet 2.5 and JSP 2.1 specifications, and includes many new features, such as a new NIO Connector, injectable thread pools, improved logging, and more.
In this article, we'll learn how to install and configure Tomcat 6, the most recent stable Tomcat branch as of May 2010, on Linux, Windows, and Mac OS X machines.
Apache Tomcat 8 Free Download
Tip: Installing Tomcat as a Windows Service can be difficult. Tcat Server, the enterprise Tomcat application server, makes it simple! Click here to download Tcat Server today!
Tomcat 6 installation methods - Packages, installers and binaries
Before we go over the installation instructions, let's take a brief look at the different methods by which Tomcat can be installed on each platform, and the advantages and disadvantages of choosing one method over another.
On a Mac OS X machine - Binary distribution
For Mac users, there is only one way to install Tomcat 6 - by downloading the latest binary from an Apache mirror, and following the instructions we've outlined below.
In fact, if you're a Mac user, you may want to click here right now to skip the following about packaged distributions as opposed to binary distributions, and get right down to installing Tomcat.
On a Windows Machine - Binary distribution or package installer
Windows users can either download the 32 or 64-bit binary distribution and install Tomcat manually, or use the Windows installer, which in its latest version includes both 32 and 64-bit distributions, and attempts to select the appropriate distribution based on the JDK you have installed.
Either of these methods is acceptable, but we recommend you use the installer. It's well-designed and maintained, and automatically takes care of some annoying Windows-specific installation issues, such as enabling Tomcat as a Windows service and setting registry values related to the JVM.
For our step-by-step guide to installing Tomcat on a Windows machine, click here.
On a Linux machine - Binary Distribution, bundled distribution or repository package
Linux users can either download and install the binary distribution of Tomcat from an Apache mirror, use one of many available platform-specific repackaged Tomcat distributions, which are provided by various Linux vendors and usually incorporate some pre-configured settings to help Tomcat run on the chosen platform, or install from a general Linux repository package, such as JPackage or RPM.
While some of these packages are well maintained, others include outdated versions of Tomcat, non-documented modifications, or are not quickly updated with new patches released by the Tomcat team. (A notable exception is the Debian/Ubuntu Tomcat package, which is maintained with the help of contributions from the MuleSoft development team. For more information, click here to read 'A Better Tomcat For Ubuntu', a blog post about the partnership.)
Although installing from a package has the benefit of being very simple, usually consisting of no more than two or three commands, we recommend that you take the time to install and configure Tomcat yourself from the binary distribution. Completing the initial install and configuration process by hand is a great introduction to Tomcat's internal settings, and you'll never have to wonder if your package has some odd modification or is missing a vital security patch.
Click here to jump to our simple, step-by-step instructions for installing the Tomcat binary distribution on a Linux machine.
Installing Tomcat 6 on Mac OS X
The Mac OS X installation process is fairly painless and straightforward, but there are a few rough spots along the way. Follow these step by step instructions to get Tomcat up and running on your Mac OS X machine in no time.
Step 1: Configure environment variables
Tomcat finds certain resources, such as your Java runtimes, by reading values from your environment variables. On Mac OS X, the variable that Tomcat is looking for is 'JAVA_HOME', which points it to your JDK for compilation purposes.
If you are new to the Mac platform, and you are wondering why there's been no mention of installing Java, don't worry. Apple provides a special OS X version of Java, which is automatically installed and updated via Software Update.
Additionally, you should set the 'CATALINA_HOME' variable, which points to the Tomcat home directory, and can be used during Tomcat configuration in lieu of a complicated directory path that might change.
To set the JAVA_HOME variable, open a new Terminal window and use the following command to open the system profile for editing. (You can substitute your favorite text editor. We like Vim.):
Once you've opened the profile, add the following lines to set the JAVA_HOME and CATALINA_HOME variables:
export JAVA_HOME=/Library/Java/Home export CATALINA_HOME=/Path/To/Tomcat/Home
(Note: If you're not familiar with Vim, here's a useful list of editing commands.)
Step 2: Download and install Tomcat binaries
Next, download the most recent stable build of Tomcat from an Apache project mirror site. If you're worried about checksum, be sure to run a checksum on the package with the 'md5' Terminal command and match it against the value provided on the Apache site.
Next, simply unzip the binaries into a simple location, such as /Library. By default, the unpacked folder name will be something like 'apache-tomcat-x-x-xx'. For ease of use, change it to 'Tomcat'.
Step 3: Start Tomcat
You should now be able to start Tomcat by navigating to the 'bin' folder and executing 'startup.sh' from the command line. After running the script, test to see if Tomcat has been successfully installed by visiting http:/localhost:8080 on your machine. If you followed the installation steps correctly, your browser should display the Tomcat Welcome Page.
Note: If you receive a permissions error, use the follow command to allow access to all of the Tomcat shell scripts:
Step 4: Automatic start on boot
You can configure Tomcat to start up automatically when your system restarts by using a custom script in conjunction with Mac OS X's launchd.
For more information about starting Tomcat automatically at login, please visit our guide to Tomcat Start.
Installing Tomcat on Linux
Installing Tomcat on your Linux machine is not all that different from the Mac OS X installation process. The primary difference between the two sets of instructions we provide here is that we cover installing Java on a Linux machine, as it is not automatically installed by the operating system.
Step 1: Download and install Java
You'll need to download the most recent Java runtimes in order to run Tomcat 6, which only supports Java 5 and later. You can either obtain them with the package manager of your choice, or download them as a self extracting binary from Sun's website.
Before you download anything, you can use the following command to find out if Java has already been installed on your system:
If you have already installed Java, this will return a list of Java packages available on your system. If no results are returned, you'll need to install Java. After you have downloaded the latest Java package from the Sun website, use the following commands to complete your installation:
These commands make the package executable, and then install the package in a directory that makes it available to all users. This requires root access - if you don't have it, you can install Java in an alternative directory of your choice.
Step 2: Download and install Tomcat
Next, download the latest stable build of Tomcat from an Apache mirror. You can either use a web browser or download the release from the command line with the following command, with appropriate values for the [placeholders]:

Verify the checksum of the package after downloading it, using the 'md5sum' command to obtain the sum and comparing it to the checksum provided on the Apache website.
Next, extract the package, and move it to the desired folder:
Step 3 - Set Environmental variables
If you haven't already, you should now set the JAVA_HOME and CATALINA_HOME environmental variables. Tomcat uses JAVA_HOME to locate your Java runtimes, and CATALINA_HOME can be used in configuration files and scripts in place of a complicated file path. Under Linux, these environmental variables are set in '.bashrc'. Open the file:
You'll need to log out of bash and log back in for your additional variables to take effect.
Step 4 - Start Tomcat
You should now be able to run the Tomcat server by executing the 'startup.sh' shell script. If you want Tomcat to run automatically at start-up, you can use a custom init script to call startup.sh. You can use this technique in conjunction with some additional configuration to run Tomcat as a system-owned process for increased security.
For more information, visit Tomcat Start, our helpful guide to automatic start.
Installing Tomcat on Windows
As noted above, the easiest way to install Tomcat on a Windows machine is by using the Windows Installer. If you will be using this method, you should not need much more help; the installer will guide you through the whole process.
Step 1: Download and install Java
Installing Java on Windows is a simple process. Like the Tomcat Installer, The Java JDK and JRE Installers for Windows are robust, and can be downloaded from the Sun website. Download and follow the Installation Wizard to install Java on your machine.
Step 2: Download and install Tomcat
If you are only planning on running Tomcat as a service, and won't need to use the start up scripts, all you'll need is the Windows Service package. Otherwise, use the standard package. You can find both on the Apache project site. The Tomcat 6 Windows Installer is solidly built, and you shouldn't have any trouble.
If you will be using this install of Tomcat only for local development, you may want to consider changing the default port during the installation process from 8080 to 80, the default web port. This will allow you to access Tomcat simply by visiting http:/localhost/, without any additional port number.
For more information about running Tomcat as a Windows Service, please visit our Tomcat Service guide.
Skip to end of metadataGo to start of metadataRunning Tomcat on Mac OS X
For an updated guide for installing Tomcat 5/6 on Mac OS X 10.6 using MacPorts check http://serverfault.com/questions/183496/full-guide-for-installing-tomcat-on-os-x
[See below for later updates to this 2004 posting]
These notes are the result of several weeks playing with different things and asking a LOT of questions on several mailing lists.
I hope these notes are of use to someone out there.
THE ENVIRONMENT
Java is installed by default on every MacOS X installation. MacOS X 10.2 (Jaguar) comes with Java 1.3; MacOS X 10.3 (Panther) comes with Java 1.4. MacOS X 10.4 (Tiger) comes with Java 1.4.2 installed, but Java 1.5 can be downloaded. MacOS X 10.5 (Leopard) comes with Java 1.5. MacOS X 10.5 (Snow Leopard) comes with Java 1.6. It is possible to run Java 1.4 on MacOS X Jaguar but it may interfere with operation of the standard environment.
JAVA_HOME
is at /Library/Java/Home
, but this is a link into a directory /System/Frameworks/JavaJVM.Framework/Versions
which is used to switch between versions easily. There is a link Current
and CurrentVersion
which matches up the current Java environment with the appropriate version.
THE SITUATION
I wanted to learn about Java Servlet Pages (JSP) on my Macintosh (with MacOS X). I installed it the first time on a Windows XP Professional system, but my development machine is a Macintosh.
Apache Tomcat Server 8 Download For Mac
THE SOLUTION
Since I had already installed and played with a separate install of Tomcat (the version installed by Apple's XCode was out of date, as was the version I downloaded from another site), I was ready to give up!
In my case I wanted to get rid of all the other Tomcat installations and start from scratch.
Step 1: Download Tomcat
Download Jakarta Tomcat from the Tomcat home page, and get the binary version - I_downloaded jakarta-tomcat-5.0.27.tar.gz.
Extract the files (unless your browser automatically extracts them).
Navigate (using the Finder) to Macintosh HD > Library.
If there is not already a folder in Macintosh HD > Library called Tomcat, then create one.
If there is already a Tomcat folder (presumably from an out-of-date installation), delete all the files already in that folder.
Step 2: Extract tomcat archive
Copy all the unstuffed files from the jakarta-tomcat-5.0.27.tar.gz download and put all the files into the Tomcat folder.
I just named it Tomcat as it saves some typing in the Terminal
So the directory structure becomes:
Macintosh HD > Library > Tomcat > <extracted files>
Step 3: Configure tomcat-users.xml
Open the /Library/Tomcat/conf/tomcat-users.xml
file with a plain text editor. The default Tomcat installation only has the basic roles and users set up.
What is configured as default is:
An example of what it should look like follows:
In this case a role, a user and password have been set up with the name tomcat. You can change this later.
Step 4: Start Tomcat
To start Tomcat, open a shell command prompt (using, for instance, the Terminal application).
The path to Tomcat via the Finder is Macintosh HD > Library > Tomcat.
But to get to that directory using the Terminal, type in:
Do an ls
- you should see a file called startup.sh
.
Any file in this directory ending in .sh
can be executed in the terminal by putting a period and a slash before the file name (eg: startup.sh
). The following example executes the tomcat startup script:
Terminal should display four lines looking something like this:
There are some notes and a couple of Preference Panes for automating the starting and stopping of Tomcat. After trying them all on five different computers - this is the simplest!
Step 5: Test installation Open a browser window, and enter http://127.0.0.1:8080 - the default Tomcat page should open.
If you click the Tomcat Administrator or Tomcat Manager links in the upper left hand of the default Tomcat page, you will be asked for a user name and password.
As mentioned above, use tomcat for the user name, and tomcat for the password.
By : Brynley Blake (31 August 2004)
With considerable help from Joachim, Tracy, Tom, Samuel and Jonel from the Apple Web and Java Developer mailing lists.
Updated for 2006
Basil Bourque says:
Today (2006-04-05) I disovered a somewhat different recipe to running Tomcat 5.5.16 on Mac OS X 10.4.6.
- Today's Tomcat (v5.5) wants to run on Java 5, but Apple's command line defaults to Java 4 (1.4.2). Surprisingly, Tomcat's script works around this.
- I did not need to set any environment variables (JAVA_HOME).
- But I did need to fix vital file permissions in the downloaded Tomcat folder.
Also Updated in 2010
By Pid: I removed some of the original statements about setting JAVA_HOME as they did not match my experience of installing Tomcat on OS X. It's also certainly overkill to install an application just to be able to set an environment variable.
(1) Upgrade to Mac OS X 10.4.6
- I do not know if 10.4.6 is required, but it sure made an easy Tomcat install.
- Apply all of Apple's Software Updates, especially the Java 5 update.
(2) Download apache-tomcat-5.5.16
- Unzip.

- Move it to your home folder.
(3) Fix the Unix file permissions
- Download the freeware BatChmod, a GUI wrapper around the Unix 'chmod' command.
- Drag and drop the entire Tomcat folder onto the BatChmod icon.
- Check *all* the checkboxes.
- Click 'Apply' and give your Administrator password.
(4) Start Tomcat
- Launch /Applications/Utilities/Terminal.
- Navigate to the Tomcat folder (apache-tomcat-5.5.16):
- Run the startup script:
- You should see something like this:
- Notice that somehow the startup script(s) have used Java 5 on Mac OS X even though it is not the default Java runtime at the command line. I hope to parse that script later to discover how they did this.
(5) Test Tomcat
- Launch a web browser such as Safari.
- Goto http://127.0.0.1:8080/
- You should see the cute Tomcat logo on the welcome page.
You are technically done at this point. But as a good pratice, I also did the following additional steps.
(6) Start the Firewall
- System Preferences > Sharing > Firewall > Start
- Also, click the Advanced button on that panel, to (a) block UDP, and (b) start logging. It is fascinating to see how quickly a computer directly on the Internet starts to get queried/tested/attacked. Open /Applications/Utilities/Console to see the log.
(7) Enable Port-Forwarding
- Add a rule to do port-forwarding from port 80 to Tomcat's default port 8080. Type this in the Terminal:Or use this nifty program, another GUI wrapper around the ipfw command line, Simple Port Forwarder:http://www.4dresources.com/files/
The Sharing SysPref will get cranky when you add an ipfw rule behind its back; it disables its user interface. To use the Sharing SysPref again you'll have to clear that rule, the one we added and numbered 100. To delete a rule, either read the ipfw man page, or use Simple Port Forwarder again. Quit the System Preferences program, and re-launch it to re-enable its Firewall panel.
(8) Test Tomcat
- Launch a web browser such as Safari.
- Goto:http://127.0.0.1/
Notice that we left off the port number this time, so the web browser defaults to port 80. Or you can explicitly say port 80:http://127.0.0.1:80/
- You should see the cute Tomcat logo on the welcome page.
- To be sure it is working, and not cached by the browser:
• Try another browser.
• Click the Reload button in the toolbar of the browser.
• Choose the Reload command, such as View > Reload Page in Safari.
Tomcat Server Download For Mac Pro
(9) Walk the dog
- Enjoy an all-too-rare moment of computing satisfaction.
As best as I can recall, that is all I had to do today. I hope I am not steering you wrong. I did assume at first that Java 5 would not be used be default, so I wasted time messing with the path ($PATH) and setting the environment variable JAVA_HOME. But I undid those, as they failed. I then tried the simple steps above, and it worked.
I hope to refresh my own web site with this info:http://www.BasilBourque.org/
Tip: You can drag and drop from the Finder to the Terminal, to avoid typing file and folder names.
--Basil Bourque
Updated for 2008
Michael Valentiner says:
Today (2008-02-03) I verified running Tomcat 6.0.14 on Mac OS X 10.5.1.
Like Basil, I did not need to set up JAVA_HOME and I did need to fix Unix file permissions.
Unlike Basil, the System Preferences > Sharing > Firewall has moved to System Preferences > Security > Firewall. I was able to enable logging, but haven't figured out how to block UDP.
Updated for 2009
Chris Latko says:
To have Tomcat 6.0.x launch on boot on Mac OS X 10.5.x, you need to add a LaunchDaemon. Create a file called org.apache.tomcat.plist in /Library/LaunchDaemons/ with the following content:
Updated for 2009
Greg Woolsey says:
For Tomcat 5.5.x (and probably 6.0, as the scripts don't appear to have changed much) you need a slightly modified plist, that calls catalina.sh in a manner compatible with the requirements of launchd: http://developer.apple.com/MacOsX/launchd.html. Specifically, the script must be run with the 'run' parameter instead of 'start', as start backgrounds the Java process and exits the script. This causes launchd to think the service is done, and kills the java process as part of it's cleanup.
Tomcat Server Download For Mac
My plist assumes Tomcat is installed in /Library/Tomcat/tomcat-version, with a symbolic link called 'Home' pointing to the version to use.
Tomcat Server Download For Mac Download
Save this file as /Library/LaunchDaemons/org.apache.tomcat.plist:
If you have a web app that doesn't want to shut down nicely (my company's product is one), then to avoid the need to force quit Tomcat just to turn off your Mac, use a startup script instead of a daemon plist.
Add this line to /etc/hostconfig as root:
TOMCAT=YES
Then, as root, create /Library/StartupItems/Tomcat, writable only by the owner (root).
Inside this, create two files - Tomcat (script) and StartupParameters.plist. Again, make them writable only by root, and the script executable by everyone.
Contents of StartupParameters.plist:
Contents of the Tomcat script file: