-
Notifications
You must be signed in to change notification settings - Fork 1
/
lemp_deb_18.04.sh
151 lines (120 loc) · 3.97 KB
/
lemp_deb_18.04.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
echo "Welcome automated LEMP Stack Setup (Ubuntu 18.04) 1.2"
echo "Step:1 [System Update]"
echo "Update Starts....."
sudo apt update && sudo apt upgrade
echo -e "System Update Completed Successfully\n"
echo "Step:2 [Install NGINX]"
sudo apt install -y nginx
echo -e "NGINX Installation Completed Successfully\n"
echo "Step:3 [Allow SSH in Firewall]"
sudo ufw allow OpenSSH
echo -e "Done."
echo "Step:4 [Allow nginx in Firewall]"
sudo ufw allow in "Nginx Full"
echo -e "Done."
echo "Copying IP of this server"
sudo apt-get install -y curl
ip=`curl -s https://api.ipify.org`
echo "Step:5 [Install MySQL]"
sudo apt install mysql-server
sudo mysql_secure_installation
echo -e "MySQL Installation Completed Successfully\n"
echo "Step:7 [Install PHP7.2]"
sudo apt install -y php-fpm php-mysql
echo -e "PHP 7.2 Installation Completed Successfully\n"
sudo systemctl start php7.2-fpm
sudo systemctl enable php7.2-fpm
echo "Step:5 [Install PHPmyadmin]"
sudo apt-get install -y phpmyadmin
echo -e "PHPmyadmin Installation Completed Successfully\n"
sudo systemctl restart nginx
echo "Remove the default symlink in sites-enabled directory"
sudo rm /etc/nginx/sites-enabled/default
sudo echo 'server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name '$ip';
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}' > /etc/nginx/sites-available/default
sudo nginx -t
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
sudo systemctl reload nginx
echo -e "Downloading latest Adminer\n"
cd /var/www/html
sudo wget -q -O db.php https://www.adminer.org/latest-mysql-en.php
echo -e "Dowloaded and Renamed Successfully\n"
echo "Creating a Configuration File for Adminer in sites-enabled directory"
cd /etc/nginx/sites-available
sudo wget https://raw.githubusercontent.com/masiur/Environment-Configuration/master/src/db-adminer
sudo ln -s /etc/nginx/sites-available/db-adminer /etc/nginx/sites-enabled/
sudo systemctl reload nginx
sudo ufw allow 51
cd ~
sudo cat > /var/www/html/index.html <<END
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx! Looks like your Server is Ready</h1>
<br/>
<a href="http://$ip/info.php">Php - info</a>.<br/>
<br/>
<a href="http://$ip:50">Database</a>.<br/>
</body>
</html>
END
sudo cat > /var/www/info.php <<END
<?php
phpinfo();
?>
END
echo "Configuration File Ready"
echo "Step:7 [Install Git]"
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install -y git
echo -e "Git Installation Completed Successfully\n"
echo "Step:8 [Install php-fpm]"
sudo service php7.2-fpm restart
sudo systemctl restart nginx
echo -e "mcrypt Installation and enable rewrite Completed Successfully\n"
echo "Step:9 [Install Composer]"
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
echo -e "Composer Installation Completed Successfully\n"
sudo ufw enable
echo "+-------------------------------------------+"
echo "| ${b}${A}Finish Auto Install and Setup LEMP${R} |"
echo "| |"
echo "| Web Site: http://$ip/"
echo "| |"
echo "| Database Adminer: http://$ip:50"
echo "| User:root || Pass"
echo "| |"
echo "| Test PHP:http://$ip/info.php"
echo "| |"
echo "| ${E}Warning:Delete info.php${R} |"
echo "| |"
echo "+-------------------------------------------+"
echo "Thanks !!! ~ Your Lemp config has been successfully done"