Skip to content

Instantly share code, notes, and snippets.

@ciscoinc
Last active August 29, 2015 14:22
Show Gist options
  • Save ciscoinc/e40a186be4a4041e9888 to your computer and use it in GitHub Desktop.
Save ciscoinc/e40a186be4a4041e9888 to your computer and use it in GitHub Desktop.
Script para crear virtual host para un dominio en un servidor apache
#!/usr/bin/perl
#By Jose Pagola
$domain=$ARGV[0];
$complete_domain='www.'.$domain;
$path='/var/www/public_html/';
$document_root=$path.$domain;
$create_document_root=`mkdir -p $document_root`;
$own_folder=`chown -R www-data:www-data $document_root`;
$permissions=`chmod -R 755 $document_root`;
$file_name='index.html';
$absolute_path_file=$document_root.'/'.$file_name;
$create_index=`touch $absolute_path_file`;
$file_fill=`echo "this is "$domain > $absolute_path_file`;
$current_path='temp_host';
$create_vh=`touch /etc/apache2/sites-available/$domain`;
$create_temp=`touch temp_host.conf`;
$vh_fill=`echo "<VirtualHost *:80>
ServerAdmin webmaster\@localhost
ServerName "$domain"
ServerAlias "$complete_domain"
DocumentRoot "$document_root > temp_host.conf`;
$write_vh_temp=`cat virtual_host_default >> temp_host.conf`;
$move_temp=`mv temp_host.conf /etc/apache2/sites-available/$domain`;
$activate_host=`a2ensite $domain`;
$reload_apache=`service apache2 reload`;
$restart_apache=`service apache2 restart`;
<VirtualHost>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment