How to start XAMPP in Terminal Mac OSX

In the latest version of XAMPP, they removed the GUI to start stop Apache as well as other services (MYSQL,FTP etc). You have to use command line on terminal to start stop Apache Server. Documentation can be found on XAMPP site it self, However they do not show the exact command to stop stop. Here is quick tutorial how to start stop XAMPP

  1. Start Terminal. Issue this command to go where XAMPP is installed
    cd /Applications/XAMPP/xamppfiles
  2. Issue the following command.  You have to use SUDO because this command needs root level privilege. Note that ./ is important. It indicates xampp is in the current folder
    SUDO ./xampp start

Or you can do it in one step by issuing the following command

 SUDO /Applications/XAMPP/xamppfiles/xampp start

Fixing Security Issues (login)

When you access localhost it might prompt you for user name and and password. The default username is “xampp”, the password is the one that you already set. If you have issue accessing the site, you simply need to reset username and password. Run the following command to do that. This will fix issues with the login

SUDO /Applications/XAMPP/xamppfiles/xampp security

Start XAMPP using GUI

Click here to Start XAMPP using GUI on Mac

Using Path

In the comments of “How to start XAMPP in Terminal Mac OSX”, there were suggestions about using alias for the command. The problem with alias is they are temporary and are lost as soon as you close the Terminal Window. You have to recreated them each time you open the terminal.

A better approach is to add xampp to system path so you do not have to type complete path each time you run this command. You can follow this easy tutorial how to modify path variable on mac. In short, issue this command

sudo nano /etc/paths

1. Enter your user name and password (it will prompt for it)
2. Edit the file, add the path, /Applications/XAMPP/xamppfiles, at the bottom of the file in a new line
3. Hit Command + O to write the file
4. Close the terminal completely and re-open it again.

Now you can use use xamppt start command directly in the terminal

This entry was posted in Tutorials/Tips and tagged , , . Bookmark the permalink.

12 Responses to How to start XAMPP in Terminal Mac OSX

  1. Thanks!

    You can even use:
    xampp startapache,
    xampp startmysql or
    xampp startftp.

    I use it to start as a shell script on boot, from Applescript/Automator.

  2. Davie says:

    Or an easier solution:
    cp /Applications/XAMPP/xamppfiles/xampp /usr/bin
    alias xampp=’sudo xampp’

    Now you can launch just xampp from command line:
    xampp
    xampp start
    xampp stop
    xampp restart
    etc.

  3. Davie says:

    Found a new way for Mac OS X El Capitan:
    insert this to .bash_profile or .zshrc, depends what shell you’re using:

    alias xampp=’sudo /Applications/XAMPP/xamppfiles/xampp start’

    Next time just type xampp to terminal and you’re good to go

  4. Mr Alexander says:

    Thanks for the tip, it worked. I saw references to aliases in the comments, would be nice if you could cover it as well 🙂

    • admin says:

      A Alias is a shortcut to a long command that you can type easily. Using alias is not a good approach here because they are temporary. Once you close your terminal window, all your aliases are lost. There is a way to make permanent aliases, you may follow this link for that

      • Edem says:

        …unless you save them in your ~/.profile; or better yet, in your ~/.aliases file and add
        if [ -f ${HOME}/.aliases ]; then
        . ${HOME}/.aliases
        fi

        to your ~/.profile

  5. arun says:

    Thanks. worked….

  6. Anand says:

    Hi,

    I did exactly mentioned in above steps. Then I checked and verified that echo $PATH showing my newly added path. Also had closed all terminal window and opened fresh terminal window. Still my command not working.
    I have added “/Applications/XAMPP/xamppfiles/xampp” at the last.

    Now when trying to access xampp directly from terminal its not working showing “-bash: xampp: command not found”.

    Please help me.

    • admin says:

      Hello Anand, Thanks for point that out. I have fixed that. In path use the following text

      /Applications/XAMPP/xamppfiles (leave xampp out)

      Now close terminal and re-open it. The command can now be executed.

  7. rod says:

    can’t get past the password request. doing my head in!!

  8. Saeed says:

    I used the (above) command to start XAMPP. Although MySQL started correctly, Apache server failed with this error:
    “Another web server is already running”

Leave a reply to arun Cancel reply