Sunday, March 19, 2006

How to turn on the LAMP in 30 minutes

This is a how-to tutorial for LAMP (Linux, Apache, MySQL, PHP)!

Requirement: either you are running Linux on your physical machine or try VMWare Player (Free) and following step 0 to setup the environment.

Part A: Environment Setup (Optional):


Step 1: First go to http://www.thoughtpolice.co.uk/vmware/, download FC4:
Fedora Core 4, minimal install.
fedora-fc4-i386.zip, 283M
Download: fast torrent!, direct (60 second delay)
md5sum: 8e46e5ac5fe813cf83454febed2cfdef
Notes: Root password is "thoughtpolice". Remember
that a standard install means selinux
enabled, firewall on.
It only takes me 11 minutes for the direct download. (BT could be much faster). Next, extract to wherever you like. Then, fire VMWare Player and open fedora-fc4-i386.vmx.

Step 2: After you boot up the FC4 VM, login by root with password "thoughtpolice". Be sure to find out the IP address of the VM (default IP loads from DHCP):
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:89:3B:D3
inet addr:192.168.1.110 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe89:3bd3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:39409 errors:0 dropped:0 overruns:0 frame:0
TX packets:28155 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:49994259 (47.6 MiB) TX bytes:2735995 (2.6 MiB)
Interrupt:10 Base address:0x1080
Step 3: The FC4 VM has SELinux enabled and firewall on by default. We need to modify some firewall rules here.
     [root@localhost ~]# vi /etc/sysconfig/iptables
Step 4: You should have EXACTLY the same iptable configuration as the following:
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
Step 5: Just add these 5 lines (highlighted), which open FTP, SSH, HTTP, HTTPS, and MySQL
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
Step 6: Let’s restart the firewall, by launching this command:
[root@localhost ~]# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Step 7: Now you can at least use SSH to connect to this FC4 VM and other ports is going to be needed by LAMP.

Part B: LAMP (Linux, Apache, MySQL, PHP) Setup:

Step 1: Now, download XAMPP (LAMP all-in-one package) from http://www.apachefriends.org/en/xampp-linux.html#374. It guides you to download from sourceforge. Once you pick the mirror, use wget to download into your linux. For example, my ISP is near easynews.dl.sourceforge.net (Phoenix, AZ):
[root@localhost ~]# wget http://easynews.dl.sourceforge.net/sourceforge/xampp/xampp-linux-1.5.1.tar.gz
--01:32:48-- http://easynews.dl.sourceforge.net/sourceforge/xampp/xampp-linux-1.5.1.tar.gz
=> `xampp-linux-1.5.1.tar.gz'
Resolving easynews.dl.sourceforge.net... 69.16.168.245
Connecting to easynews.dl.sourceforge.net[69.16.168.245]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 47,380,489 [application/x-tar]
100%[=============================>] 47,380,489 510.83K/s ETA 00:00
01:34:19 (509.66 KB/s) - `xampp-linux-1.5.1.tar.gz' saved [47,380,489/47,380,489]
Step 2: You can follow http://www.apachefriends.org/en/xampp-linux.html#377 or my step as following:
[root@localhost ~]# tar xvfz xampp-linux-1.5.1.tar.gz -C /opt
lampp/
lampp/bin/
lampp/bin/CA
lampp/bin/DB/
lampp/bin/DB/scripts/
lampp/bin/DB/scripts/DB_DataObject_createTables.bat
......
......
......
lampp/phpsqliteadmin/SPSQLite.class.diff
lampp/phpsqliteadmin/phpsla.css
lampp/cgi-bin/
lampp/cgi-bin/test-cgi
lampp/cgi-bin/printenv
Step 3: Now let’s turn on our LAMP
[root@localhost ~]# /opt/lampp/lampp start
XAMPP: SELinux is activated. Making XAMPP fit SELinux...
Starting XAMPP for Linux 1.5.1...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
Step 4: Finally, fire up your favorite web browser, go to http://[your linux box IP]/. In my case, I would type in http://192.168.1.110/. Then choose you language, definitely English for now since you’re reading my steps in English, right? :)

0 Comments:

Post a Comment

<< Home



Welcome to my tech blog, you reach the end ... end of your life ... NO ! end of this blog