Installing with Windows
By following our step-by-step guide, you will successfully have all three components installed on
your Windows system. This guide includes instructions for Windows NT, Windows 2000,
Windows XP, and Windows .NET 2003.
Install Apache
Apache will act as the server for your PHP/MySQLWeb site. Installation is easy, as you will see.
This installation is for Windows NT, Windows 2000, Windows XP, and Windows .NET 2003. For
other versions of Windows, complete installation instructions can be found at www.apache.org.
Note that you must have TCP/IP running on your machine in order for your installation to be
operational.
The following are the basic steps for installation:
1. Go to www.apache.org, and click the HTTP Server link.
While the Apache Software Foundation provides many different software packages, this is
the only one we are concerned with at this time.
2. Click “Download from a Mirror” to choose an FTP site for downloading.
3. Click the Win 32 Binary-MSI Installer link to download.
If you experience problems downloading this file, you can try a different mirror site; click
the drop-down box near the top of the screen to locate one.
4. Click the MSI file to initiate the installation wizard for the Apache software.
After accepting the installation agreement, you will see a screen that is equivalent to a
readme.txt file—it gives basic information about the Apache software and where to go to find
more information. We highly recommend that you read this file.
5. Click Next. You will see the Server Information screen.
6. Enter the following information:
❑ Domain name: For example, domainname.com
❑ Server name: For example, server.domainname.com
❑ Net administrator’s e-mail address
❑ Who Are We Installing Apache For?
7. Select “All Users” if you want a server that will be available to anyone wishing to see your site
or “Only the Current User” for a server that will be used for testing purposes before files are
uploaded to a live server on another computer.
8. Click Next to select a setup type.
Typical installation is recommended for beginners and will suffice for most needs. Advanced
users may feel more comfortable choosing Custom setup.
9. Click Next.
The Destination Folder screen appears.
10. If you do not want your Apache files saved in the default path, click Change and select an alternate
path; then click Next.
The Ready to Install the Program screen appears.
11. Click Install to finish installation.
For configuration options and customization, please refer to Chapter 1 of this book.
Install PHP
This installation is for the PHP module on Windows 98, ME, and Windows 2000/XP/NT. For all other Windows versions, please refer to the source Web site, www.php.net.
The following are the steps for installing PHP:
1. Go to the PHPWeb site at www.php.net.
2. Scroll down to the “downloads” section and click the appropriate link for the version you wish
to install.
3. Scroll down to the Windows Binary section. If you are running your PHP on an Apache server,
as we do in this book, click the PHP Package link to be able to run PHP on Apache Server
4. Click any FTP site to begin the download.
5. Unzip your file using any standard unzip program and save it to the directory of your choice.
We recommend unzipping it to c:\ and then renaming it to c:\php\. It’s best not to save your
file in a directory with a space in it, as it can cause Web server problems.
6. Before you can run PHP, you will need to rename php.ini-dist to php.ini.
By default, the PHP installation provides two copies of your common configuration file:
php.ini-dist and php.ini-recommended. The php.ini-dist file is meant to be used for
development purposes, while php.ini-recommended should be used when your site goes live,
as it has additional security measures in place that the php.ini-dist does not have.
Depending on your reason for using PHP, you would choose the php.ini file that best suits
your needs. For the purposes of this book, we are going to be using the php.ini-dist file simply
because it is easier to work with and will present you with fewer obstacles. Once you are
more familiar with PHP in general, we encourage you to switch to the php.ini-recommended
file as your default. Therefore, you need to rename the configuration file as indicated in this step
in order for your PHP installation to be complete. Make sure to save your new php.ini file to
your c:\windows directory so Apache can find it.
7. Copy php4ts.dll into the c:\program files\Apache Group\Apache2\bin directory so that
Apache can find it.
This file can be found in the c:\php directory, not the c:\php\dlls directory.
You now need to configure your PHP to run with Apache and MySQL. Please refer to Chapter 1 for
more information on this step.
Install MySQL
MySQL is the database that holds all the data to be accessed by your Web site. This MySQL installation guide is for Windows 95, 98, 2000, NT, XP, and .NET 2003. For all other versions of Windows, please refer to the source Web site at www.mysql.com.
Proceed with the following steps to install MySQL:
1. Go to the source Web site, www.mysql.com, and click “downloads” on the navigation bar near
the top of the page.
2. Scroll down to the latest stable version of MySQL, and click that link.
3. Scroll down to the Windows section of the downloadable files, and click Select a Mirror.
4. Find a mirror and click to download (you may choose either HTTP or FTP to download).
5. Unzip the file to a temporary directory of your choice.
6. Click setup.exe to run the installation program. You will see the first of the Installation Wizard
screens.
7. Click Next to display the informational screen.
We highly recommend that you read this screen before you continue.
8. Click Next, which brings you to the Choose Destination Location screen.
9. If the default directory is acceptable, simply click Next; otherwise, click Browse and select a different
destination.
10. Click Next.
11. The next screen allows you to customize your installation; typical installation is sufficient for
most users.
12. Click the setup type you prefer, and click Next to begin the installation.
After installing the appropriate files, the final screen will simply indicate the installation is
complete. Click Finish to end the wizard.
You now need to configure your MySQL installation to fit your needs.
Installing with Linux
This section covers the installation of the three components of the AMP module using a Linux system. In this instance, we will cover an installation from the source for all three AMP components. Other methods are available, such as RPM, deb, and ebuild. We’ve chosen to cover source installations insteadbecause this method offers the most flexibility and works on nearly all UNIX-like systems.
Install MySQL
The following are the steps to install MySQL for a Linux system:
1. Go to the MySQLWeb site (www.mysql.com) and download the latest stable version of the
MySQL database server.
The link for this file is most likely located at the bottom under the heading Source Downloads.
2. Grab the tarball, named something along the lines of mysql-4.0.x.tar.gz.
3. Open a console window and change the directory (cd) to the folder where you downloaded the
tarball.
4. If there isn’t a user on the system dedicated to running the mysql daemon (typically mysql),
you’ll need to create one. To do this, in the console, enter the following commands:
> groupadd mysql
> useradd –g mysql mysql
5. Extract the tarball, and change to the directory it creates:
> tar –xzf mysql-VERSION.tar.gz
> cd mysql-VERSION
VERSION is the (sub)version of the mysql source tarball you downloaded, ‘0.15a’
6. Next, configure the source this way:
> ./configure —prefix=/usr/local/mysql
Using the --prefix switch tells the installer where to put the mysql libraries and binaries after
they’re built.
7. Compile the source:
> make
8. Install the libraries and binaries.
> make install
Note that you will need to be logged in as superuser (root) to perform this step and the following
steps in the MySQL installation.
9. If this is the first time MySQL has been installed on your machine (in other words, not an
upgrade), run this script to install the initial database/tables:
> scripts/mysql_install_db
10. Fix permissions on installed files, and copy over the default configuration file.
> chown –R root /usr/local/mysql
> chown –R mysql /usr/local/mysql/var
> chgrp –R mysql /usr/local/mysql
> cp support-files/my-medium.cnf /etc/my.cnf
Any changes you wish to make to customize MySQL should be made in this file.
11. Start the MySQL daemon:
> /usr/local/mysql/bin/mysqld_safe —user=mysql &
You’ll probably want to add the previous command to whatever facilities are available to
automatically start the daemon at boot. This varies by OS, so you’ll need to find out what works on
your system. Here is one easy way to add this that works with most systems (but may not be the
“best” way):
> echo ‘/usr/local/mysql/bin/mysqld_safe —user=mysql &’ >> /etc/rc.local
Install Apache
Follow these steps to install Apache:
1. Go to the Apache Web site (http://httpd.apache.org) and download the latest stable version
of the Apache 2 Web server.
2. Grab the tarball, named something along the lines of httpd-2.0.x.tar.gz.
3. Open a console window, and change the directory (cd) to the folder where you downloaded the
tarball.
4. Next, extract the tarball, and change to the directory it creates:
> tar –xzf httpd-2.0.47.tar.gz
> cd httpd-2.0.47
5. Configure the source:
> ./configure \
—prefix=/usr/local/apache2 \
—enable-so \
—enable-mods-shared=max \
—enable-modules=most
Using the --prefix switch tells the installer where to put the Apache server after it’s built. For
a complete list of configuration options, run ./configure -help.
6. Compile the source:
> make
7. Install the server:
> make install
Note that you will need to be logged in as superuser (root) to perform this step and the following
steps in the Apache installation.
8. Start the Apache daemon:
> /usr/local/apache2/bin/apachectl start
9. Add the command to start Apache to whatever boot scripts you like, so the server starts every
time you reboot. For example:
> echo ‘/usr/local/apache2/bin/apachectl start
Install PHP
Follow these steps to install PHP:
1. Go to the PHPWeb site (www.php.net) and download the latest stable version of PHP.
2. Grab the tarball, named something along the lines of php-4.3.x.tar.gz.
3. Open a console window, and change the directory (cd) to the folder where you downloaded
the tarball.
4. Next, extract the tarball, and change to the directory it creates:
> tar –xzf php-4.3.3.tar.gz
> cd httpd-4.3.3
5. Configure the source:
> ./configure \
—with-apxs2=/usr/local/apache2/bin/apxs \
—with-mysql=/usr/local/mysql
Make sure you point to the correct locations for the Apache 2 apxs binary, and the base of the
MySQL installation directory. There are numerous configuration options for PHP, and we would
almost need a chapter just to describe them all. For a complete list of configuration options, run
./configure -help.
6. Compile the source:
> make
7. Install PHP.
> make install
You will need to be logged in as superuser (root) to perform this step.
At this point, you should configure your php.ini file as you like and verify that the necessary directives
have been placed in Apache’s httpd.conf file.
Thursday, October 8, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment