dromich / -vhost-add Goto Github PK
View Code? Open in Web Editor NEWA small script that makes it easy to work with virtual hosts in Xampp on Linux
A small script that makes it easy to work with virtual hosts in Xampp on Linux
check Include etc/extra/httpd-vhosts.conf in in /opt/lampp/etc/httpd.conf
auto restart Apache
I want to make some minor changes:
#!/bin/bash
if (( $EUID != 0 )); then
echo "Please run as root!!!"
exit
fi
if grep "#Include etc/extra/httpd-vhosts.conf" /opt/lampp/etc/httpd.conf; then
echo "Place before adding a new virtual host, you should uncomment(remove # symbol) on this line \"Include etc/extra/httpd-vhosts.conf\" in the file in /opt/lampp/etc/httpd.conf"
exit
fi
read -p "Please enter a virtual domain name:" domain
echo "Added new virtual domain: $domain"
read -p "Use this directory as a DocumentRoot (type yes/no): " tDir
case $tDir in
"yes") myDir="$(pwd)";;
"y") myDir="$(pwd)";;
*) read -p "Enter DocumentRoot directory patch for new host: " myDir;;
esac
echo "DocumentRoot directory patch: $myDir"
# START
read -p "Use directory $myDir as a root site folder (type yes/no): " rDir
case $rDir in
"yes") rootDir="$myDir";;
"y") rootDir="$myDir";;
*) read -p "Enter root directory patch for new site: " rootDir;;
esac
echo "Site root directory patch: $rootDir"
# END
echo "Adding host config in /opt/lampp/etc/extra/httpd-vhosts.conf ...."
echo "<VirtualHost *:80>" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " ServerAdmin admin@$domain" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " DocumentRoot \"$myDir\"" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " ServerName $domain" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " ServerAlias www.$domain" >>/opt/lampp/etc/extra/httpd-vhosts.conf
# START
echo " ErrorLog \"logs/$domain-error_log\"" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " CustomLog \"logs/$domain-access_log\" common" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " <Directory "$rootDir">" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " Options Indexes FollowSymLinks Includes ExecCGI" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " AllowOverride All" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " Require all granted" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo " </Directory>" >>/opt/lampp/etc/extra/httpd-vhosts.conf
# END
echo "</VirtualHost>" >>/opt/lampp/etc/extra/httpd-vhosts.conf
echo "Adding host( $domain ) alias to 127.0.0.1 /etc/hosts ....."
if grep $domain /etc/hosts; then
echo "This domain was added in hosts file earlier"
else
# TAB INSTEAD OF SPACE
echo "127.0.0.1 $domain" >>/etc/hosts
fi
echo "Xampp restarting....."
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/lampp/lampp restart
echo "All done"
Also it would be good to check the availability of "net-tools" package. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.