solutions to (auto-)start of mampp

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

solutions to (auto-)start of mampp

Postby bjeanes » 17. November 2005 13:20

in searching for an answer to another problem (see post below) i came across a few useful applescripts to be used for automatically starting and stopping, restarting etc the server. i can't remember which posts they were but i had copied the applescript so i will repost them all together here as a good resource. feel free to give the original locations if u know them, so the author can have credit. i plan to make a few modifications and enhance it a bit to include stopping/starting individual elements.

once compiling these scripts i suggest saving it as an application bundle that you can simply double-click or make into a startup item so that your server starts automatically when you log-in.

i am playing around with some cocoa ideas to make a preference pane and/or standalone application for controlling elements of mampp individually since this will be a much better solution. in the meantime:

to start/restart/stop mampp and all components (also checks to make sure MacOsX server is not activated to avoid conflicts):

Code: Select all
set Check to 0
try
   set s to do shell script "ps -ax | grep /usr/sbin/httpd|grep -v grep"
on error errMsg number errNum
   set Check to 1
end try
if Check is 0 then
   display dialog "Apple's Apache is running! Please turn it off in the System Preferences first then rerun this script."
   return
end if
try
   set httpdstatus to do shell script "ps -ax | grep /Applications/xampp/xamppfiles/bin/httpd|grep -v grep"
   set dialogReply to display dialog ¬
      "XAMPP's Apache is running — Do you want to Stop or Restart XAMPP?" buttons {"Stop", "Restart", "Cancel"} default button 1
   if button returned of dialogReply is "Cancel" then
      return
   end if
on error
   set status to "XAMPP does not seem to be running"
   set dialogReply to display dialog ¬
      "XAMPP's Apache is not running— Do you want to start XAMPP?" buttons {"Start", "Cancel"} default button 1
   if button returned of dialogReply is "Cancel" then
      return
   else
      display dialog ¬
         "This may take up to half a minute. " & ¬
         "Do not Force Quit unless it has been more than a minute" giving up after 5
   end if
end try
if button returned of dialogReply is "Stop" then
   do shell script ¬
      " /Applications/xampp/xamppfiles/mampp stop" with administrator privileges -- stop xampp
else
   if button returned of dialogReply is "Restart" then
      do shell script ¬
         " /Applications/xampp/xamppfiles/mampp restart" with administrator privileges -- restart xampp
      
   else
      if button returned of dialogReply is "Start" then
         do shell script ¬
            " /Applications/xampp/xamppfiles/mampp start" with administrator privileges -- start xampp
      end if
   end if
end if
activate
display dialog "Finished Action!" giving up after 5


to switch the version of php from 4 to 5 or back:

Code: Select all
set dialogReply to display dialog " Choose which PHP version you want XAMPP to use" buttons {"PHP5", "PHP4", "Cancel"} default button 1
try
   if button returned of dialogReply is "PHP5" then
      do shell script "/Applications/xampp/xamppfiles/mampp php5" with administrator privileges -- stop xampp
   else
      if button returned of dialogReply is "PHP4" then
         do shell script " /Applications/xampp/xamppfiles/mampp php4" with administrator privileges -- restart xampp
      end if
   end if
on error errMsg number errNum from errFrom partial result errResult to errTo
   display dialog errMsg
end try
activate
display dialog " The PHP Switch is complete!" giving up after 5


will post more scripts or modifications of scripts if i find more or make/modify some additional code.

cheers,
Bo
bjeanes
 
Posts: 12
Joined: 17. November 2005 12:47
Location: Brisbane, Australia

Program for controlling XAMPP

Postby bjeanes » 19. November 2005 18:42

so i have spent the last few days starting to build up a program to administrate the XAMPP for Mac OS X package. here are some screenshots:

Image

In the above image you can see where you can stop/start individual components or xampp as a whole (just as you can use the shell commands)
and the output from these commands is displayed in the Output box so you can see any errors, etc. eventually i'll make the program have a better way of dealing with errors.

in the following picture, you can see the beginning of PHP customization and a simple about box:

Image

for now it just has the option to change the active PHP version from 4 to 5 or vise versa (current version is displayed above button). later on, however, you will be able to set many PHP options through a few different panels. this will be done by modifying the php.ini file then restarting the server once the program has finished the modifications. and yes it will back up your php.ini and will have the option to restore a backup.

anyway this is my first mac program i've ever written, though its not such a fantastic feat since it's all applescript based. however this is the first ever thing i've written in applescript including basic scripts.

i taught myself how to use xcode and A.S Studio in these past 3 days just for this project. any recommendations, suggestions, additions, criticisms, etc, that you have please post them. i'd love for this program to become quite solid since so many people find the lack of a GUI for mac's xampp a great sore spot.

