Friday 12 July 2013

Cannot access xampp from internet in Cent OS

Issue

I have xampp installed on Cent OS. I started the xampp server and tried to access it with localhost, it is working. But i cant access it using the system IP. I can ping the server.But I can't  access the server from any other computer on the network.

Solution

The default firewall of CentOS permits ssh input(tcp 22) and icmp(ping). Open a terminal and type


[root@ ~]# cat /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
Try at first stopping your firewall issuing the following command:

[root@ ~]# /etc/init.d/iptables stop
Now, test if you can access your XAMPP server.
Go to File System -> etc - >sysconfig
Open iptables. Remove the below line


-A INPUT -j REJECT --reject-with icmp-host-prohibited
 Add the below new line

iptables -A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 80,443 -j ACCEPT
It enables the ports you need to access(80 , 443).
Now your iptables looks like


# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 80,443 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
Save the file and close it.
Start your firewall issuing the following command:


[root@ ~]# /etc/init.d/iptables start
Now  you can access your XAMPP server using your macine ip address