-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapache2-multi-virtual-host.sh
161 lines (137 loc) · 4 KB
/
apache2-multi-virtual-host.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
152
153
154
155
156
157
158
159
#!/bin/bash
set -e
mkdir -p $HOME/public_web/web000/html
mkdir -p $HOME/public_web/web001/html
mkdir -p $HOME/public_web/web002/html
mkdir -p $HOME/public_web/web003/html
mkdir -p $HOME/public_web/web004/html
#Listen 8080 //type port no. here or change over 80 or add new port numbers
sudo nano /etc/apache2/ports.conf
# add an existing user named $USER to group Apache group www-data
sudo adduser $USER www-data
##Add a new user to the www-data group
#sudo useradd -g www-data vivek
### set the password for vivek user ###
#sudo passwd vivek
##Add a existing user to www-data group
sudo usermod -a -G www-data $USER
id $USER
groups $USER
sudo ln -s $HOME/public_web/web000/html/ web000.com
sudo ln -s $HOME/public_web/web001/html/ web001.com
sudo ln -s $HOME/public_web/web002/html/ web002.com
sudo ln -s $HOME/public_web/web003/html/ web003.com
sudo ln -s $HOME/public_web/web004/html/ web004.com
sudo chmod -R 755 /var/www
sudo chown -R www-data:$USER /var/www
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/web000.com.conf
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/web001.com.conf
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/web002.com.conf
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/web003.com.conf
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/web004.com.conf
#<VirtualHost *:80> //change the port number here by default its #running on 80
# ServerAdmin webmaster@localhost
# ServerName sourabh.com // Give server name here
# DocumentRoot /var/www/sourabh.com/public_html/ // give Document root path here
# <Directory />
# Options FollowSymLinks
# AllowOverride None
# </Directory>
# <Directory /var/www/>
# Options Indexes FollowSymLinks MultiViews
# AllowOverride None
# Order allow,deny
# allow from all
# </Directory>
#
# ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
# <Directory "/usr/lib/cgi-bin">
# AllowOverride None
# Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
# Order allow,deny
# Allow from all
# </Directory>
#
# ErrorLog ${APACHE_LOG_DIR}/error.log
#
# # Possible values include: debug, info, notice, warn, error, crit,
# # alert, emerg.
# LogLevel warn
#
# CustomLog ${APACHE_LOG_DIR}/access.log combined
#
# Alias /doc/ "/usr/share/doc/"
# <Directory "/usr/share/doc/">
# Options Indexes MultiViews FollowSymLinks
# AllowOverride None
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/255.0.0.0 ::1/128
# </Directory>
#
#</VirtualHost>
sudo nano /etc/apache2/sites-available/web000.com.conf
#sudo nano /etc/apache2/sites-available/web001.com.conf
#sudo nano /etc/apache2/sites-available/web002.com.conf
#sudo nano /etc/apache2/sites-available/web003.com.conf
#sudo nano /etc/apache2/sites-available/web004.com.conf
sudo a2ensite web000.com
sudo a2ensite web001.com
sudo a2ensite web002.com
sudo a2ensite web003.com
sudo a2ensite web004.com
#<ip> hostname
#172.16.1.12 web000.com
#172.16.1.12 web001.com
sudo nano /etc/hosts
WEB='web000.com'
HTML="<html>
<head>
<title>${WEB}</title>
</head>
<body>
<h1>${WEB}</h1>
</body>
</html>"
echo $HTML > /var/www/web000.com/index.html
WEB='web001.com'
HTML="<html>
<head>
<title>${WEB}</title>
</head>
<body>
<h1>${WEB}</h1>
</body>
</html>"
echo $HTML > /var/www/web001.com/index.html
WEB='web002.com'
HTML="<html>
<head>
<title>${WEB}</title>
</head>
<body>
<h1>${WEB}</h1>
</body>
</html>"
echo $HTML > /var/www/web002.com/index.html
WEB='web003.com'
HTML="<html>
<head>
<title>${WEB}</title>
</head>
<body>
<h1>${WEB}</h1>
</body>
</html>"
echo $HTML > /var/www/web003.com/index.html
WEB='web004.com'
HTML="<html>
<head>
<title>${WEB}</title>
</head>
<body>
<h1>${WEB}</h1>
</body>
</html>"
echo $HTML > /var/www/web004.com/index.html
sudo service apache2 restart