-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstallLNMP.sh
executable file
·81 lines (66 loc) · 1.69 KB
/
installLNMP.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Description: install LNMP, Composer and Redis
# Author: tlanyan<https://tlanyan.me>
function checkSystem()
{
result=$(id | awk '{print $1}')
if [ $result != "uid=0(root)" ]; then
echo "action must be carried out by root!"
exit 1
fi
if [ ! -f /etc/centos-release ];then
echo false
return
fi
result=`cat /etc/centos-release|grep "CentOS Linux release 7"`
if [ "$result" = "" ]; then
echo false
fi
echo true
}
function installNginx()
{
yum install epel-release
yum install -y nginx
systemctl enable nginx.service
}
function installPHP()
{
yum install epel-release
yum install -y https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
rm -rf /etc/yum.repos.d/remi-php54.repo
rm -rf /etc/yum.repos.d/remi-php70.repo
rm -rf /etc/yum.repos.d/remi-php71.repo
sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' /etc/yum.repos.d/remi-php72.repo
yum install -y php-cli php-fpm php-gd php-mbstring php-mysqlnd php-pdo php-opcache php-xml php-pecl-zip
systemctl enable php-fpm.service
}
function installComposer()
{
wget https://getcomposer.org/installer
php installer
rm -rf installer
mv composer.phar /usr/local/bin/composer
}
function installMariaDB()
{
yum install -y nginx mariadb mariadb-server
systemctl enable mariadb.service
}
function installRedis()
{
yum install -y redis
systemctl enable redis.service
}
result=$(checkSystem)
if [ "$result" != "true" ]; then
echo "scripts only tested on centos 7!"
exit 1
fi
echo -n "system version : "
cat /etc/centos-release
installNginx
installPHP
installComposer
installMariaDB
installRedis