Issues with httpd DocumentRoot inside of Vagrant sync folder - apache

I've set up a Vagrant LAMP development environment on my Windows 8.1 machine. The guest operating system is Centos 7. I have a subfolder of my main vagrant folder called workspace which I have synced to /var/www/workspace on my guest. I also have port 80 being forwarded to the guest and httpd running with DocumentRoot of /var/www/workspace. When the folder is empty, I get the standard apache test page. Everything is good so far.
I created an index.html file in the workspace folder on my host machine in SublimeText with the following contents.
<html>
Test1
</html>
I checked this in the web browser on my host, and get the expected result
Test1
I continued to edit the index.html file, adding head and body tags and some divs:
<html>
<head>
<title>Test site</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div class="button">Test1</div>
<div class="button">Test2</div>
</body>
</html>
Then I change the text in the links and add a third div.
<html>
<head>
<title>Test site</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div class="button">Blog</div>
<div class="button">Resume</div>
<div class="button">Experiments</div>
</body>
</html>
As soon as I add the third div, my browser starts returning a previous version of the file with Test1 and Test2 as the link text. I made sure my browser cache was disabled. I checked in the Network section of the Chrome dev console to make sure that the file was coming from the webserver, which it was. I check in vi on the guest machine, and the index file contains the Blog, Resume, Experiments links. If I modify the file in vi by just adding a new line or anything, it fixes the issue. If I remove the third div, it fixes the issue. If I remove the css reference line, it fixes the issue. I have no idea where this old version is or why it's being returned when certain changes are made. My assumption is that it is a vagrant syncing issue, but I'm open to any ideas on what else might be going wrong.

I've found an answer to my problem although not an ideal one. It appears this is an issue with VirtualBox, not Vagrant. More information about this issue can be found here:
Ticket 9069
Ticket 819
There is no solution, but there is a proposed workaround to avoid this issue. The workaround is to add this to your httpd.conf:
EnableSendfile off
EnableMMAP Off

Related

Different base paths depending on Development/Production environment

I just published a Blazor app on our development server to test if everything is running fine. I set up the server so that i would have to access the app under an address like that:
serveraddress:8090/UserManagement
On my local development machine I don't need the UserManagement folder, I just access and redirect directly to my pages. My index page for example would be available at
#page "/"
on my local machine. But when I run the software on the development server, there should be an additional /UserManagement tag added to the path. I set the ASPNETCORE_ENVIRONMENT variable to "Development" on my server and tried to change the tag in the _Hosts.cshtml as follows:
<environment include="Development">
<base href="~/UserManagement" />
</environment>
<environment include="Production">
<base href="~/" />
</environment>
Unfortunately, this does not work and all the redirects go to / instead of /UserManagement/. Any idea?
Okay I think i found the solution.
First I changed the base url so that only when the Development environment variable is found, the base url /UserManagement will be used:
_Hosts.cshtml:
<environment include="Development">
<base href="/UserManagement/" />
</environment>
<environment exclude="Development">
<base href="~/" />
</environment>
Then i added this to the very beginning of the startup.cs' configure-method:
app.UsePathBase("/UserManagement");
But that alone still did not do the trick. The problem was, that I used hrefs links like that to forward to another page:
New User
With the leading slash, the UserManagement directory was not preprended. However, after removing the leading slash like this it worked and the /UserManagement/ was added.
New User

otrs 5 in shared host

