Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
1. Have you been looking at the logs in /var/log/httpd to see what they might tell you? Properly set up there should be separate logs for each aliased web site. Reading the logs should educate you on what is actually happening.
2. Have you tried disabling the virtual hosts (aliases) and confirmed that everything with the main host web pages is working correctly?
Once that is confirmed then
3. Enable one of the aliases and make certain it is properly configured and serving the right pages, including that it reaches the proper data and returns the proper identification to the asking page.
finally,
4. Once you have worked out the issues with one of the aliases you will have an idea of what to do with the second aliased web pages.
Every task needs completed one step at a time and task 1 is getting the main server site fully functional. Tasks need completed one at a time in sequence as well
computersavvy,
I'm getting 0 (zero) errors in the error logs since I cleared the errors that were showing external to the error logs, when Apache was not starting.
I'm attaching in all the files I think are pertainent:
Quote:
File /etc/fstab: Autoloads the 3T drive.
***********************************************************************
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
I came here from the other thread you opened (and found I had been here before).
First, please use [code]...[/code] instead of [quote]...[/quote] to format code. Your config files are very hard to read right now.
I understand that this is your problem: You set up several name-based virtual hosts such as projects.com and TBNK-SVR.com, and when you access them from your web browser, you always get the default index.html file rather than the expected index file in the virtual server's document root. Correct?
Early observations:
If you are running Apache 2.4, you should use new authorization clauses (although the old ones still work).
There are two VirtualHost definitions that match projects.com. I don't know how Apache handles that.
The VirtualHost definition in the TBNK-SVR.com.conf config file has no ServerName clause.
The trailing slash in the end clause </Directory/> causes an error in my version of Apache (2.4.37 running on Centos 8).
Suggestions:
I would temporarily do away with the complexities of the TBNK-SVR.com.conf and projects.com.conf files and only use 000-default.conf for troubleshooting. I would also configure separate log files for each virtual host, so that you see which VirtualHost clauses the server uses.
Last edited by berndbausch; 01-03-2021 at 05:44 AM.
Reason: Added text on new authorization clauses
In addition to that, the OP has an unpleasant habit of bumping their own threads after long periods, instead of taking to heart & putting into practice what was suggested earlier.
The gurus on the #httpd channel at irc.freenode.net point me to all the Apache docs but I cannot find a single item/article on defining a virtual host outside of /var/www and 100% of my websites and projects are on my 2nd 3TB HD, defined in fstab as /3T/ to autoload on bootup.
I know it is possible because 100% of hosting servers at the hosting houses use typically over 6 drives including RAID arrays, and have most of the accounts on these extra drives.
Sure wish I could find these answers! All help appreciated!
TBNK
The docs are not "on your system do this", but require you to read and understand the concept then make changes in the given examples so they apply to your specific system.
For security apache normally prevents access to any location outside the /var/www directory tree. If you mount the 3T volume at some location under /var/www (such as /var/www/html/3T) then the web server can be given access. by proper configuration of ServerName, DocumentRoot, Listen, and the appropriate Directory sections within the config files.
For ease of management each alias config file should be in /etc/apache2/conf-includes.d (or whereever the "include dirname" statement at the very end of the main /etc/apache2/apache2.conf file points). Putting everything in one file risks messing everything up with a change meant for one of the aliases.
I understand that this is your problem: You set up several name-based virtual hosts such as projects.com and TBNK-SVR.com, and when you access them from your web browser, you always get the default index.html file rather than the expected index file in the virtual server's document root. Correct?
Yes Correct!
Quote:
Again from you:
The VirtualHost definition in the TBNK-SVR.com.conf config file has no ServerName clause.
The trailing slash in the end clause </Directory/> causes an error in my version of Apache
Thanks! Had not realized I forgot both ServerName and ServerAlias in that file.
I was getting errors on my system that made me put in the trailing slash! Funny how different Apache is from Linux flavor to flavor!
So if I change my fstab definition for my 3TB drive from "/3T" to "/var/www/3T" or "/var/www/html/3T" then my problems should end?
Never thought of that! Had always used aliases and had always used those outside of /var/www, so was perplexed when Apache was not seeing the 3TB drive.
Well tried that and can't work as everything but Apache is looking for /3T. Guessing that maybe a symlink to put the projects dir under /var/www might work.
Well tried that and can't work as everything but Apache is looking for /3T. Guessing that maybe a symlink to put the projects dir under /var/www might work.
What do you think?
Cheers!
TBNK
This is why you do not change the main config file after it is properly working and put those definitions for the aliases in separate .conf files in the included directory.
Your version of apache is much older than mine but I have these lines as the vary last lines in the main httpd.conf file.(bolding is mine). Yours will have something similar and they point to a directory on the same level as the conf directory. For me that is /etc/httpd/conf and /etc/httpd/conf.d.
Code:
# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
The reason for that is the main .conf file (for me /etc/httpd/conf/httpd.conf) is where you have the primary site config and it seldom gets changed. Once you have it working then the alias configs don't interfere. It is easy to make an error if you are trying to do it all in one file (as you currently are) and mess things up as you just did.
When you add an alias you put the conf file for it in (for me) /etc/httpd/conf.d. As you can see that config is loaded after all the main configs and that way something you put there does not screw up the main config. It adds additional config that is specialized for the alias only.
Last edited by computersavvy; 01-07-2021 at 07:24 PM.
When I have the last line in my apache2.conf file:
Code:
#IncludeOptional sites-enabled/*.conf
commented out I run error free, but the virtual hosts are declared in that directory, so when I remove the comment"
Code:
IncludeOptional sites-enabled/*.conf
I get all the following errors from:
Code:
systemctl status apache2.service
journalctl -xe
Errors:
***********************************************************************
Exceeded text allowance here so moved to PB at: https://pastebin.com/Tysnaxgw
***********************************************************************
I see no errors from the projects.com virtual host and all errors appear to be from the TBNK-SVR virtual host, but being so many, don't know where to start, but going to rename that .conf file and see where I'm at!
So renamed TBNK-SVR.com.conf to TBNK-SVR.com.bak and restarted Apache which ran error free, but still the projects.com is pointing to the localhost index.html page. If I can just fix that, I should know how to resolve the TBNK-SVR.com issues.
So since projects.com was error free, copied projects.com.conf to TBNK-SVR.com.conf, edited the DocRoot and <Directory> entries, restarted Apache and now both error free, but still pointing to the localhost index.html file.
When I have the last line in my apache2.conf file:
Code:
#IncludeOptional sites-enabled/*.conf
commented out I run error free, but the virtual hosts are declared in that directory, so when I remove the comment"
So that tells you one or more of the .conf files in that directory have errors.
Rename all but one of them to something else, such as alias1.conf.save so apache will ignore them, then fix the problems in that remaining one .conf file. Then move on to the next and do the same. One step at a time. Trying to do more than one at a time leaves you wondering which is the error.
You need to first address the directory declaration that tells the server where the home for projects.com is located.
You also MUST have a discrete IP address and hostname assigned for each host alias as well as having the .conf file declare the host name and address to listen on for connections. If the server cannot identify the host alias it is listening for it will only serve the primary pages.
The errors you posted for apache explicitly give you the file and line number for the errors and the required fix. For example
Code:
Jan 12 12:12:41 TBNK-SVR apachectl[2391]: apache2: Syntax error on line 52 of /etc/apache2/apache2.conf: Syntax error on line 7 of /etc/apache2/sites-enabled/000-default.conf: Expected </Directory/> but saw </Directory>
Jan 12 12:12:41 TBNK-SVR apachectl[2391]: Action 'start' failed.
Jan 12 12:12:41 TBNK-SVR apachectl[2391]: The Apache error log may have more information.
It also tells you the apache log may have more info. That log should be under /var/log.
Then
Code:
Jan 12 00:09:39 TBNK-SVR apachectl[26496]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.102. Set the 'ServerName' directive globally to suppress this message
AND
Jan 12 11:27:38 TBNK-SVR apachectl[1464]: apache2: Syntax error on line 52 of /etc/apache2/apache2.conf: Syntax error on line 13 of /etc/apache2/sites-enabled/000-default.conf: Expected </Directory> but saw </Directory/>
AND
Jan 12 11:27:41 TBNK-SVR apachectl[1476]: apache2: Syntax error on line 52 of /etc/apache2/apache2.conf: Syntax error on line 13 of /etc/apache2/sites-enabled/000-default.conf: Expected </Directory> but saw </Directory/>
Do you see the common theme of those errors. They are telling you exactly what to fix.
Last edited by computersavvy; 01-12-2021 at 06:43 PM.
Later ran into more errors, but now getting more of the concept and so was able to work off those errors and now error free, but the 2 virtual hosts are still pointing the localhost (/var/www) index.html file, though I created unique index.html files for each docroot.
Oh yes: Half of the problem with me was not knowing what I was reading or seeing with the error reports, so when I finally got that straight in my mind, the debugging got much easier!
So the Q remains: How do I actually get these to point to the right directories?
Yes I understand that the hosting apps like "Control Panel" do this automatically, but I don't have those apps installed. Thanks!
So now, having the unique index.html files is good. The .conf file for that alias has to point to that exact directory path as the root for that aliased server.
You have not said what you have done as far as making certain a connection to that aliased server knows it receives a connection that should be sent to that alias instead of the main server.
I have mentioned repeatedly that in order for the server to know a connection should be sent to the alias it needs both a server name FQDN and IP in the request.
For example the host requesting the info should address request to the main site as http://host.domain and requests to the alias should go to http://alias.domain.
The receiving server should then be able to identify which directory path is the root for the requested data. That is also set up in the *.conf file for each site.
The network config needs to have for example, 192.168.0.111 for the main server and 192.168.0.112 for the alias with either dns or the /etc/hosts file tying the IP to the FQDN for each server.
The appropriate *.conf file then sets the listen to the proper IP and the ServerName to the FQDN for the alias.
All this is needed for the apache server to be able to properly direct the incoming requests.
(Note: Although the different IPs are not 100% required, config is much easier with each alias having its own IP.)
Last edited by computersavvy; 01-13-2021 at 10:43 AM.
Since I'm still mostly confused, do you have examples, so I can try to understand?
Oh! Neither phpmyadmin nor php on cmd line were working, so I re-installed phpmyadmin, but it is still not working, but php cmd line started working after that. Pretty important as I do over 90% of my development in either BASH or PHP, mostly PHP.
I think somehow that phpmyadmin is not properly loading it's .conf file, so tried finding an old backup copy and moved it to /etc/apache2/conf-available, since it was missing, but that did not fix it, so still trying to figure why it is not working.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.