All,
So let me write out my understanding to this sheer craziness of what Apache is
clueless about. According to the Apache docs, I can define/configure Apache one
of two ways! Since the apache2.conf last 2 line read:
Code:
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
Apache will read all .conf files in the /etc/apache2/sites-enabled/ directory
but the actual files exist and are edited in the /etc/apache2/sites-available/
directory then symlinked to the site-enabled directory via the cmd
"ln -s <available-file> <enabled-file>
so I have the following <available files>
1.) _default_conf
2,) projects.conf (or projects.com.conf),
3.) seopanel.conf (from seopanel install),
4.) TBNK-SVR.conf (or TBNK-SVR.com.conf),
5.) TBotNik.conf (or TBotNik.com.conf),
6.) Webs-R-Us.conf (or Webs-R-Us.com.conf)
Notice I have tried with both the .com and without. Also notice that the
phpmyadmin is not in the list as it exists at:
/etc/apache2/conf-available/
/etc/apache2/conf-enabled/
With the second location via symlink. And I have executed the "ln -s" on all
the /sites-available/ file so their symlinks exist in /sites-enabled/ also.
The other method, again according to the Apache docs, is to define all the
vhosts in only the _default_.conf file, so I have been fighting this soooo long
that I created a directory "/Configs/Apache" for storing and editing the files
so I can implement either way using a BASH script to move things around. So
here are my files:
Single-File Implementation:
_default_.conf
Code:
# Single File VHost Config
#Default
<VirtualHost _default_:80>
ServerAdmin webmaster@localhost
ServerName localhost
ServerAlias localhost
DocumentRoot /var/www/
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
#Projects
<VirtualHost projects.com:80>
ServerAdmin admin@projects.com
ServerName www.projects.com
ServerAlias projects.com
DocumentRoot /3T/Syncs/Projects/
<Directory /3T/Syncs/Projects/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/prj_error.log
CustomLog ${APACHE_LOG_DIR}/prj_access.log combined
</VirtualHost>
#SeoPanel
<VirtualHost seoloical:80>
ServerAdmin admin@seolocal.com
DocumentRoot /var/www/html/seopanel
ServerName www.seolocal.com
ServerAlias seolocal.com
<Directory /var/www/html/seopanel/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/seop_error.log
CustomLog ${APACHE_LOG_DIR}/seop_access.log combined
</VirtualHost>
#TBNK-SVR
<VirtualHost TBNK-SVR.com:80>
ServerName www.tbnk-svr.com
ServerAlias tbnk-svr.com
ServerAdmin admin@tbnk-svr.com
DocumentRoot /3T/Syncs/
<Directory /3T/Syncs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/tbs_error.log
CustomLog ${APACHE_LOG_DIR}/tbs_access.log combined
</VirtualHost>
#TBotNik
<VirtualHost TBotNik.com:80>
ServerName www.TBotNik.com
ServerAlias tbotnik.com
ServerAdmin admin@tbotnik.com
DocumentRoot "/3T/Syncs/.../TBotNik/"
<Directory "/3T/Syncs/.../TBotNik/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/tbk_error.log
CustomLog ${APACHE_LOG_DIR}/tbk_access.log combined
</VirtualHost>
#Webs-R-Us
<VirtualHost webs-r-us:80>
ServerAdmin admin@webs-r-us.com
ServerName www.webs-r-us.com
ServerAlias webs-r-us.com
DocumentRoot "/3T/Syncs/.../Webs-R-Us/"
<Directory "/3T/Syncs/.../Webs-R-Us/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wru_error.log
CustomLog ${APACHE_LOG_DIR}/wru_access.log combined
</VirtualHost>
Multi-File Implementation:
_default_.conf
Code:
<VirtualHost _default_:80>
ServerAdmin webmaster@localhost
ServerName localhost
ServerAlias localhost
DocumentRoot /var/www/
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
</VirtualHost>
projects.conf (also projects.com.conf)
Code:
<VirtualHost projects:80>
ServerAdmin admin@projects.com
ServerName www.projects
ServerAlias projects
DocumentRoot /3T/Syncs/Projects/
<Directory /3T/Syncs/Projects/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
</Directory>
</VirtualHost>
<VirtualHost projects.com:80>
ServerAdmin admin@projects.com
ServerName www.projects.com
ServerAlias projects.com
DocumentRoot /3T/Syncs/Projects/
<Directory /3T/Syncs/Projects/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
</Directory>
</VirtualHost>
seopanel.conf (From install so not changed)
Code:
<VirtualHost seolocal:80>
ServerAdmin admin@seolocal.com
DocumentRoot /var/www/html/seopanel
ServerName www.seolocal.com
ServerAlias seolocal.com
<Directory /var/www/html/seopanel/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/seop_error.log
CustomLog ${APACHE_LOG_DIR}/seop_access.log combined
</VirtualHost>
TBNK-SVR.conf (also TBNK-SVR.com.conf)
Code:
<VirtualHost TBNK-SVR:80>
ServerName www.tbnk-svr
ServerAlias tbnk-svr
ServerAdmin admin@tbnk-svr
DocumentRoot /3T/Syncs/
<Directory /3T/Syncs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/tbs_error.log
CustomLog ${APACHE_LOG_DIR}/tbs_access.log combined
</VirtualHost>
<VirtualHost TBNK-SVR.com:80>
ServerName www.tbnk-svr.com
ServerAlias tbnk-svr.com
ServerAdmin admin@tbnk-svr.com
DocumentRoot /3T/Syncs/
<Directory /3T/Syncs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/tbs_error.log
CustomLog ${APACHE_LOG_DIR}/tbs_access.log combined
</VirtualHost>
TBotNik.conf (also TBotNik.com.conf)
Code:
<VirtualHost TBotNik.com:80>
ServerName www.TBotNik.com
ServerAlias tbotnik.com
ServerAdmin admin@tbotnik.com
DocumentRoot "/3T/Syncs/.../tbotnik/"
<Directory "/3T/Syncs/.../tbotnik/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/tbk_error.log
CustomLog ${APACHE_LOG_DIR}/tbk_access.log combined
</VirtualHost>
<VirtualHost TBotNik.com:80>
ServerName www.TBotNik.com
ServerAlias tbotnik.com
ServerAdmin admin@tbotnik.com
DocumentRoot "/3T/Syncs/.../tbotnik/"
<Directory "/3T/Syncs/.../tbotnik/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/tbk_error.log
CustomLog ${APACHE_LOG_DIR}/tbk_access.log combined
</VirtualHost>
Webs-R-Us.conf (also Webs-R-Us.com.conf)
Code:
<VirtualHost webs-r-us:80>
ServerAdmin admin@webs-r-us.com
ServerName www.webs-r-us
ServerAlias webs-r-us
DocumentRoot "/3T/Syncs/.../Webs-R-Us/"
<Directory "/3T/Syncs/.../Webs-R-Us/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wru_error.log
CustomLog ${APACHE_LOG_DIR}/wru_access.log combined
</VirtualHost>
<VirtualHost webs-r-us.com:80>
ServerAdmin admin@webs-r-us.com
ServerName www.webs-r-us.com
ServerAlias webs-r-us.com
DocumentRoot "/3T/Syncs/.../Webs-R-Us/"
<Directory "/3T/Syncs/.../Webs-R-Us/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wru_error.log
CustomLog ${APACHE_LOG_DIR}/wru_access.log combined
</VirtualHost>
Notice I changed the error log name for each so I can isolate any real
problems by the VHost.
Then I wrote this BASH script to automate the process:
Code:
#! /bin/bash
# Sciprt for setting Apache Configs
# Must run in the SUDO Mode
# CMD: bash "/3T/Scripts/Extras/set-apache.sh" [option: single, multi]
opt=$1
aav_dir="/etc/apache2/sites-available"
aen_dir="/etc/apache2/sites-enabled"
cfg_dir="/Configs/Apache"
clear
if [ -z $1 ]; then
echo "No option set!"
exit
fi
# Declare the functions first to load for execution!
function rm_cfg ( ) {
for file in `ls $1`; do
lfiv=${file: -5}
lfor=${file: -4}
if [ $lfiv = ".conf" ] || [ $lfor = ".swp" ]; then
if [ $lfor = ".swp" ]; then
nfil=".$1$file"
else
nfil="$1$file"
fi
rm -f $nfil
fi
done
} # end function rm_cfg
function cp_cfg ( ) {
for file in `ls $1`; do
subs=${file:0:2}
tail=${file:2}
if [ ${subs} = "m_" ]; then
cp "$1$file" "$2$tail"
ln -s "$2$tail" "$3$tail"
fi
done
} # end function cp_cfg
echo "Remove all files in $aav_dir and $aen_dir"
rm_cfg "$aen_dir/"
rm_cfg "$aav_dir/"
if [ $opt == 'single' ]; then
echo "Option is single!"
cp "$cfg_dir/s_default_.conf" "$aav_dir/_default_.conf"
ln -s "$aav_dir/_default_.conf" "$aen_dir/_default_.conf"
else
echo "Option is multi!"
cp_cfg "$cfg_dir/" "$aav_dir/" "$aen_dir/"
fi
#ls -al "$aav_dir"
#ls -al "$aen_dir"
echo "Restart Apache!"
bash "/3T/Scripts/Extras/ap-er-grab.sh"
Which calls this apache restart and msg trapping script:
Code:
#! /bin/bash
# Sciprt for dianosis of Apache Errors
# CMD: bash "/3T/Scripts/Extras/ap-er-grab.sh"
clear
echo "Clear the target file!"
rm -f "/3T/Syncs/Files/aper-grab.txt"
touch "/3T/Syncs/Files/aper-grab.txt"
echo "Restart Apache!"
echo "Restart Apache2" > /3T/Syncs/Files/aper-grab.txt
service apache2 restart >> /3T/Syncs/Files/aper-grab.txt
echo "Read System Errors!"
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo "Read System Errors!" >> /3T/Syncs/Files/aper-grab.txt
echo "Run systemctl status 4 Apache2" >> /3T/Syncs/Files/aper-grab.txt
systemctl status apache2.service >> /3T/Syncs/Files/aper-grab.txt
echo "Read Journal Errors!"
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo "Read Journal Errors!" >> /3T/Syncs/Files/aper-grab.txt
echo "Run journalctl 4 Apache2" >> /3T/Syncs/Files/aper-grab.txt
journalctl -xe >> /3T/Syncs/Files/aper-grab.txt
echo "Read Default Error log 1st 20 lines!"
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo "Read Default Errors!" >> /3T/Syncs/Files/aper-grab.txt
head -20 /var/log/apache2/error.log >> /3T/Syncs/Files/aper-grab.txt
echo "Read Projects Error log 1st 20 lines!"
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo "Read Projects Errors!" >> /3T/Syncs/Files/aper-grab.txt
head -20 /var/log/apache2/prj_error.log >> /3T/Syncs/Files/aper-grab.txt
echo "Read SeoPanel Error log 1st 20 lines!"
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo "Read SeoPanel Errors!" >> /3T/Syncs/Files/aper-grab.txt
head -20 /var/log/apache2/seop_error.log >> /3T/Syncs/Files/aper-grab.txt
echo "Read TBNK-SVR Error log 1st 20 lines!"
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo "Read TBNK-SVR Errors!" >> /3T/Syncs/Files/aper-grab.txt
head -20 /var/log/apache2/tbs_error.log >> /3T/Syncs/Files/aper-grab.txt
echo "Read TBotNik Error log 1st 20 lines!"
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo "Read TBotNik Errors!" >> /3T/Syncs/Files/aper-grab.txt
head -20 /var/log/apache2/tbk_error.log >> /3T/Syncs/Files/aper-grab.txt
echo "Read Webs-R-Us Error log 1st 20 lines!"
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo " " >> /3T/Syncs/Files/aper-grab.txt
echo "Read Webs-R-Us Errors!" >> /3T/Syncs/Files/aper-grab.txt
head -20 /var/log/apache2/wru_error.log >> /3T/Syncs/Files/aper-grab.txt
echo "Edit the output file!"
nano /3T/Syncs/Files/aper-grab.txt
So I have deployed the script with both the "single" and "multi" options.
Apache restarts, there are no errors, but nothing at all works. That includes
PHP from the cmd line.
Sorry I'm clueless, so help needed!