if anyone wants to see the source code or nib files to improve them or wants to make me a nicer logo (current one does have transparency and stuff so it doesnt look too bad), just let me know. it's a bit tmuch to post considering the length of everything else already.

--bo
bjeanes
 
Posts: 12
Joined: 17. November 2005 12:47
Location: Brisbane, Australia

Postby Kristian Marcroft » 22. November 2005 21:31

Hi,

this is very interesting.
We have also tried excly what you have achieved.
IF you could provide us the ControlPanel incl. Source and if it is Open Source, we could think about including it into the next version of XAMPP for MacOS X.

Please contact me at kris@apachefriends.org

Thank you
Kristian
User avatar
Kristian Marcroft
AF Moderator
 
Posts: 2962
Joined: 03. January 2003 12:08
Location: Diedorf

XAMPP Control Panel

Postby bjeanes » 23. November 2005 07:57

OK i have sent an email with some info but i figured i'd write here also in case anyone else wants an update *shrug*

i expect to add some of the following features:

    - the ability to run the security script
      - and if i have time to analyze the current one have the ability to re-run and re-administer certain security features (i.e. creating a new mysql password)
    - the ability to edit the php.ini, my.conf, proftp.conf, and httpd.conf files. i have not decided whether that will be through fields and checkboxes and such or by directly editing the text file. the former of course would be easier and will probably be implemented at first anyway)

    - there will be buttons to open the htdocs folder in your Finder window - either directly or as an FTP server (however i have noticed that even with the correct username and password, the Finder will not give write privileges to ftp://localhost)

i expect to think of more things to add. any other suggestions are welcome and if u'd like a look at the surprisingly simple code (its all applescript based), i will provide it once the package is in a semi-stable state.

currently i only expect it to work with the current version of xampp as a lot of the relies on analyzing output strings, which might of course be different in newer versions of xampp.

if anyone sees a better way to do anything i have done once they see the source code, please tell me and i'll make it better. i don't claim to be a fantastic programmer, especially since this is my first experience with xcode, as well as my first contact with applescript and programming for the mac in general.

the project WILL be open source and will be given to apachefriends.org once i am satisfied with my results. ok enough talking by me

bye
bjeanes
 
Posts: 12
Joined: 17. November 2005 12:47
Location: Brisbane, Australia

can you post to the wild?

Postby mjhamson » 23. November 2005 17:44

bjeanes,

Are you willing to send out your source to the wild? I would really love to play with it (err.. use it).

by the way, since I use XAMPP strictly as a local dev environment, I created a simple applescript that passes my user/password info to the shell using the 'do shell' to execute the start of the environment. I compile the source of course to give it a little bit of security (not much I know)... but I am not too worried about the security on this machine. The script gets attached to my login items.

down and dirty I guess.

-Michael

ps. I had built a control panel app back during version 0.3, but nuked the code. never had the chance to redo it. (very simple process).
mjhamson
 
Posts: 1
Joined: 16. July 2005 11:46

Postby bjeanes » 23. November 2005 23:33

mjhamson,
yes of course i will "send the source to the wild" ... but as i said above i am not at the machine i created it on right now, and also i'd prefer to just tie up the last few things i've started on it. and yes since i have never written a mac program and (although i know some c) am not any good with objective c, i wrote the program in applescript. what i mean by this is, it's all based off the do shell script command. however, for the security script feature i want to add, since applescript can not dynamically interact with the shell, i might re-write those scripts to be able to take in all the necessary usernames/password etc from the command line ... if i find time.

as soon as i find the time (hopefully this weekend) to tie up all the loose strings in teh program i will upload it (including source) to my website and post the link here so people can have a look at it. i only have a few conditions, which are mostly the standard: always keep my name in the source and the about box in the program as the original author, and any modifications you make, send back to me. the latter condition is mostly so for my learning experience, just so i can see how i could have done things better etc., but also so i can pull together lots of peoples different ideas and repost the combined code

last note: this program is ONLY designed to control a setup for a local dev environment, i don't even begin to assume that it is secure or could hold up to anything but a dev environment. i designed it for my own ease, and thats what i use XAMPP for.

will keep updating. watch this post and wait for a link. if at any point i decide to ditch the project or i am stumped at some point i will post the messy code and let you guys get in at it. till later

bo
bjeanes
 
Posts: 12
Joined: 17. November 2005 12:47
Location: Brisbane, Australia

that's great!

Postby fuocorav » 02. December 2005 03:44

that's great what you're doing!
fuocorav
 
Posts: 8
Joined: 28. November 2005 22:38

Postby bjeanes » 02. December 2005 14:02

hey fuocorav, thanks.
yes it is a great thing i am doing ... or should i say will be doing. as many people who code opensource material discover, and this will be opensource, its hard to find the time to sit down and dedicate it to finding a way to do what you want to do in a program.

i am too lazy to read my post, but i may have mentioned that i am the producer and layout guy for a local magazine and am currently spitting out the latest issue which pretty much occupies me 12-hours a day for the next week and a half (about 60 pages!!!). this is mostly because it's a small office (3 people really) so i also design ads, and contact people, and manage emails and incoming ads, as well as editing. anyway that's not important nor is it my point. i know this mac os control panel is certainly a welcome project for the XAMPP community, but it will be a slow process with all this stuff going on. as i said before, once i work out a system for doing so, i would love to have others contribute to the project as my only interest for it is to have it work fantastically for everyone with everyones features included.

i will think about finding a few seconds to post what i have of the app up on my website soon. just so people can activate xampp and switch php versions until the other features are added. more later

bo
bjeanes
 
Posts: 12
Joined: 17. November 2005 12:47
Location: Brisbane, Australia

Postby Fireant » 02. December 2005 15:06

I found a tutorial on making a MacOs X startup item and have successfully made one for Xampp. It will work for any Mac as long as Xampp is in the user's Applications folder.

http://home.austin.rr.com/dmcknight/xampp.zip

bjeanes, thanks for all your work! I'm inspired to finally give xcode/A.S. a try!
Fireant
 
Posts: 5
Joined: 28. November 2005 19:18

Postby macsel » 17. February 2006 11:57

@Fireant: can you describe how to use the downloaded files? I'm really a n00b.

@bjeanes: keep up the good work! Looks amazing!
macsel
 
Posts: 2
Joined: 17. February 2006 11:52

Postby Fireant » 20. February 2006 03:08

Hi macsel, here are the instructions for installing the startup item:

1.) for this to work, you MUST have XAMPP installed in its default location (the main Applications folder). If you have it installed elsewhere, the startup command will not find it.

