-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvhost_install.sh
More file actions
38 lines (26 loc) · 985 Bytes
/
vhost_install.sh
File metadata and controls
38 lines (26 loc) · 985 Bytes
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
#!/bin/bash
# Enable a virtual host in my Antegos system
read -p 'Name of the site : ' sitename
read -e -p 'IP of the site : ' -i '127.0.0.1' siteip
# Add the register in /etc/hosts:
sed -i -e '$a'$siteip' '$sitename /etc/hosts
# Check if /etc/httpd/conf/vhosts exist if not create
if [ ! -d /etc/httpd/conf/vhosts ]; then
mkdir /etc/httpd/conf/vhosts
fi
# Copy conf file to vhosts directory
cp virtualhost_conf /etc/httpd/conf/vhosts/$sitename
# Search and replace in the created conf file
sed -i -e 's/_site_/'$sitename'/g' /etc/httpd/conf/vhosts/$sitename
# Include the conf file to /etc/httpd/conf/httpd.conf
sed -i -e '$aInclude conf/vhosts/'$sitename /etc/httpd/conf/httpd.conf
# Create folder for public files
mkdir /srv/http/$sitename
# Folder permissions
chown http:http /srv/http/$sitename
# Reload apache service
systemctl restart httpd
echo 'Virtual Host Created --> http://'$sitename
echo 'Here is Apache status'
# Output apache status
systemctl status httpd