PHP Classes

File: bash_create_apache_vhost.sh

Recommend this page to a friend!
  Classes of ask sa sa   PHP Artificial Intelligence Example Code Generated by OpenAI   bash_create_apache_vhost.sh   Download  
File: bash_create_apache_vhost.sh
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Artificial Intelligence Example Code Generated by OpenAI
OpenAI-generated code in PHP and other languages
Author: By
Last change:
Date: 1 year ago
Size: 655 bytes
 

Contents

Class file image Download
#!/bin/bash # Check if the script was run with the required number of arguments if [ "$#" -ne 2 ]; then echo "Usage: configure-vhost SERVER_NAME DOCUMENT_ROOT" exit 1 fi server_name=$1 document_root=$2 # Create the configuration file for the vhost config_file="/etc/apache2/sites-available/$server_name.conf" cat > $config_file <<EOF <VirtualHost *:80> ServerName $server_name DocumentRoot $document_root <Directory $document_root> AllowOverride All Require all granted </Directory> </VirtualHost> EOF # Enable the vhost a2ensite $server_name.conf # Reload Apache to apply the changes systemctl reload apache2