Situatie
Vrem sa cream virtual host pt apache2 mai usor.
Solutie
Pasi de urmat
Executam comanda pico addvhost.sh
inseram urmatorul script in fisierul addvhost.sh
#!/bin/bash
name=$1
WEB_ROOT_DIR=$2
email=${3-‘webmaster@localhost’}
sitesEnable=’/etc/apache2/sites-enabled/’
sitesAvailable=’/etc/apache2/sites-available/’
sitesAvailabledomain=$sitesAvailable$name.conf
echo “Creating a vhost for $sitesAvailabledomain with a webroot $WEB_ROOT_DIR”
### Creare Virtual Host
echo ”
<VirtualHost *:80>
ServerAdmin $email
ServerName $name
DocumentRoot $WEB_ROOT_DIR
<Directory $WEB_ROOT_DIR/>
Options Indexes FollowSymLinks
AllowOverride all
</Directory>
</VirtualHost>” > $sitesAvailabledomain
echo -e $”nNew Virtual Host Createdn”
sed -i “1s/^/127.0.0.1 $namen/” /etc/hosts
a2ensite $name
service apache2 reload
echo “GATA, pentru verificare poti sa accesezi http://$name”
Salvam fisierul
Executam comanda chmod+x addvhost.sh
Executam comanda : ./addvhost.sh numevhost /locatia/unde/vor/fi/stocatate/fisierele/vhostului
Leave A Comment?