-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstallLAMP.sh
59 lines (54 loc) · 1.24 KB
/
InstallLAMP.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
#Tested with Centos 6.x
#Trace execution
set -o xtrace
# Install MySQL
function installMySQL
{
yum -y install mysql mysql-server
/etc/init.d/mysqld start
chkconfig --levels 35 mysqld on
# replace newpass by your password
/usr/bin/mysqladmin -u root -h `hostname` password 'newpass'
/usr/bin/mysqladmin -u root -h localhost password 'newpass'
}
function installHTTPD
{
yum -y install httpd
/etc/init.d/httpd start
chkconfig --levels 35 httpd on
# Now browse IP of server to see test page
# if it hangs remove firewall
# iptables -F
# chkconfig iptables off
# or allow port 80
}
function installPHP
{
#install PHP packages
yum -y install php
# install php-mysql package
yum -y install php-mysql
#restart httpd
/etc/init.d/httpd start
}
function configureFirewall
{
#restore iptables from old config
iptables-restore /etc/sysconfig/iptables.old
#add the httpd port 80
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# This ensures you don't lock yourself out
# ssh if working remotely
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#Save new config
service iptables save
#Restart firewall
/etc/init.d/iptables restart
}
installHTTPD
installMySQL
installPHP
configureFirewall
# Now go ahead and configure virtualhosts
# Test php with: php -r "phpinfo();"