Вы находитесь на странице: 1из 13

Chetan Soni Security Specialist

WAMP & LAMP


Installation and Configuration

By

CHETAN SONI
www.facebook.com/er.chetansoni

Page 1

Chetan Soni Security Specialist

About Me
I am a social-techno-learner who believes in its own efficiency first and then
implements with the suggestions of my strong and enthusiastic Team which helps me
takes everything into its perfection level.
At Present, I am the Founder & Admin of blog Just Do Hackers(JDH), a security based
blog and the overall resource person of a Online Digital Library named as Seculabs
which is a product of Secugenius Security Solutions.
I conducted more than 100 workshops on topics like Botnets, Metasploit Framework,
Vulnerability Assessment, Penetration Testing, Cyber Crime Investigation & Forensics,
Ethical Hacking at various institutions/Colleges/Companies all across the world.

Chetan Soni

www.facebook.com/er.chetansoni

Page 2

Chetan Soni Security Specialist

WAMP Server
Requirements/Software Needed :1.
2.
3.
4.

Apache v2
PHP v5
MySql v4.1
phpMyAdmin

Personally, I do my webdev on Linux, but needed to figure this out for a Windows XP
Home user. I found it very easy to setup, but only because I have a lot of experience with these
products. For this, I can imagine this process would be very confusing. So as, these are good
instructions to follow step-by-step to get this working. In this Project, I do not attempt to tell you
HOW to use Apache, MySql, PHP, or phpMyAdmin. Instead, I explain only enough to get it all
downloaded, installed, configured, and tested.
As fast as things change, these instructions may not be accurate in 30 days, but here
goes...PLEASE follow these directions in the order listed.
--------------------------------------------------------------Apache - The Web Server
--------------------------------------------------------------File Name: - apache_2.0.54-win32-x86-no_ssl.msi.
Run the installer and follow the installation wizard using all the default options.
When asked to provide a domain name, if you are just installing for personal local development
and learning, you can enter anything you want.
Try mydomain.net for example. This same screen will prompt for a server name and
an email address. The server name must include the domain name. So you could enter
www.mydomain.net.
(In this case, the name of your computer is "www" and the full name is "www.mydomain.net". It
does not have to match the actual computer name of your machine.)
You can just enter your real email address--it wont matter.
If everything worked, you should now have Apache installed and configured as a
Windows Service which means it will automatically start when you start Windows. You should
have a new icon in your System Tray that is a little red Apache feather. The icon shows the status
of your web server--green for running and red for stopped.
You can click it to open the Apache Service Monitor. You use this to Stop, Start, and
Restart the service. You will need to restart the service anytime you make a configuration
change.

www.facebook.com/er.chetansoni

Page 3

Chetan Soni Security Specialist


Confirm that the service is running. If not, start it.
If it fails, then your problems are beyond this tutorial. Sorry.
You have a web server! Open a browser and go to http://localhost.
You should see the Apache default page telling you your server is working. These pages are
being served from the Document Root, which by default a folder is named htdocs within the
location you installed Apache.
Default is C:\Program Files\Apache Group\Apache2\htdocs.
I like to leave this folder alone, and create my own Document Root to build my website in. To do
this, create a folder named www on your C:\ drive. Navigate to your C:\www folder, and create a
new file using Notepad or your favorite text editor. (I recommend PSPad.)
Name it index.html.
Copy and paste the following into c:\www\index.html.
[HTML]
<html>
<head>
<title>My Own Local Web Server</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
[/HTML]
Now we need to edit the Apache configuration to point it to our c:\www folder as the Document
Root. To do this, again in your favorite text editor, open the Apache conf file.
By default this is C:\Program Files\Apache Group\Apache2\conf\httpd.conf
Find the line that looks like this:
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"

Save your changes. Using the Apache Service Monitor, Restart the service. Open a browser and
go to http://localhost.

You should see your new home page which is c:\www\index.html.

www.facebook.com/er.chetansoni

Page 4

Chetan Soni Security Specialist


