php hello world on OSX

By | July 10, 2017

Getting a php hello world up and running is very quick in OSX. First of all, everything is there already. Apache and php.

To start apache run:

> sudo su

> apachectl start

Then go to http://localhost and you should see:

The web directory is /Library/WebServer/Documents

If you put hello.php there

<title>PHP Test</title>
<?php echo “<p>Hello World</p>” ?>

You’ll get this:

To get rid of the extra characters, open httpd.conf in /etc/apache2 directory, find the line LoadModule php5_module libexec/apache2/ and uncomment it. (ie remove the # symbol)

Then run:

> apachectl restart

You should now be good to go. If you want MySQL, read here.


Leave a Reply

Your email address will not be published. Required fields are marked *