
Hi Guys,
Now when we are familiar with PHP, its time to move ahead and install the application. In this post we will focus on installation of PHP and APACHE on MAC and in next few posts we will learn More about APACHE and MYSQL installation .
MAC OS X is a great platform for working with PHP. Leopard comes with Apache, PHP and many other development tools,such as subversion already installed. This is a guide for setting up a PHP development envoirnment under 10.5 using the version of PHP that ships with leopard.
You may refer to use one of the 3rd party distributions of PHP, such as MAMP, XAMPP or Marc Liyanage. This is a guide to using the version of PHP that comes with 10.5.
Enable Developer Tools
These steps may not be strictly necessary for this process, but I find it useful to do them.
First, enable your root password.
You may also want to install XCode Tools from your Leopard disk(or grab the latest from Apple developer tools). The tools are required as you are going to compile any extension for PHP.
Editing Configuration Files
We will haeve to edit several configuration file that exists as a part of the unixy underpinnings of OS X. I am going to recommend the free text editor, TextWrangler for this purpose. Normally. the finder hides the configuration files from view. However, in the finder, you can use the "Goto Folder .." option under the "Go" ( Go>Goto Folder) . This option if available via command-shift-G. Actually, this option is available in any file open in dialog in OS X via command-shift-G. In addition, TextWrangler will allow you to browse these files with its "open hidden.." option. But, much easier option is selecting "open file by name.." (command-D) and just typing the full path and filename. To save many of these files, you need to enter your root password. Be careful.
Enabling PHP
PHP is installed in Mac OS X by default, but not enabled. To enable it, we must edit the apache 2 configuration file, which is located at /etc/apache2/httpd.conf. Find the line which loads PHP 5 module, which looks like this :
# LoadModule php5_module libexec/apache2/libphp5.so
The line is currently commented out. All we have to do is remove the comment symbol, #, so the line looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
Save.
Starting Apache
Go to the sharing panel in system preferences and enable " Web Sharing". This will start the apache server.

Another way to do this is to type the following in the terminal application:
sudo apachectl start
You will be prompted to enter your root password. After that, your apache server should now be running. If you need to restart the server from the terminal, you can type this:
sudo apachectl restart
If you find this tedious to type, there is a script that can download to do this later in this post.
Visiting our Web Site
In Web browser, go to url http://localhost/ . localhost is a special name that means " My comuter". If your web server is working , you should see a page titled "Test Page for Apache Installation:. If you go to http://localhost/manual/ , you can read an Apache 2.2 manual, hosted from your own server. But, this don't tell you that PHP is working. For that, we will write simple php program. Create a new file in textWrangler and type the following:
< ? php phpinfo(); ?>
(Don't copy and paste this. There is no space between < ? . It's because of WordPress software.)
Save this using file name info.php in the /Library/WebServer/Documents/ directory. Now you should be able to visit the PHP page that you have just created by visiting http://localhost/info.php . You should see the PHP logo and a big table of configuration info.
In next post we will discuss following topics :
- Data Security
- Enabling a personal Website
- Virtual Hosting
- MYSQL Installation

No comments:
Post a Comment