My goal: Run Apache on Ubuntu. Use it to debug web sites before I put the HTML on shared hosting.
I hope: Every time Firefox runs, it will render a web site the same.
I get: Firefox doesn't reliably render my simple web site.
I'm calling my simple web site win.com. My test URLs are each of the four win.com URLs listed in the hosts file listing below.
Example: I start Firefox in Ubuntu. My test URL was active during shutdown; Firefox remembers it and processes it. One of three results occurs:
- My web site paints correctly.
- Firefox tells me: "Unable to connect | An error occurred during a connection to localhost."
- Firefox tells me: "Not Found | The requested URL was not found on this server."
I close Firefox. I start Firefox. One of the three above results occurs. If this request for rendering is within a Firefox session in which another request has occurred, the two results are the same. Refresh has the same result.
Maybe the problem is my computing stack. I'm using a Win10 computer. On it, I run VMWare Workstation 16 Player. In it, I run Ubuntu. All three are current.
I assess risk from the web site as low.
It's 56 lines of simple and raw HTML with two images. It has run flawlessly in a shared hosting environment for a couple of years without modification.
I have a copy of the site in the Windows environment. The site works reliably in the Windows Firefox using a URL of the form file:///C/.../index.html.
I haven't done much with the similar URL in the Ubuntu environment (file:///var/www/html/win.com/index.html). For this write-up, I tried it several times with identical results.
I no longer have access to a shared hosting environment.
The Ubuntu host file (/etc/hosts), in relevant detail, is
127.0.0.1 localhost
127.0.0.1 https://localhost
127.0.0.1 win.com
127.0.0.1 https://win.com
127.0.0.1 localhost/win.com
127.0.0.1 https://localhost/win.com
I inform Apache about the site via /etc/apache2/sites-enabled/win.com.conf:
<VirtualHost *:80>
ServerAdmin ewin@twc.com
DocumentRoot /var/www/html
ServerName win.com
ServerAlias *.win.com
DirectoryIndex index.html
CustomLog ${APACHE_LOG_DIR}/access-win.com.log combined
ErrorLog ${APACHE_LOG_DIR}/error-win.com.log
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost :443>
ServerAdmin ewin@twc.com
DocumentRoot /var/www/html
ServerName win.com
ServerAlias .win.com
DirectoryIndex index.html
CustomLog ${APACHE_LOG_DIR}/access-win.com.log combined
ErrorLog ${APACHE_LOG_DIR}/error-win.com.log
<Directory /var/www/html/win.com/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/self-signed-win.com.crt
SSLCertificateKeyFile /etc/ssl/private/self-signed-win.com.key
</VirtualHost>
I regularly monitor folder /var/log/apache2/ (APACHE_LOG_DIR). Files access.log, error.log, access-win.com.log, and error-win.com.log are regularly zero-length.
This question is as specific as I know to make it. If I were in a group of programmers, I would seek help among them with less effort than posing this question. I'm not in a group.
I've looked for related questions here. None found.
"This site can't be reached" when using virtual host is very similar, but I'm not making the mistake fixed there.
https://askubuntu.com/a/1373651 offered some useful tweaks to my conf file.
I am stronger in Windows than in Ubuntu or Apache. This exercise is helping me learn the latter two.
I read well. If you know where the answer is, please feel free to point me to that location and I'll happily find the answer there. Maybe limit the breadth of searching I need to do by giving me a search term or subject area!
I'm not getting help from documentation because I don't know the nature of the error enough to read about it.
If this question is inappropriate for this site, I'm happy to remove the question on request with no (other) questions asked.
I'll appreciate all help offered. I won't resent anyone skipping this question.
/etc/hosts
definition. If you do not have corresponding IPv6 entries for each of the IPv4 records, weirdness and overall sluggish lookups can occur. Add some::1
records (and ditch the lines containing the protocol, as it’s irrelevant) and you may be golden – matigo Oct 25 '22 at 23:27