News:

:) Be aware all of you from laziness (al-kasal). The prophet, ^alayhi-s-salatu was-salam, said as part of his du^a': Wa^udhu bika minal^ajzi w-al-kasal. Al-^ajz means the weak endeavor in working for the Religion. It is not the weakness of the body. Many people have weak bodies, but when it comes to endeavor they are stronger than men with strong bodies. Both, weakness and laziness delay the person from reaching higher ranks.

Main Menu

Tutorial - PHP, Mysql and Apache configuratioN

Started by alsunna, 03, 16

Previous topic - Next topic

alsunna

This tutorial is based on the installation and configuration of MySQL, Php & Apache on a windows XP systems.

--------------------------------------------------------------------------------
Requirement :
Apache: download the apache software
PHO: download the PHP software
MySql: download the Mysql software


Important :
Service Pak: for windows Xp :SP1 is necessary
Windows Socket: Windows 95 : Windows socket most be installed and Windows most be updated
Port: Apache cannot share the TCP port with another software, so you might have to shutdown other services that use the same port


to be cont..

alsunna

Apache Installation - Configuration and Test
--------------------------------------------------------------------------------

The Apache Link
http://www.apache.org/dyn/closer.cgi

click on the link to download the software and save to a directory of your choice
Locate the Apache.exe file and run it.
Information that you will have to enter in the first step:


Network Domain : Domain Name, Workgroup, otherwise use 'User'

Server Name: localhost

Administators Email: your_email@domain.com

Finish the install.
--------------------------------------------------------------------------------
Right after you install Apache, it is configured just to run on default. So lets try it out now:

For Win9x/2000/xp/2003
Click on Start — Programs — Apache HTTP Server — Control Apache Server — Start Apache in Console
Apache launches a DOS window then the window is immediately renamed to 'APACHE'. It will desappear in a couple of seconds. In win98, the window stays there, you have to minimize it.

--------------------------------------------------------------------------------
Now, you have configured apache, you can't wait to test it: Open your browser and type http://localhost, can you see this logo:



We are in business. One more thing : to Stop - Start - Restart apache type the following line: net stop/start/restart apache
--------------------------------------------------------------------------------


now we have to tell apache the extention that it will have to check for and the place where all the web files will be located


Let's modify the httpd.conf file:

Open httpd.conf and make a search for : DirectoryIndex and add the extentions: index.htm, index.php, etc...



Let's make a directory called: WebData and we will copy index.html in it for now.

alsunna

PHP Installation - Configuration and Test
--------------------------------------------------------------------------------

The PHP Link
click on the link to download the software and save to a directory of your choice but you will have to unzip it to PHP directory. PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Let's unzip this file into the folder 'c:\php'or the PHP directory for the current drive(H:\PHP, F:\PHP etc...)




Note: When you unzip this file, it drops an extra folder. C:\php\php-blah*. Move the contents of the second php folder to the first one then delete that extra php folder that was created.

Configure PHP
Go into folder 'c:\php' find file 'php.ini-dist' rename it to 'php.ini' Open the file 'php.ini' using 'Notepad' Under 'Search' click 'Find' or 'Edit' click 'Find' on Windows 2000 or press 'Ctrl+F' then type this 'doc_root' and modify according to the image below. Seven lines after find 'extension_dir' and modify following the image below.




Save and Close the file.
Move the file 'php.ini' to c:\windows -- Win95/98/XP To c:\winnt or c:\winnt40 -- WinNT/2000/XP
copy the file php4apache.dll from c:\php\sapi folder to the apache.exe folder by default c:\Program Files\Apache Group\Apache
copy the file php4ts.dll from c:\php to the same apache.exe folder c:\Program Files\Apache Group\Apache

alsunna

Configure Apache for PHP

Open the 'httpd.conf' file that we opened earlier configuring Apache.
Click on Start — Programs — Apache HTTP Server — Configure Apache Server — Edit the Apache httpd.conf Configuration File
Search for 'DocumentRoot' & 'Directory' Modify the variables to match the following values:
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Go to the line or search for 'AddType application/x-tar .tgz' below that line add the following: -You can cut and paste them. LoadModule php4_module c:/php/sapi/php4apache.dll AddModule mod_php4.c AddType application/x-httpd-php .php -Save and Close the file.

--------------------------------------------------------------------------------

Test PHP
If your apache was still running while you configured php then shut it down and restart it. Lets go ahead and test php with a simple line. Open Notepad by clicking 'Start' -> 'Run' then typing 'notepad'
Open this link copy type the following line: test for php Save the file under 'c:\WebData\test.php' Open your browser and type this at the location box 'http://localhost/test.php'

http://www.me.homelinux.com/test.txt

The sample script is about a greeting form.

alsunna

Mysql Installation - Configuration and Test

--------------------------------------------------------------------------------

Mysql Link
http://dev.mysql.com/downloads/mysql/4.0.html


Click on the link to download the software and save to a directory of your choice The package that you got is a zip file which contains the setup files. You will need to unzip the files so that you can install it. This one is really to install. Extract the files to a folder, the double click on the setup.exe and you will have to click on NEXT till the installation is complete.

Securing the Initial MySQL Accounts
Part of the MySQL installation process is to set up the mysql database containing the grant tables:
Windows distributions contain preinitialized grant tables that are installed automatically. On Unix, the grant tables are populated by the mysql_install_db program. Some installation methods run this program for you. Others require that you execute it manually.

