installing apache, php, mysql on windows...

4
Installing Apache, PHP, MySQL on Windows Computers Installation of Apache, PHP and MySQL is straightforward for Windows computers. Go to each of the Apache , PHP and MySQL sites to download the software. Select the appropriate ZIP file. Pick the versions that match your web server. You will have to modify your ini and configuration files as described in the install READMEs, but you do not have to worry about DSO modules, compiling, etc. as discussed for Linux below. I have omitted detailed discussion of changes to local files because different versions of PHP, MySQL and Apache have different requirements. Most web sites are hosted on a web server that hosts many sites. In most cases your site will be hosted with standard PHP, MySQL, Apache configurations. On your localhost (your own computer), you should not deviate too far from the configuration of your web hosting server. Otherwise, you will find yourself in the common programmer situation of saying ”well it works on my machine.” (More help about this subject is in my web hosting for developers article.) One of the great things about PHP and MySQL is many web hosting companies provide them at reasonable prices. So, install Apache, PHP and MySQL on your machine, write some code test it and upload it to a real web server for all the world to see. Installing Apache, PHP, MySQL for Red Hat Linux Installation is similar on other Linux distributions. The tutorial below covers two approaches. The first discussed is downloading and installing packages. How to use Apache's DSO Module is discussed second. The following tutorial was written for then current (year 2000) versions. For complete information regarding installation, especially if there are new versions released, you should read the install notes for each of the packages. This tutorial assumes you are running Linux and it is installed properly. For help with installing and configuring Linux check out some of the related links at the bottom of this page. Download the Packages First download the required packages to a directory. If you are running a different platform be sure to download the appropiate files for your platform: Apache download PHP download MySQL download

Upload: docong

Post on 04-Jan-2019

236 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Installing Apache, PHP, MySQL on Windows Computerstumorsdatabase.altervista.org/install_apache_php_mysql.pdf · Installing Apache, PHP, MySQL for Red Hat Linux Installation is similar

Installing Apache, PHP, MySQL on Windows Computers

Installation of Apache, PHP and MySQL is straightforward for Windows computers.

Go to each of the Apache, PHP and MySQL sites to download the software. Select the

appropriate ZIP file. Pick the versions that match your web server.

You will have to modify your ini and configuration files as described in the install READMEs,

but you do not have to worry about DSO modules, compiling, etc. as discussed for Linux below.

I have omitted detailed discussion of changes to local files because different versions of PHP,

MySQL and Apache have different requirements.

Most web sites are hosted on a web server that hosts many sites. In most cases your site will be

hosted with standard PHP, MySQL, Apache configurations. On your localhost (your own

computer), you should not deviate too far from the configuration of your web hosting server.

Otherwise, you will find yourself in the common programmer situation of saying ”well it works

on my machine.” (More help about this subject is in my web hosting for developers article.)

One of the great things about PHP and MySQL is many web hosting companies provide them at

reasonable prices. So, install Apache, PHP and MySQL on your machine, write some code test it

and upload it to a real web server for all the world to see.

Installing Apache, PHP, MySQL for Red Hat Linux

Installation is similar on other Linux distributions. The tutorial below covers two approaches.

The first discussed is downloading and installing packages. How to use Apache's DSO Module is

discussed second.

The following tutorial was written for then current (year 2000) versions. For complete

information regarding installation, especially if there are new versions released, you should read

the install notes for each of the packages.

This tutorial assumes you are running Linux and it is installed properly. For help with installing

and configuring Linux check out some of the related links at the bottom of this page.

Download the Packages

First download the required packages to a directory. If you are running a different platform be sure to

download the appropiate files for your platform:

Apache download PHP download MySQL download

Page 2: Installing Apache, PHP, MySQL on Windows Computerstumorsdatabase.altervista.org/install_apache_php_mysql.pdf · Installing Apache, PHP, MySQL for Red Hat Linux Installation is similar

Extract the Apache and PHP package into that directory using

# tar xfz apache_1.3.14.tar.gz

# tar xfz php_4.0.3pl1.tar.gz

Note: The pound sign # is the system prompt. You type in only what is after it .

Installing MySQL

MySQL is easiest to install on Red Hat systems using the RPM packages. To install MySQL in the same

directory as the RPM packages use the command:

# rpm -Uvh *.rpm

Note: You most likely need to do this as the root user. Either log in or su to root.

After MySQL is installed you need to set the root password. To do this use the following

commanding changing my_password to the password you want for the root user to access

MySQL.

# mysqladmin -u root password 'my_password'

Note: If the MySQL service is not running, you may have to start it by hand before trying to set

the password. It should start automatically when the computer boots. The command to start

MySQL is:

# /etc/rc.d/init.d/mysqld start

You can test the MySQL installation by doing the following:

# mysql mysql (connect to mysql database)

Enter Password:

mysql> SELECT * FROM user; (grab some data out of user table)

This should return the data in the user table. Type exit to leave.

Installing Apache with PHP

Apache with PHP can be installed a few different ways. One way is to statically embed the PHP binary

into the Apache binary. This is probably the fastest and best way to run PHP. You can also install PHP as

a DSO module (see below)

Page 3: Installing Apache, PHP, MySQL on Windows Computerstumorsdatabase.altervista.org/install_apache_php_mysql.pdf · Installing Apache, PHP, MySQL for Red Hat Linux Installation is similar

Here are the step by step directions to install Apache and PHP in the directory /usr/local/apache

In Apache src directory (apache_1.3.14/)

# ./configure --prefix=/usr/local/apache

In PHP src directory (php-4.0.3pl1/)

# ./configure --with-mysql \

--with-xml \

--enable-track-vars \

--with-apache=../apache_1.3.14 \

# make

# make install

In Apache src directory (apache_1.3.14)

# ./configure --prefix=/usr/local/apache \

--enable-module=rewrite \

--activate-module=src/modules/php4/libphp4.a

# make

# make install

This will install Apache in the /usr/local/apache directory. The only thing left to do is to

configure them.

Configuring Apache and PHP

To configure PHP copy php.ini-dist which is in the PHP src directory to /usr/local/lib/php.ini

Edit this file setting the options you wish, generally nothing needs to be edited. However, you

can set various options such as a default MySQL username and password.

To configure Apache edit /usr/local/apache/conf/httpd.conf and set the your document directory

and any other Apache settings you may want. To enable Apache and PHP to work together the

following line needs to be added:

AddType application/x-httpd-php .php

Page 4: Installing Apache, PHP, MySQL on Windows Computerstumorsdatabase.altervista.org/install_apache_php_mysql.pdf · Installing Apache, PHP, MySQL for Red Hat Linux Installation is similar

Look for this line or something similar already in the httpd.conf file and replace it with the above. Make

sure to remove the # comment mark.

After editing the config file you need to restart Apache. The command to restart Apache is:

/etc/rc.d/init.d/httpd restart

To test that Apache and PHP work together, create a PHP file. Name it test.php. The entire

contents of the file are:

<?php

echo("<h1>Yay! PHP and Apache Work!</h1>");

?>

Copy this file to the document directory, if you did not change the document directory in the

config file (httpd.conf) then the default document directory is /usr/local/apache/htdocs/ Load this

page in your browser by using the following URL: http://localhost/test.php