Log In · Register

 
Xamp/wamp alt. for mac?
Maccabee
post Aug 14 2009, 01:53 AM
Post #1


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



I have a mac now and im looking for something that will allow me to test website that use php includes without outting them ive on my server. Whats a free program that can do this? Is there something at http://www.apple.com/downloads/? And I dont get that site. How can I just view all the free downloads? hehe. thanks.

Edit:
I just saw that php and apache are actually pre installed on the mac. Who knows how to enable it? I was hoping there was a way to do it, not in the terminal but it looks like their isnt.
 
 
Start new topic
Replies (1 - 22)
mipadi
post Aug 14 2009, 07:21 AM
Post #2


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



Macs already have Apache and PHP. Just go to System Preferences > Sharing > Web Sharing (and check the Web Sharing checkbox). Here's a page detailing how to get MySQL installed.

Or alternatively you can use MacPorts to download, install, and update to the latest versions. (That's what I use.)
 
Maccabee
post Aug 14 2009, 11:06 AM
Post #3


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



I take it macports is more for programming? I couldnt really figure out what it even was by reading the site.

But dang! That was easy. And I love how there is a sites folder. If I had known about this on macs I would have bought one ages ago!
 
mipadi
post Aug 14 2009, 11:16 AM
Post #4


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



QUOTE(jcp @ Aug 14 2009, 12:06 PM) *
I take it macports is more for programming? I couldnt really figure out what it even was by reading the site.


It's a package manager (similar to BSD Ports or Gentoo Portage, and similar in spirit to apt-get on Debian Linux).

QUOTE(jcp @ Aug 14 2009, 12:06 PM) *
But dang! That was easy. And I love how there is a sites folder. If I had known about this on macs I would have bought one ages ago!


Yes. It is.
 
Maccabee
post Aug 14 2009, 11:26 AM
Post #5


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



So, where exactly do I put the sites contents? I put a whole site that uses php into the sites folder but then when I go http://555.555.5.55/~joseph/ or http://555.555.5.55/ it doesnt actually change anything.

That isnt the actual number but I wasnt sure if it was something I needed to keep private. haha.
 
mipadi
post Aug 14 2009, 12:04 PM
Post #6


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



QUOTE(jcp @ Aug 14 2009, 12:26 PM) *
That isnt the actual number but I wasnt sure if it was something I needed to keep private. haha.

You want to got to http://localhost/~joseph (assuming "joseph" is your username). Or http://127.0.0.1/~joseph.
 
Maccabee
post Aug 14 2009, 12:09 PM
Post #7


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



Php files arent working. All its doing is showing the text in the file. Why is it doing this? Don't macs come preinstalled with php? there is an index.php in the sites folder but it is just showing the directory files.
 
mipadi
post Aug 14 2009, 12:14 PM
Post #8


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



Oh, sorry. Forgot that PHP isn't enabled by default in Leopard. First, disable web sharing. Then you need to edit the file /etc/apache2/httpd.conf. Open that file, find the line #LoadModule php5_module libexec/apache2/libphp5.so, and uncomment it (remove the # mark). Then restart web sharing (to restart Apache). Should work after that.
 
Maccabee
post Aug 14 2009, 12:20 PM
Post #9


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



ok. I was hoping there was a way to do it that didnt involve getting into those files but watevs. haha.

How exactly do I get there? I looked for a etc folder in the macintosh hd and I looked in library and system.

?
 
mipadi
post Aug 14 2009, 12:24 PM
Post #10


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



QUOTE(jcp @ Aug 14 2009, 01:20 PM) *
How exactly do I get there? I looked for a etc folder in the macintosh hd and I looked in library and system.

?

It's hidden. You can get to it in 2 ways:
  1. Fire up a Terminal and cd into it using cd /etc/apache2.
  2. In the Finder, go to Go > Go to Folder..., and type /etc/apache2 into the dialog box.
 
Maccabee
post Aug 14 2009, 12:41 PM
Post #11


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



I took away the # and hit command+s and it asked for the password so I entered it but when I went back to web sharing to turn web sharing back on, it was un clickable. Only bluetooth is clickable now.

nvm, I ha to unlock the settings.

Its working! Thanks :) Please dont close this yet though.
 
Maccabee
post Aug 14 2009, 04:28 PM
Post #12


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



Do you know how I could make a "sub domain" for localhost? Often my sites need to be tested in the base directory and I dont want to have to remove one site to test out another one. Something like http://test.localhost/~joseph/
 
heyo-captain-jac...
post Aug 14 2009, 06:04 PM
Post #13


/人◕‿‿◕人\
*******

Group: Official Member
Posts: 8,283
Joined: Dec 2007
Member No: 602,927



why not just http://localhost/~joseph/test ?
 
mipadi
post Aug 15 2009, 11:01 AM
Post #14


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



QUOTE(jcp @ Aug 14 2009, 05:28 PM) *
Do you know how I could make a "sub domain" for localhost? Often my sites need to be tested in the base directory and I dont want to have to remove one site to test out another one. Something like http://test.localhost/~joseph/

Read this. Although I'm inclined to say just use http://localhost/~joseph/test, etc.
 
Maccabee
post Aug 15 2009, 11:06 AM
Post #15


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



QUOTE(Buttsex @ Aug 14 2009, 06:04 PM) *

Because then the pointing of everything works differently.
 
mipadi
post Aug 15 2009, 11:13 AM
Post #16


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



QUOTE(jcp @ Aug 15 2009, 12:06 PM) *
Because then the pointing of everything works differently.

If you're using absolute paths, then they're not going to work anyway since you're serving under ~joseph.
 
Maccabee
post Aug 15 2009, 11:17 AM
Post #17


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



I mean when im working on a large site I dont want to have to go through every page and change <?php include("/includes/header.php") ?> to <?php include("../includes/header.php") ?> or whatever the case is. Unless I can find a script that goes through all the pages and replaces one thing with another.
 
mipadi
post Aug 15 2009, 11:22 AM
Post #18


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



QUOTE(jcp @ Aug 15 2009, 12:17 PM) *
I mean when im working on a large site I dont want to have to go through every page and change <?php include("/includes/header.php") ?> to <?php include("../includes/header.php") ?> or whatever the case is.


Right, I know... But if you're serving under localhost/~joseph, /includes/... isn't going to work anyway, it'd have to change to /~joseph/includes.

QUOTE(jcp @ Aug 15 2009, 12:17 PM) *
Unless I can find a script that goes through all the pages and replaces one thing with another.

You can. It's called "awk" or "sed", and it comes with your Mac.
 
Maccabee
post Aug 15 2009, 11:26 AM
Post #19


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



QUOTE(mipadi @ Aug 15 2009, 11:22 AM) *
Right, I know... But if you're serving under localhost/~joseph, /includes/... isn't going to work anyway, it'd have to change to /~joseph/includes.
You can. It's called "awk" or "sed", and it comes with your Mac.

Are you for freaking serious? They have all these hidden features!
 
heyo-captain-jac...
post Aug 15 2009, 11:30 AM
Post #20


/人◕‿‿◕人\
*******

Group: Official Member
Posts: 8,283
Joined: Dec 2007
Member No: 602,927



They're not hidden.
 
mipadi
post Aug 15 2009, 11:48 AM
Post #21


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



QUOTE(jcp @ Aug 15 2009, 12:26 PM) *
Are you for freaking serious? They have all these hidden features!

awk and sed are standard utilities on Unix, and Mac OS X is a Unix, so they're not really "hidden" per se.
 
Maccabee
post Aug 15 2009, 11:50 AM
Post #22


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



Well I didnt know about them. haha. How do I use them? I cant find them in spotlight.
 
mipadi
post Aug 15 2009, 11:58 AM
Post #23


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



They're command-line programs -- you call them from the Terminal.

Here's a quick bash script to do what you want:

CODE
#!/bin/bash

for f in ~/Sites/**/*.php; do
  sed 's_/includes_../includes_' < $f > "${f}.new"
  mv "${f}.new" $f
done


Or Ruby, if you prefer:

CODE
#!/usr/bin/env ruby

def fix(file)
    tmp = File.open "#{file}.tmp", 'w'
    File.open(file).each do |line|
        s = line.gsub %r{/includes}, '../includes'
        tmp.puts s
    end
    tmp.close
    File.rename tmp.path, file
end

def getfiles(path)
    Dir.foreach(path) do |f|
        if File.directory? f
            getfiles f unless f =~ /^\.\.?/
        else
            fix "#{path}/#{f}" if f =~ /\.php$/
        end
    end
end

if __FILE__ == $PROGRAM_NAME
    getfiles File.expand_path '~/Sites'
end
 

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: