Sunday, March 11, 2012

PHP Apache on MacOs (Basic)

MacOs comes with installed but not configured Apache and PHP.
Open a terminal ...
$) php -v              [should tell the version of php]
$) apachectl -v     [should tell the version of apache]
Make sure that your webserver Apache is enabled (not necessarily started) and that the document root is properly setup as well.

Open a browser and navigate to http://localhost OR http://localhost/~username. In my case the ~username will be ~aniket, as mentioned in the image above. Make sure that you see the famous 'It Works !' message. This means apache is up and running on it's default port 80.

Uncomment the line
$) vi /etc/apache2/httpd.conf as root user.

#LoadModule php5_module libexec/apache2/

$) apachectl stop
$) apachectl start
For testing whether php is setup and works create the following file and insert a line ...
$) vi /Library/WebServer/Documents/phpinfo.php  [Or the specific user document root folder corresponding to ~username link above]

<php phpinfo(); >
Save the file and in the browser open the link http://localhost/ to get a full listing of PHP parameters. Apache and PHP are now setup together to gel well. Create the web folder structure under document root to build a website.

No comments :

Powered by Blogger.