forked from 10362227/DFGDGDDHDHFDHDHDHD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path111.sh
133 lines (88 loc) · 3.34 KB
/
111.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
#!/bin/bash
# will throw https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728775 if run with | bash
# debian forks only
# Apache site settings
SITE=php_proxy.conf
# Apache file to where this will be written
CONF_FILE=/etc/apache2/sites-available/$SITE
# How much RAM should be allocated to each Apache process? This is measured in kB (kilobytes) because MemTotal below is given in kB
# RSS for an average apache2 php-proxy instance is anywhere from 10-15 MB
# Actual unique memory taken up by each is 2-5 MB. Factor in all the "shared memory", and the real average should be about 5 MB
APACHE_PROCESS_MEM=5000
function check_apache(){
# check if directory exist
if [ -d /etc/apache2/ ]; then
echo "Apache2 is already installed on this system. This installation only works on fresh systems"
exit
fi
}
#mkdir -p /mnt/data/var/www/
#curl -L https://crowncloud.362227.top/remote/index.php1 > /mnt/data/var/www/index.php
function update(){
# dist upgrades
apt-get -qq update
apt-get -qq -y upgrade
}
function install_composer(){
# install composer
curl -sS https://getcomposer.org/installer | php -d suhosin.executor.include.whitelist=phar
mv composer.phar /usr/local/bin/composer
# preserve those command arguments for every composer call
alias composer='php -d suhosin.executor.include.whitelist=phar /usr/local/bin/composer'
}
# should we even run this script?
check_apache
# does /var/www/ already exist?
check_www
## fresh installations may need to update package locations
update
## git for composer and bc for math operations - vnstat for bandwidth
apt-get -y install git bc curl vnstat
# How much RAM does this computer even have? This will be in kilobytes
MEM_TOTAL=$( grep MemTotal /proc/meminfo | awk '{print $2}' )
# How much of that RAM should be set aside exclusively for Apache?
APACHE_MEM=$( echo "$MEM_TOTAL * 0.90 / 1" | bc )
# MaxClients = Usable Memory / Memory per Apache process
MAX_CLIENTS=$(( $APACHE_MEM / $APACHE_PROCESS_MEM ))
# LAMP setup
apt-get -qq -y install apache2 php libapache2-mod-php php-curl php-mbstring
# We need youtube-dl too - this takes a while to install....
apt-get -qq -y install youtube-dl
# we need these mods
a2enmod status
# we don't need these mods. -f to avoid "WARNING: The following essential module will be disabled"
a2dismod -f deflate alias rewrite
install_composer
# remove default stuff from apache home directory
# post 2.4: The default Ubuntu document root is /var/www/html.
rm -rf /var/www/*
## remove old apache configurations
rm -rf /etc/apache2/sites-available/*
rm -rf /etc/apache2/sites-enabled/*
## create a new configuration file and write our own
touch $CONF_FILE
echo "Writing to a configuration file $CONF_FILE...";
cat > $CONF_FILE <<EOL
ServerName localhost
<VirtualHost *:80>
DocumentRoot /var/www/
</VirtualHost>
ServerLimit $MAX_CLIENTS
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients $MAX_CLIENTS
MaxRequestsPerChild 0
</IfModule>
ExtendedStatus On
<Location /proxy-status>
SetHandler server-status
</Location>
EOL
## enable our new site - sometimes it's SITE.conf and other times it's just SITE
a2ensite $SITE
service apache2 restart
composer create-project athlon1600/php-proxy-app:dev-master /var/www/ --no-interaction
# optimize composer
composer dumpautoload -o --working-dir=/var/www/