#!/bin/bash ##### This section will check to see if httpd looks in vhost.d for vhost configuration files. If it doesn't, we add the include line #### if grep -Fxq "vhost.d" /etc/httpd/conf/httpd.conf then # It's there! Do nothing. it's good to go! else # OK, we need to add it. No biggie. echo "Include vhost.d/*.conf" >> /etc/httpd/conf/httpd.conf fi ############# This section is the actual vhost data, that goes in the /etc/httpd/vhost.d/www.zyxyellowxyz.com.conf file DATA=" ServerName www.zyxyellowxyz.com ServerAlias www.www.zyxyellowxyz.com #### This is where you put your files for that domain: /var/www/vhosts/www.zyxyellowxyz.com DocumentRoot /var/www/vhosts/www.zyxyellowxyz.com # This section sets directives for the directory. # -Indexes <-- That blocks index listings on folders that don't have a default file (index.php/index.html/default.html/etc) # FollowSymLinks <-- This will treat symlinks like they should be treated in linux: as folders/files in the folder the symlink resides # MultiViews <--It's easier for you to read this: http://httpd.apache.org/docs/2.0/content-negotiation.html#multiviews Options -Indexes FollowSymLinks MultiViews # AllowOverride All <-- This is required for Apache HTTPD server to read .htaccess files. It says that you can have a per-folder override for apache directives AllowOverride All ## Everything to see here. Just the log files. Good to use for troubleshooting errors. CustomLog /var/log/httpd/www.zyxyellowxyz.com-access.log combined ErrorLog /var/log/httpd/www.zyxyellowxyz.com-error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn ####################THIS SECTION COMMENTED OUT BY DEFAULT. IT IS FOR HTTPS ONLY. USE ONLY IF YOU NEED, AND YOU UNDERSTAND WHAT YOU ARE DOING! #################### Documentation for usage can be found here: http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html # # ServerName www.zyxyellowxyz.com # DocumentRoot var/www/vhosts/www.zyxyellowxyz.com # # Options Indexes FollowSymLinks MultiViews # AllowOverride All # # # CustomLog /var/log/httpd/www.zyxyellowxyz.com-ssl-access.log combined # ErrorLog /var/log/httpd/www.zyxyellowxyz.com-ssl-error.log # # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. # LogLevel warn # # SSLEngine on # SSLCertificateFile /etc/pki/tls/certs/localhost.crt # SSLCertificateKeyFile /etc/pki/tls/private/localhost.key # # # SSLOptions +StdEnvVars # # # BrowserMatch \"MSIE [2-6]\" \ # nokeepalive ssl-unclean-shutdown \ # downgrade-1.0 force-response-1.0 # BrowserMatch \"MSIE [17-9]\" ssl-unclean-shutdown #" ################## OK, this next section will make the required directories, and if that succeeds, it changes the directory to apache. if THAT is good, then it will echo the data to the vhost config file. #################### If THAT all goes well, it restarts httpd, and your vhosts should be up and running! mkdir -p /var/www/vhost/www.zyxyellowxyz.com && chown apache:apache /var/www/vhost/www.zyxyellowxyz.com &&echo "$DATA" > /etc/httpd/vhost.d/www.zyxyellowxyz.com.conf && service httpd restart