I would like to install OTRS 5 in a shared hosting environment. I heard, that this is possible but not easy.
Here is what I know so far and what I did:
Webfolder: /var/www/html/
otrs-5.0.23.tar.gz is extraced to /var/www/html/cgi-bin/
Also added /var/www/html/otrs-web
Permissions are set to 755
Config.pm.dist renamed to Config.pm
Created a DB an gave the Informations to Config.pm
Home Path is set to /var/www/html/cgi-bin/
I imported the three mysql SQL Files to te OTRS DB
I renamed the Cronjobs
Links were set ln -s /var/www/html/otrs-web/skins/ /var/www/html/cgi-bin/var/httpd/htdocs/skins
ln -s /var/www/html/otrs-web/js/ /var/www/html/cgi-bin/var/httpd/htdocs/js
After this, I tried to open http://192.168.0.160/otrs-web in the browser. It gets the index.html a it tries to redirect me to http://192.168.0.160/otrs/index.pl but ends with
Not Found
The requested URL /otrs/index.pl was not found on this server.
Apache/2.4.10 (Debian) Server at 192.168.0.160 Port 80
The content of the index.html is:
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<meta http-equiv="refresh" content="0; URL=/otrs/index.pl" />
<title>OTRS Redirect</title>
</head>
<body>
</body>
</html>
<!--
index.html - redirect
Copyright (C) 2001-2017 OTRS AG, http://otrs.com/
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
-->
I have to confess, that I am not into this whole redirection stuff. I gues, this might be the problem. If someone do have an Idea or a link to a nice tutorial, I would be happy :)

Apache Tomcat Server 8.0.32 and a blue color default Favicon

I have deployed abc.war file on Apache Tomcat 8.0.32. Everything works fine except the favicon.ico. Even on index.html I have defined like :
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
It shows icon like this :
Not sure from where this icon is coming ?
EDIT:
I also tried to see via developer tools of chrome , but didn't get the info of this blue icon.As checked all images retrieved from the network.

Redict Apache Directory Index

I've got an Apache server, and I'd like to set it up such that when a directory is requested that does not have an index.html file (and thus, Apache would, by default, generate a directory listing), Apache instead redirects (ideally using HTTP code 303) to a given url.
Unless absolutely necessary, I'd like to stay away from going outside Apache (for example, by having Apache load a php script which writes the headers manually). This is an otherwise static site, and I'd like to avoid having to introduce scripting languages into the mix.
Also, note that this post doesn't solve my problem since all of the proposed solutions use external scripts.
So I figured out that by using a combination of HTML meta refreshing and JavaScript redirection, I could cover almost all browsers in use and still have a static file. So what I did was this. In the apache site config, I put a directive that told apache to first look for index.html files, and if that failed, use a site-wide /no-index.html:
<Directory /path/to/web/root>
DirectoryIndex index.html /no-index.html
</Directory>
no-index.html, then, contained the following:
<html>
<head>
<meta http-equiv="refresh" content="0; url=/">
<script type="text/javascript">
window.location = "/";
</script>
</head>
</html>
(in this example it redirects to the web root, /, but you could replace that with whatever url you wanted)
See here for an explanation of what the <meta> tag is doing.

Favicon for all the pages in my website

I've learned that the way to add favicon for a web page is to have the following lines in the page.
<link rel="SHORTCUT ICON" type="image/x-icon" href="http://mysite.com/faviconfilename.ico"/>
<link rel="icon" type="image/x-icon" href="http://mysite.com/faviconfilename.ico" />
Should i add this code in each and every page my site has?? I use Apache - tomcat clustering to serve pages. Is there any other easy way to do this?
It is usually enough to place a file called "favicon.ico" in the root of your website.
You can get rid of the unnecessary processing and traffic as well as the error log entries by using the following Apache configuration incantations:
# Don't bother looking for favicon.ico
Redirect 404 /favicon.ico
# Send custom text instead of sending the custom error page
<Location /favicon.ico>
ErrorDocument 404 "No favicon"
</Location>
Modify the apache config.
upload this file to the root directory of your website. Make sure that it is readable so that apache can read it. If you have shell access, type: "chmod +r favicon.ico".
Then edit httpd.conf and insert the following line:
"AddType image/x-icon .ico"
Your approach works when you don't have access to your apache config. In this case, if you are using any framework then you should add it to your layout/template.
Here is my method for php sites. It ensures that if you update the favicon, it will be updated immediatly when your clients visit your site:
<link rel="shortcut icon" href="favicon.ico?v=<?php echo time() ?>" />