Build your own LAMP Server under CentOS


Apache2

Install

yum -y install openssh-server openssh-clients

Then start it up

iptables -n -L -v --line-numbers

Now open the iptables port, this is continuing from our last change but is including two rules, one for SSL connections (https).

[root@localhost /]# iptables -n -L -v --line-numbers
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1      705 65371 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
3        2   120 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
4       29  5379 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 
 
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1        0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Now you can browse to the installation and see the Apache start-up page. If you do not know what the ip is of your virtual box, type ifconfig at the command line to view the currently assigned address.


PHP5

Install PHP

iptables -I INPUT 4 -m tcp -p tcp --dport 22 -j ACCEPT
service iptables save

Restart Apache after install

[root@localhost /]# iptables -n -L -v --line-numbers
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1      705 65371 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
3        2   120 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0    
4        1    52 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22       
5       29  5379 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Now we can check to see if PHP is installed properly, we can run a test page and parse some data. The default directory for Apache’s install is /var/www/html.

nano -w /etc/ssh/sshd_config

Add the following into the new file

PermitRootLogin yes

Save the file and browse over to the new page. (ie: http://192.168.1.200/info.php)

Tagged , , , , , , , , . Bookmark the permalink.

Comments are closed.