2.) First download and unzip the file: http://home.austin.rr.com/dmcknight/xampp.zip . This will create a folder called 'xampp'.

3.) You need to place that folder into your main startup items folder ("Macintosh HD/Library/StartupItems/"). This folder is owned by 'system' so you wont have write access to it:
    a.) Select the StartupItems folder and "Get Info" (apple-i)
    b.) Under Ownership & Permissions Details, change its owner from "system" to your username...you'll need the root password to do it.
    c.) place the 'xampp' folder into the 'StartUpItems' folder
    d.) change the ownership back to 'system', and click the lock to prevent future changes.


4.) You're done! Whenever you restart, XAMPP will automatically start up every time. This startup item is one of the very last things to take place during system startup, so you will want to wait until the system is completely done with startup before jumping into XAMPP from your browser.

Hope that helps, and good luck :)
Fireant
 
Posts: 5
Joined: 28. November 2005 19:18

Postby macsel » 20. February 2006 12:19

THX, I'll going to try to install it correctly tomorrow
macsel
 
Posts: 2
Joined: 17. February 2006 11:52

Postby Fireant » 03. March 2006 17:50

Just an update, there's a nice application out that can be used to launch Command Line apps here:

http://applaunch.sourceforge.net/
Fireant
 
Posts: 5
Joined: 28. November 2005 19:18

Postby pref-at-laval » 08. April 2006 13:13

I used a root crontab to start Xampp:

crontab -u root -e
@reboot /Applications/xampp/xamppfiles/mampp start

Can anyone see a flaw in this way of doing it?
Pref-at-Laval
pref-at-laval
 
Posts: 3
Joined: 06. April 2006 15:22
Location: Laval, Canada

hey all

Postby bjeanes » 12. May 2006 05:27

hello everybody.

I feel pretty terrible that i still haven't worked on this project at all. But its a bit hard when i do not even own a mac!!! i am currently aiming to have one by June. if that happens, i will continue this development project (i just put in an application for a sourceforge project) and put out a basic version by the end of june/early july. of course this depends solely on if i can actually get a mac. Also, i started this project before intel macs were around, so hopefully it'll be as simple as pie to make this a universal app as well.

I have been talking with a fellow in canada who is interested in helping me with it, so if i can get my hands on my original source code (which is currently in another state on a computer belonging to someone else, who is currently in japan) i will email it to him and maybe he can compile a stable version and put it up on the site for people to start using.

I also talked months ago about letting apachefriends include it in their macosx release of xampp. if this project gets back on track, that is still definitely my preference. Expect another post in a month or so about whether or not i can get a mac :-)

Bo
bjeanes
 
Posts: 12
Joined: 17. November 2005 12:47
Location: Brisbane, Australia

Next

Return to XAMPP for macOS

Who is online

Users browsing this forum: No registered users and 21 guests