Installing PHP

About PHP

PHP is a programming language for building dynamic, interactive Web sites. As a general rule, PHP programs run on a Web server, and serve web pages to visitors on request. One of the key features of PHP is that you can embed PHP code within HTML Web pages, making it very easy for you to create dynamic content quickly.

PHP stands for Hypertext Preprocessor, which means gives you a good idea of its core purpose: to process information and produce hypertext (HTML) as a result.(Developers love recursive acronyms, and PHP . Hypertext Processor is a good example of one.)

Installing PHP

To create and run PHP scripts, you need to have a few things in place:

  • A computer running web server software, such as Apache or Internet Information Server(IIS).
  • The PHP server module installed on the same computer. This module talks to the Web server software; this is the PHP engine that actually does the work of turning your PHP scripts.
  • If you want to build data base driven web-applications-and you probably will – you’ll also need a database server installed. Options include MySQL, PostgreSQL, and SQL server.  This book mostly refers to using MySQL, so that is the database server that you will install here.

Many combinations of operating system and web server software (not to mention versions of PHP) are available.  For example, operating systems that can run PHP include Linux, windows and Mac OS X, and web server software includes Apache, IIS, and Zeus.

Installing PHP on Ubuntu linux :

Linux is a popular choice among PHP web developers, because both technologies are open source.  Furthermore, PHP tends to work well with Linux, Apache, and MySQL database server, In fact, the acronym LAMP (Linux, Apache, My SQL and PHP) is often used to refer to this warning software.

Ubuntu is a popular linux distribution that is easy to install.  You can download it from www.ubuntu.com/getubuntu/download; the desktop edition is fine for developing back PHP applications.  It comes in the form of a CD image, so you can just burn a CD from it, then pop your CD in your computer’s drive and reboot to install it.

The Ubuntu desktop edition comes with a graphical package manager called Synaptic that you can you use to easily install the Apache web server as well as the PHP module and the MySQL Server one.  To do this follow the step:

  1. Run Synaptic by choosing System –Administration – Synaptic Package Manager. (You’ll probably be prompted to enter your root (admin) password that you created when you installed Ubuntu).
  2. Click the reload button in power alone Synaptic’s toolbar to make sure it knows about the latest Ubuntu packages.
  3. Click the world wide web option in the list of packages groups on the left side of the window than, in the top right window, click the checkbook next to the following:

Packages :apache2,  back php5,  php5-curl, php5-gd, php5-mysql, php5-sqlite, php5-xsl and php-pear.  You will see a pop-up menu appear each time you click below the check box; choose mark for installation from this menu.

Now Click the miscellaneous –text-based option in the packages groups list on the left, then click the checkboxes next to mysql-client and mysql-server.

  1. Often you will see “Mark additional required changes ?” dialog – appear each time you mark one of the packages for installation .  Click the mark button to ensure that Synaptic installs any additional required packages.
  2. Click the apply button in the Synaptic’s toolbar, then in the summary dialog box that appears, click Apply. Synaptic grabs all the needed packages from the Web and installs them for you.  Along the way you will probably be prompted to enter a password, then inter it again when prompted.  If all goes well you will eventually see a chance you knows applied dialog box appears; click the close button in the dialog box to finish the installation.
  3. At this point, you need to start that Apache web server. To do this, choose system-administration-services, then click unlock button at the bottom of the services setting dialog box and enter your password.  Now the scroll down to the “web server (apache2)” option, and select its check box to start it.

That’s it.  You should now have a working Apache web server with PHP and MySQL installed.  Skip to the” testing your installation” select to make sure everything’s working OK.

The packages you have installed you have basic as PHP installation with the functionality needed to follow the contents of this book.  However, you can use synaptic to install extra PHP packages (or remove packages) just easily at any time.

In fact, as of Ubuntu 7.04, then is an even easier way to install Apache, PHP and MySQL is one go. Simply open up a terminal window (applications-accessories-Terminal), then type:

