Giter Site home page Giter Site logo

-vhost-add's People

Contributors

dromich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

-vhost-add's Issues

Add functions

check Include etc/extra/httpd-vhosts.conf in in /opt/lampp/etc/httpd.conf
auto restart Apache

Some changes

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.