I am running an Apache web server on a machine running Centos.
THE PROBLEM:
When I run the server, everything works fine and I can see the welcome page. The problem occurs when I try to put in an index.html file I previously created into the /var/www/html directory. When I do this I get the error: Forbidden you do not have permission to access index.html on this server. The weird part is I created an index.html file as root in this directory and it works. It was just a simple test html file:
<!DOCTYPE html>
<html>
<head>
<h1>Hello World</h1>
</head>
</html>
This works. So I tried copying the html text from the original index.html to the one I specifically created in the /var/www/html directory and that works. The only problem here is now I have to create lots of new files in the html folder and copy the contents of the old files into the new ones. Also, how would I get images to work? And Hence, my question. So what is the difference between moving files to a directory and creating them there?
Note
I know I have set the server up correctly because I am able to access it from another computer so I don't think there is an error with the httpd.conf file. Also, I am not using a .htaccess file. The permissions on each file is the same, only one works and one doesn't. The permissions I have tried are -rwxr--r-- and -rwxrw-rw- and -rwxr-xr-x. I have also changed the owner of the files to be the same. I have tried changing the owner to apache and to root. No luck.
Thanks for the help
Moving files retains the SELinux file context assigned to the file when it was created in its original location. Copying it recreates the file anew in the new location, giving it the appropriate file context for that location.
The appropriate file context can be restored on a directory and all files contained within by running restorecon against it. See the restorecon(8) man page for details.
Related
I have a website I am trying to host, but for whatever reason, apache2 is refusing to serve the css file I have for my website. I have not change any settings and everything is completely default. I installed apache in the past 2 weeks so everything is clean and fresh.
All I did was copy all the files generated by jekyll from the _site folder and put them into /var/www/html on my server. now, when I go to my website, I can see all the content and the html loads correctly. The links work, images work. but there is no css styling available.
Because the default settings on apache arent that good, i can browse the folder contents. for example, my css file is store in /var/www/html/assets/css/style.css. So, when I access the website by going to https://mywebsite.com/assets/css, I can see the file structure and apache shows that I have a css file in there. but, when I try and click on that file, I get a
Not Found.
The requested URL was not found on this server.
----
Apache/2.4.52 (Ubuntu) Server at xxxx.com Port 443
All other files can be browsed in the folder structure and every file appears to be present, its just the pesky css file that will not load.
I have my domain pointing at a ubuntu server hosted by amazon ws, and I have my index.html file that gets loaded when someone makes a request to my domain, in the same folder of that index.html file I have another file, and I would like to make it possible to download it from my website. How can I achieve that? I tried with an iframe tag, and giving it src="./myfile.jpg" but the server tries to look for it at www.mydomain.com/myfile.jpg and it can't find it there. Can anyone give me any suggestions?
Btw my files are inside /var/www/html folder, which from what I understood is the default folder for public files on ubuntu.
I'm new to creating webpages, so perhaps this is really easy and I just can't see it. I have a HTML/CSS template that I am modifying for a new site. When I check the index.html file locally (in Dreamweaver or in browsers) it appears correct. When I uploaded them to the server then the website does not load the images and it appears that the styles.css file is not loading correctly. I have attached a few screenshots to get the ball rolling. As always thanks for your assistance.
Desired Output:
Current Output:
This is likely (later confirmed by asker in comment) a file and directory access right problem.
This can be verified by checking the access logs of the http server.
The solution is to update the ownership and permissions of any problem files so that the http server has rights to them. In this case, it is probably the easiest to examine the permissions of the index.html file and related folders and apply the same permission to the problematic files/folders.
I have static HTML pages. Using the Apache server (through XAMPP) I used to put my HTML files in the htdocs folder and they would be accessible through the localhost URL.
I'm not sure how to do this with Websphere Liberty server. let's say I have the following HellWorld HTML example in index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HellWorld</title>
</head>
<body>
<p>HellWorld</p>
</body>
</html>
How can I get this HTML page to show in the browser through Liberty?
The minimum folder structure needed is the following
+ SampleHTMLSite.war
- index.html
To create the .war file just zip your index.html file and then change the extention of the zipped folder from .zip to .war
If you are running Liberty sever in foreground through server run command, as soon as you put this website in Liberty's dropins folder (usually located here: ...\wlp\usr\servers\YourServerName\dropins) you will get something like the following update:
[AUDIT ] CWWKT0016I: Web application available (default_host):
http://localhost:9080/SampleHTMLSite/
[AUDIT ] CWWKZ0001I: Application SampleHTMLSite started in 0.317 seconds.
If you go to http://localhost:9080/SampleHTMLSite/index.html you should be able to see your HelloWorld HTML page.
If you get the following error:
Error 404: java.io.FileNotFoundException: SRVE0190E: File not found: /index.html
Open your SampleHTMLSite.war with any unzipping program (example: 7-Zip) and be sure that the index.html is showing directly inside the .war file and not inside another folder. There is a chance that you have the following structure:
+ SampleHTMLSite.war
+ SampleHTMLSite
- index.html
This would mean to access the index.html you need the following URL:
http://localhost:9080/SampleHTMLSite/SampleHTMLSite/index.html
In bigger project and where you need to use Java apps your folder structure might need to include other folders and files. If you are intrested to know more about this, check the following article:
Handling Static Content in WebSphere Application Server
The simplest:
In dropins folder (\wlp\usr\servers\serverName\dropins), create folder myApp.war
put your index.html in the myApp.war
If your server is configured for polled monitoring you are done. Otherwise restart the server (if was started).
It will be available via http://host:port/myApp/index.html.
I know similar questions have been asked but cannot see why our external css link doesn't work on Linux. The folder structure on both Windows and Linux is:
/
/static
/css
style.css
/img
/js
/html
index.html
The index.html links to style.css with:
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
It works on Windows but fails on Linux with a 404. This would imply that the /static folder and sub-folders don't have the correct permission but they actually have identical permissions as the /html folder. If all the /static content is placed in the /html folder then it works.
Has anyone come across a similar situation or know what the problem is?
Are you using mod_rewrite ? It has to be a server config issue. Make sure it is configured right
To be sure the path is ok, open index.html on the browser and check the path of css file from the page source there.
The problem can probably be permission on the css file.
The user apache ir running on must be able to read the file, otherwhise it will fail to load it
you can try running:
chmod a+r style.css
to add read permission to everyone on that file, or:
chown [user]:[group] style.css
to change the owner of the file to the user and group apache is using.
You can also check which user apache is running on in this question Finding out what user Apache is running as?
By default it usually is apache user and apache group.