Sudo tasksel install lamp-server

And press Enter.  This installs all the packages needed to have a fully functioning LAMP Web server.  You will be prompted to choose a root password for MySql , during the installation, but apart from that, the process is fully automated.  Again, you will probably need to restart the Web server after installation.

Installing PHP on Windows

PHP one windows can work with Apache or IIS .  For the sake of simplicity, Here is very easy way to install Apache and PHP: WAMP server.  This handy piece of software gives you Apache, my SQL, and PHP all in one handy, easy to install package.

WAMP server comes from the acronym-windows, Apache, MySQL and PHP –which is used to describe any windows, based web server setup that uses these three open source technologies.

To install WAMP Server follow these steps:

  1. Download the latest version of Wamp server from http://www.wampserver.com/en/.

At the time of writing, the latest version was PHP 5.2.6, however, by the time you read this it’s likely that a PHP 5.3 version is available.

Open the WAMP server .EXE file that you downloaded, and followed the instruction on the screen to install the application.

Unblock Apache.  As you run the installer, you may be asked if you want to allow Apache, through the windows firewall, if you want to allow other computer on your network to access the web server, click unblock.  If you are only going to access the web server from a browser on the same computer, you can click keep blocking to improve security.

Enter default mail settings.  During the configuration process you will also be asked to enter a default mail server and e-mail address for PHP to use, you can accept that defaults for now.

Once the setup wizard has completed one, You should see a wampserver icon in your taskbar.

Click the icon to display the wampserver  menu.  Choose the start all services option to fire up the Apache and my SQL servers.

To test that the running server is running correctly, Choose the local host option from the Wampserver menu.  If all has gone according to plan, you should see the icon.  This means that wampserver  was successfully installed.

Congratulations !

Now you can use.

Installing PHP on Mac OS X

Mac OS X comes with a version of Apache and PHP already installed.  However, it is likely that the installed version is somewhat out of date.  Furthermore, Mac OS X does not come with a MySql package installed by de default; it’s possible to install it.

Note: You will need MySql  or a similar database system to build database driven web-sites.

As luck would have it, just as windows has WAMP, Mac OS X has MAMP , Mac OS X has MAMP- an all-in-one, easy to install packages that gives you an Apache, MySQL ,and PHP setup on your Mac. The great thing about MAMP (and its windows WAMP equivalents, for that matter)is that it’s self contained.This means that folder; and it’s very easy to uninstall later if you want to.

To install MAMP on your Mac, follow these steps:

  1. Download the latest MAMP version from www.mamp.info/en/. ( At the time of writing,two versions are available: MAMP and MAMP PRO. The regular MAMP is fine for the purpose of developing PHP applications on your Mac).
  2. Open the MAMP .dmg file that you downloaded.
  3. In the window that pops up, drag the MAMP folder on top of the application folder to install it.
  4. Open the MAMP folder inside your applications folder in finder, then double-click the MAMP                          icon to launch the application.
  5. If necessary, click the start server button to start up the Apache and MySQL servers. Once they running, you should green light next to them in the dialog box.
  6. To test the web server is running correctly, click the open start page button.you now have a working Apache, and MySql installation on your Mac.

Note : By Default, MAMP’s Apache server runs on port 8888, and it MySQL server runs on port 8889.This is to avoid conflicts with any other Apache or MySQL server that might be running on your Mac, but it does mean that you need to specify the Apache port(8888) in the URL in your browser’s address bar.

You can click the preference button in the MAMP application to change the ports that the MAMP Apache and MySQL servers use. For example provided you’ve stopped any other web servers on your Mac that might use the slandered HTTP port 80, you can set the MAMP Apache port of 80 to avoid having to type the port number into your browser’s  address bar.

As with the Linux and Windows install options previously discussed, MAMP install PHP 5.2 at the time of writing, not PHP 5.3 .

Leave a Reply

Your email address will not be published.