Author |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Sat 17 Apr '21 3:53 Post subject: Virtual Hosts Work Localhost does not |
|
|
All,
I've been fighting Apache issues for a while. Localhost shows the Word "Forbidden" but no error code. When I click on "Inspect Element" I have this code:
Code: |
<html><head><meta name="viewport" content="width=device-width"><title>http://localhost/</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="-moz-tab-size: 4"><pre id="line1"><span>Forbidden.</span></pre></body></html>
|
I see no error code so cannot look up a fix. Now I have defined 2 virtual hosts and they are working. Hope someone has had this problem so knows the fix. I wrote this up on Linux Questions at:
Code: |
https://www.linuxquestions.org/questions/linux-software-2/apache-alias-help-4175681489/page4.html#post6214546
and
https://www.linuxquestions.org/questions/linux-software-2/apache-not-sure-4175689230/
|
Also I do so much development in PHP at the cmd line and that also is not working. It seems to be a permission issue but there is no .htaccess file or anything else seeming to block anything and localhost was working, but the projects I needed for the Virtual Hosts were not, but when I got those working then localhost quit, which should not happen.
I'm open to suggestions as I having to do all PHP dev on an older slower machine as a work around.
Cheers!
TBNK |
|
Back to top |
|
DoHITB
Joined: 16 Feb 2017 Posts: 8 Location: Catalonia, Lleida
|
Posted: Sat 17 Apr '21 10:21 Post subject: |
|
|
Hi.
I had a similar problem a time ago. Try to go to /var/www/html and do sudo chmod +r your_file.
It may be that problem, I had it last week when writing a javascript file (couldn't access it until I gave permission).
Regards. |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Sat 17 Apr '21 13:26 Post subject: |
|
|
DoHITB,
That dir is already set:
chown -R $USER:$GROUP
chmod -R 775
Some suggest it should be:
chown -R www-data:users
Have tried both, no chanage!
For testing I have 5 tabs open in the browser of:
- localhost
- localhost/info.php
- localhost/test.php
- localhost/phpmyadmin/
- localhost/seopanel/
All are supposed to be working but are not!
Cheers!
TBNK |
|
Back to top |
|
DoHITB
Joined: 16 Feb 2017 Posts: 8 Location: Catalonia, Lleida
|
Posted: Sat 17 Apr '21 14:24 Post subject: |
|
|
Hello
What kind of request are you trying? Is it an AJAX call perhaps?
If so, check CORS policy |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Sat 17 Apr '21 23:40 Post subject: |
|
|
What errors do you see in the access log and the error log? |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Sun 18 Apr '21 21:46 Post subject: |
|
|
James Blond wrote: | What errors do you see in the access log and the error log? |
James Blond,
As I said: "NONE"!
But Q to you! Since the 2 virtual hosts are working and localhost is not, are different logs used for each Apache instance. I know the config file declares where the logs are, so how do I tell which I'm looking at!
Cheers!
TBNK |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Mon 26 Apr '21 23:57 Post subject: ThankS |
|
|
James Blond,
Thanks! I knew I wasn't going crazy! Thanks for the link!
So I still need "localhost", do I just give it another vhost name in the httpd.conf and then rename it in the includes directory?
Cheers
TBNK |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 27 Apr '21 0:11 Post subject: |
|
|
The default vhost can serve as localhost, since all host names called that are not specified are served by that vhost. On my local machine I have
httpd.conf
Code: |
Define SRVROOT "/Users/james/Apache24"
Define WORKROOT "/Users/james/work/"
Define PHP72RC "C:\\php72"
Define PHP73RC "C:\\php73"
Define PHP74RC "C:\\php74"
Define PHP80RC "C:\\php80"
ServerRoot "${SRVROOT}"
Listen 80
Listen 443
ServerAdmin admin@example.com
ServerName localhost:80
# .... a lot of lines
# Virtual hosts
Include conf/vhosts/*.conf
|
000_default.conf
Code: |
<VirtualHost _default_:80>
IndexOptions +XHTML
HeaderName /HEADER.html
DocumentRoot "${WORKROOT}"
<Directory "${WORKROOT}">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
CustomLog "C:\nul" common
<IfModule fcgid_module>
FcgidInitialEnv PHPRC "${PHP80RC}"
FcgidInitialEnv PATH "${PHP80RC};C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;"
FcgidInitialEnv SystemRoot "C:\\Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:\\WINDOWS\\TEMP"
FcgidInitialEnv TMP "C:\\WINDOWS\\TEMP"
FcgidInitialEnv windir "C:\\WINDOWS"
FcgidPassHeader Authorization
<Files ~ "\.php$">
Options Indexes FollowSymLinks ExecCGI
AddHandler fcgid-script .php
FcgidWrapper "C:/php80/php-cgi.exe" .php
</Files>
</IfModule>>
</VirtualHost>
|
Well the C:\nul is because I don't need logs on localhost. And the projects have each a vhost.
However: On a productive system, have an empty default vhost with only an empty index.html file. |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Tue 27 Apr '21 0:18 Post subject: |
|
|
Linux only friend, Winduhs is a curse word! over 25 years behind the "REAL COMPUTING WORLD"!
Cheers!
TBNK |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 27 Apr '21 9:49 Post subject: |
|
|
TBotNik wrote: | Linux only friend, Winduhs is a curse word! over 25 years behind the "REAL COMPUTING WORLD"!
Cheers!
TBNK |
LOL, you are on a Apache on Windows forum writing thart. I like your humor. |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Tue 27 Apr '21 19:49 Post subject: |
|
|
James Blond wrote: | TBotNik wrote: | Linux only friend, Winduhs is a curse word! over 25 years behind the "REAL COMPUTING WORLD"!
Cheers!
TBNK |
LOL, you are on a Apache on Windows forum writing thart. I like your humor. |
James,
Mine does not say "for Windows: just Apache! Here's the forum index text:
Apache Forum Index -> Apache
Nothing mentions the curse word! He he! Remember Apache was made for Unix/Linux but realize WAMP server makes it possible elsewhere. There are even versions for IBM midrange and mainframe machines!
Cheers!
TBNK |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Sat 01 May '21 17:26 Post subject: Which files? |
|
|
James Blond,
Just like all the other dumbshit HOWTOs the howto in your link does not correctly address the problem, because they "assume" you know exactly which file(s) you need to modify and how!
So to clarify, I posted the 3 files Apache uses in it's configuration at:
https://pastebin.com/JrjxTAud
Then hopefully you can let me know which file(s) must be modified and how. The examples for -default- look good but where do I enter/modify and for my vhosts I have .conf files in /etc/apache2/sites-available/ for each and what do I need there to get default/localhost to read again.
Files I have there are:
1.) 000-default.conf,
2.) projects.com.conf,
3.) seopanel.conf,
4.) TBNK-SVR.com.conf,
5.) TBotNik.com,conf,
6.) Webs-R-Us.com.conf
Since phpmyadmin and seopanel do not work, what am I missing or needing here for them to work again? Assuming a copy of phpmyadmin.conf is needed and must point to the right listener port, which makes me ask, should I use port 8080 for both seopanel and phpmyadmin?
Oh do I need to post the 6 listed files and the phpmyadmin.conf as well?
Cheers!
TBNK
PS
Oh currently the phpmyadmin.conf resides in /etc/apache2/conf-available/
Where do I find the right log to show which or if all these config files are read or do I need to create and link .html files showing on the browser or cmd line to let me know they actually got read in?
TBNK
Last edited by TBotNik on Sat 01 May '21 20:33; edited 1 time in total |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Sat 01 May '21 17:31 Post subject: Why! |
|
|
James,
The reason I sometimes delay, is I own 20 companies and do this dataroom maintenance only when time allows, so apologize for delays due to ultra business!
Cheers!
TBNK |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Mon 03 May '21 23:18 Post subject: |
|
|
The default vhost needs the _default_ as I posted in my example above.
Quote: | Since phpmyadmin and seopanel do not work |
Is it not reachable? PHP is not executed? Other error?
Why port 8080? It is recommended to use https over port 443.
I wonder why you don't use the /etc/apache2/site-availabe/ and You need to enable them via a2ensite or create a symlink yourself to /etc/apache2/sites-enabled/ |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Tue 11 May '21 18:30 Post subject: |
|
|
James,
Let me lay out what I see as the chain of logic in the Apache config.
According to the last 2 lines of:
/etc/apache2/apache2.conf
they include so only read:
/etc/apache2/conf-enabled/*.conf
/etc/apache2/sites-enabled/*.conf
so from what you are saying, I must do the following:
1.) Rename sites-available/000-default.conf to .bak
2.) Delete all *.conf from sites-enabled,
3.) Create the *.conf files, including _default_ in
/sites-available/,
4.) Run ln -s *.conf from sites-available to
sites-enabled,
Then restart apache.
Do I have the right logic?
Cheers!
TBNK |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 11 May '21 19:33 Post subject: |
|
|
Yes that is about it.
I recommend to read the documentation of a2ensite |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Wed 12 May '21 17:46 Post subject: Good |
|
|
James Blond wrote: | Yes that is about it.
I recommend to read the documentation of a2ensite |
James,
Thanks! See that is the logic and info missing in all the Apache HOWTO docs, that leave any non-guru guessing and not sure howto proceed.
Cheers!
TBNK |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 12 May '21 21:44 Post subject: Re: Good |
|
|
TBotNik wrote: |
See that is the logic and info missing in all the Apache HOWTO docs |
Well that is not the default / vanilla apache behavior. It is Linux distribution behavior. I don't recall which distro started that to be able to enable and disable vhosts via an external program. And that is why it isn't in the official documentation, but in the distros' documentation. |
|
Back to top |
|
TBotNik
Joined: 06 Apr 2021 Posts: 13 Location: USA, Greenville
|
Posted: Tue 18 May '21 20:43 Post subject: Progress |
|
|
James/All,
Well I've made some progress but not there yet.
Here is my _default_.conf file:
Code: |
<VirtualHost localhost: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>
|
Localhost now comes up and shows the correct directory, but will not allow any of the subdirectories to open. Guessing it is the "AllowOverride None" line effecting that.
The other vhosts do not come up, but the Apache error log, which was blank before is now 54 pages of errors and have not figured out what any of those are yet.
Cheers!
TBNK |
|
Back to top |
|