Whew! Step 1 complete.
--------------------------------------------------------------PHP - The Scripting Language
--------------------------------------------------------------File Name:- php-5.0.4-Win32.zip.
Create a folder named php on your C:\ drive. Unzip the file into c:\php.
Make a copy of c:\php\php.ini-recommended and name it c:\php\php.ini
Right-click My Computer and choose Properties. Choose the Advanced tab. Click the
Environment Variables button at the bottom.
In the System Variables section, click Path, then the Edit button.
At the end of the path value, add ;C:\php;C:\php\ext
Click OK and keep clicking OK until you exit out of the Properties.
Reboot your computer.
Now we have to modify the Apache conf so it knows to use the PHP module. To do this,
again in your favorite text editor, open the Apache conf file.
Find the LoadModule section that begins with a comment line that looks like this:
# Dynamic Shared Object (DSO)
At the end of the list of LoadModule lines, add these 4 lines:
# PHP5
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/php/"
DirectoryIndex index.html index.html.var

And change it to this:


DirectoryIndex index.html index.html.var index.php

Now save your changes, and restart Apache.


Create a new file named c:\www\index.php.
Copy these lines into it:
Rename c:\www\index.html to c:\www\old_index.html
Open http://localhost in your browser. You should see the phpinfo page that displays your PHP
version at top and a lot of system and user information tables.

www.facebook.com/er.chetansoni

Page 5

Chetan Soni Security Specialist


--------------------------------------------------------------MySql - The Database
--------------------------------------------------------------File Name:-mysql-essential-4.1.12a-win32.msi.
Run the installer and use all the default values. When prompted for a root password,
choose one you can remember. Normally, security is an issue here, but if this is just for you to
learn and play, it does not matter much.
Once the installation is complete, MySql should be configured as a Windows Service
which means it will auto start when you start Windows.
You should have a new MySql folder in your Start/All Programs menu. One of the items in the
menu is MySQL Command Line Client.
You can use this to do all your database administration from creating databases and tables to
inserting data, etc.
For now, though, use the MySQL Command Line Client to test your installation. Open the
command line client to see a password prompt.
Enter your root password.
Welcome to the MySQL monitor.
Your MySQL connection id is 60 to server version: 4.1.12a-nt
Now you need to configure PHP to work with MySql. Open c:\php\php.ini in your
favorite text editor. There are 2 lines you need to uncomment.
Save your changes. Restart the Apache service. (That's right--since we are using php as
an Apache module, anytime you change either the Apache conf file or the PHP ini file, you must
restart Apache to see your changes.)
To test that you have PHP configured to work with MySql, create a file named
c:\www\dbtest.php.
You now have a WAMP system to administrate your database.

www.facebook.com/er.chetansoni

Page 6

Chetan Soni Security Specialist

LAMP Server
LAMP means Linux, Apache, MySql and PHP. Depending on who you talk to, the P
also stands for Perl or Python, but in general, it is assumed to be PHP.

Initial Steps
PLEASE BE AWARE THAT A SOURCE-BASED INSTALLATION LIKE THIS ONE IS
NOT NEEDED FOR A BASIC LAMP SERVER!
You should only be doing a source-based installation if you need to alter settings in one
or more components of the LAMP stack (e.g., you need a feature in PHP that isn't in the default
RPM). If you are just getting started with LAMP, use the binaries provided by your distribution it is much simpler, and a lot easier to upgrade later.
Most out-of-the-box Red Hat Linux installations will have one or more of the LAMP
components installed via RPM files. I personally believe in installing things like this from
source, so I get the most control over what's compiled in, what's left out, etc. But source code
installs can wreak havoc if overlaid on top of RPM installs, as the two most likely won't share
the same directories, etc.
If you have not yet installed your Linux OS, or just for future reference, do not choose
to install Apache, PHP, or MySQL during the system installation. Then you can immediately
proceed with the source-based install listed here.
su root
yum install gcc gcc-c++
Log in as root
If you do not have direct access (via keyboard) to the server, PLEASE use
Secure Shell (SSH) to access the server and not telnet!! Whenever you use telnet (or plain
FTP for that matter), you are transmitting your username, password, and all session information
in "plain text". This means that anyone who can access a machine someplace between your PC
and your server can snoop your session and get your info. Use encryption wherever possible!
su - root