Part of the MySQL installation process is to set up the mysql database containing the grant tables:

Windows distributions contain preinitialized grant tables that are installed automatically.
On Unix, the grant tables are populated by the mysql_install_db program. Some installation methods run this program for you. Others require that you execute it manually.
The grant tables define the initial MySQL user accounts and their access privileges. These accounts are set up as follows:

Two accounts are created with a username of root. These are superuser accounts that can do anything. The initial root account passwords are empty, so anyone can connect to the MySQL server as root without a password and be granted all privileges.

On Windows, one root account is for connecting from the local host and the other allows connections from any host.
On Unix, both root accounts are for connections from the local host. Connections must be made from the local host by specifying a hostname of localhost for one account, or the actual hostname or IP number for the other.

Two anonymous-user accounts are created, each with an empty username. The anonymous accounts have no passwords, so anyone can use them to connect to the MySQL server.

On Windows, one anonymous account is for connections from the local host. It has all privileges, just like the root accounts. The other is for connections from any host and has all privileges for the test database or other databases with names that start with test.

On Unix, both anonymous accounts are for connections from the local host. Connections must be made from the local host by specifying a hostname of localhost for one account, or the actual hostname or IP number for the other. These accounts have all privileges for the test database or other databases with names that start with test_.

As noted, none of the initial accounts have passwords. This means that your MySQL installation is unprotected until you do something about it:

If you want to prevent clients from connecting as anonymous users without a password, you should either assign passwords to the anonymous accounts or else remove them.

You should assign passwords to the MySQL root accounts.

The following instructions describe how to set up passwords for the initial MySQL accounts, first for the anonymous accounts and then for the root accounts. Replace ``newpwd'' in the examples with the actual password that you want to use. The instructions also cover how to remove the anonymous accounts, should you prefer not to allow anonymous access at all.

You might want to defer setting the passwords until later, so that you don't need to specify them while you perform additional setup or testing. However, be sure to set them before using your installation for any real production work.

To assign passwords to the anonymous accounts, you can use either SET PASSWORD or UPDATE. In both cases, be sure to encrypt the password using the PASSWORD() function.

To use SET PASSWORD on Windows, do this:

shell> mysql -u root
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR ''@'%' = PASSWORD('newpwd');

To use SET PASSWORD on Unix, do this:

shell> mysql -u root
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');

In the second SET PASSWORD statement, replace host_name with the name of the server host. This is the name that is specified in the Host column of the non-localhost record for root in the user table. If you don't know what hostname this is, issue the following statement before using SET PASSWORD:

mysql> SELECT Host, User FROM mysql.user;

Look for the record that has root in the User column and something other than localhost in the Host column. Then use that Host value in the second SET PASSWORD statement.

The other way to assign passwords to the anonymous accounts is by using UPDATE to modify the user table directly. Connect to the server as root and issue an UPDATE statement that assigns a value to the Password column of the appropriate user table records. The procedure is the same for Windows and Unix. The following UPDATE statement assigns a password to both anonymous accounts at once:

shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
-> WHERE User = '';
mysql> FLUSH PRIVILEGES;

After you update the passwords in the user table directly using UPDATE, you must tell the server to re-read the grant tables with FLUSH PRIVILEGES. Otherwise, the change will go unnoticed until you restart the server.

If you prefer to remove the anonymous accounts instead, do so as follows:

shell> mysql -u root
mysql> DELETE FROM mysql.user WHERE User = '';
mysql> FLUSH PRIVILEGES;

The DELETE statement applies both to Windows and to Unix. On Windows, if you want to remove only the anonymous account that has the same privileges as root, do this instead:

shell> mysql -u root
mysql> DELETE FROM mysql.user WHERE Host='localhost' AND User='';
mysql> FLUSH PRIVILEGES;

This account allows anonymous access but has full privileges, so removing it improves security.

You can assign passwords to the root accounts in several ways. The following discussion demonstrates three methods:

Use the SET PASSWORD statement
Use the mysqladmin command-line client program
Use the UPDATE statement
To assign passwords using SET PASSWORD, connect to the server as root and issue two SET PASSWORD statements. Be sure to encrypt the password using the PASSWORD() function.

For Windows, do this:

shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('newpwd');

For Unix, do this:

shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');

In the second SET PASSWORD statement, replace host_name with the name of the server host. This is the same hostname that you used when you assigned the anonymous account passwords.

To assign passwords to the root accounts using mysqladmin, execute the following commands:

shell> mysqladmin -u root password "newpwd"
shell> mysqladmin -u root -h host_name password "newpwd"

These commands apply both to Windows and to Unix. In the second command, replace host_name with the name of the server host. The double quotes around the password are not always necessary, but you should use them if the password contains spaces or other characters that are special to your command interpreter.

If you are using a server from a very old version of MySQL, the mysqladmin commands to set the password will fail with the message parse error near 'SET password'. The solution to this problem is to upgrade the server to a newer version of MySQL.

You can also use UPDATE to modify the user table directly. The following UPDATE statement assigns a password to both root accounts at once:

shell> mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
-> WHERE User = 'root';
mysql> FLUSH PRIVILEGES;

The UPDATE statement applies both to Windows and to Unix.

After the passwords have been set, you must supply the appropriate password whenever you connect to the server. For example, if you want to use mysqladmin to shut down the server, you can do so using this command:

shell> mysqladmin -u root -p shutdown
Enter password: (enter root password here)