Create A Subdomain Linux Apache2 Web Server Script
Page 1 of 1
Create A Subdomain Linux Apache2 Web Server Script
- Code:
#!/bin/bash
#
# sudo chmod +x *.sh
#
# Example Usage: ./New.sh
#
# jnet.forumotion.com/t1509-create-a-subdomain-linux-apache2-web-server-script#2235
#
#
echo "Enter New Virtual Host Name"
read name1
# Creating New Hosts
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/$name1.conf
sudo mkdir /var/www/$name1/
# Adding Example Index page.
sudo echo "<center>Virtual Host test Page " > /var/www/$name1/index.php
# now set permissions for this file
sudo chown -R $USER:www-data /var/www/$name1/
sudo chmod -R 755 /var/www/$name1
sudo chown -R $USER:www-data /var/www/$name1/index.php
sudo chmod -R 755 /var/www/$name1/index.php
# Or Use nano if doing it remotely!
sudo gedit /etc/apache2/sites-available/$name1.conf
sudo a2ensite $name1.conf
sudo service apache2 restart
echo "Now add entry to hosts file..."
sudo gedit /etc/hosts
echo "All Done Now Test New Site With browser"
firefox $name1
Example test.conf file
- Code:
<VirtualHost *:80>
ServerAdmin root@localhost
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/VirtualHost1/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Example Hosts file:
- Code:
192.168.0.4 test.com
![-](https://2img.net/i/empty.gif)
» how to solve body onload issue on a local apache2 server with a script tag
» Setting up custom 404 error document on apache2 linux web server
» Favico For Linux Web Server Apache2
» setup apache2 and mysql server on linux
» Linux Web Server Web Dev Vote Polls PHP Script
» Setting up custom 404 error document on apache2 linux web server
» Favico For Linux Web Server Apache2
» setup apache2 and mysql server on linux
» Linux Web Server Web Dev Vote Polls PHP Script
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|