www.facebook.com/er.chetansoni

Page 7

Chetan Soni Security Specialist


At the time of updating this, the current versions of all the components we'll use are:
MySQL - 4.1.22
Apache - 1.3.37
PHP - 4.4.6

Installing Apache2 With PHP5 And MySQL


1. Preliminary Step
In this use the hostname server1.example.com with the IP address 192.168.0.100.
These settings might differ for you, so you have to replace them where appropriate.

2. Installing MySQL 5.0


To install MySQL,
yum install mysql mysql-server
Then we create the system startup links for MySQL
(so that MySQL starts automatically whenever the system boots) and start the MySQL server:
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
Run
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword
to set a password for the user root (otherwise anybody can access your MySQL database!).

3. Installing Apache2
Apache2 is available as a Redhat 6.0 package, therefore we can install it like this:
yum install httpd
Now configure your system to start Apache at boot time...
www.facebook.com/er.chetansoni

Page 8

Chetan Soni Security Specialist


chkconfig --levels 235 httpd on
... and start Apache:
/etc/init.d/httpd start
Now direct your browser to http://192.168.0.100, and you should see the Apache2 placeholder
page:

Apaches default document root is /var/www/html on Redhat System, and the


configuration file is /etc/httpd/httpd.conf .
Additional Configurations are stored in /etc/httpd/conf.d/ Directory.

4. Installing PHP5
We can install PHP5 and the Apache PHP5 module as:
Yum install php
We must Restart Apache Afterwards
/etc/init.d/httpd restart
www.facebook.com/er.chetansoni

Page 9

Chetan Soni Security Specialist

5. Testing PHP5 / Getting Details About Your PHP5 Installation


The document root of the default web site is /var/www/html. We will now create a small
PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful
details about our PHP installation, such as the installed PHP version.
vi /var/www/html/info.php
<?php
phpinfo();
?>

Now we call that file in a browser (e.g. http://192.168.0.100/info.php):

As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as
shown in the Server API line. If you scroll further down, you will see all modules that are
already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support
in PHP5 yet.

www.facebook.com/er.chetansoni

Page 10

Chetan Soni Security Specialist

6. Getting MySQL Support In PHP5


To get MySQL support in PHP, we can install the php-mysql package. It's a good idea to install
some other PHP5 modules as well as you might need them for your applications. You can search
for available PHP5 modules like this:
yum search php
Pick the ones you need and install them like this:
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
Now restart Apache2:
/etc/init.d/httpd restart
Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules
section again. You should now find lots of new modules there, including the MySQL module:

www.facebook.com/er.chetansoni

Page 11

Chetan Soni Security Specialist

7. phpMyAdmin
phpMyAdmin is a web interface through which you can manage your MySQL databases.
First we enable the RPMforge repository on our Redhat system as phpMyAdmin is not available
in the official Redhat repositories:
On i386 systems:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
phpMyAdmin can now be installed as follows:
yum install phpmyadmin
Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin
allows connections not just from localhost
(by commenting out the <Directory "/usr/share/phpmyadmin"> stanza):
vi /etc/httpd/conf.d/phpMyAdmin.conf
#
# Web application to manage MySQL
#
#<Directory "/usr/share/phpmyadmin">
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
#</Directory>
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

Next we change the authentication in phpMyAdmin from cookie to http:


vi /usr/share/phpMyAdmin/config.nic.php
[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]

www.facebook.com/er.chetansoni

Page 12

Chetan Soni Security Specialist


Restart Apache by this command:
/etc/init.d/httpd restart
Afterwards, you can Access phpMyAdmin under http://192.168.0.10/phpmyadmin/:

www.facebook.com/er.chetansoni

Page 13

Вам также может понравиться