File Not found - very basic web dev help - apache

I have not done any web dev before. I got my Apache server running on mac OS X, and set up a virtual host at /Users/dan/webapps. So, when I go to http://localhost/ in my browser, my index.html in the webapps folder shows up, as expected.
I then created Users/dan/webapps/temp/ folder, and put a flash app in there, let's call it "test.html", along with the required "test.swf". I restart the server. However, when i put http://localhost/temp into my browser, I get File Not Found. How do I make the browser able to go to that directory, and when it goes there, have it start test.html. I am using Safari. Thanks.

you should type: http://localhost/temp/test.html
a full path to your page,
Or you can change the name of your page from test.html to index.html and it would be loaded when you enter http://localhost/temp/, since the default DirectoryIndex is index.htm or index.html

Create a .htaccess file in Users/dan/webapps/temp/, and add the line:
DirectoryIndex test.html
This will make apache look for test.html when someone accesses the directory. Make sure permissions/ownership allows your webserver to read this file.

Related

Apache httpd.conf strange behavior and virtual host setup

I want to setup a virtual host and couldn't.
Checking better, I discovered that the server always opens the index page from the root, no matter what it is in the httpd.conf file or even in the httpd-vhosts.conf file.
As a test I deleted everything from the httpd.conf file and saved it as empty file and restarted Apache. It still opens the index.php file from the root. So how does it know the root, if there's nothing in the config file, in the first place..?
I cleared the cache with htcacheclean, but same result.
If I setup a virtual host with root in a subfolder and access it at http://site1.localhost, it doesn't open the index from the site1 subfolder, but again only the one from the root.
More than that, instead of site1 I can type anything, literally, and it wouldn't give error, it will open the same index.php file in the root.
What could be the problem..?
I figured it out.
The server was working fine. It was that when I restarted it from shortcut in Programs, after making modifications in httpd.conf and other files, it was not actually restarting, like I believed.
I restarted it from the Services, and then it worked... quite weird behavior..
Anyway, thanks for caring.

How do I find out where my root URL is being served from in Apache?

I've recently got a VPS server and it came installed with CentOS, WHM and cPanel. I'm trying to find where the physical folder location the root URL of the server IP is being served. When I go to the root IP in a browser, I get a redirect to "/cgi-sys/defaultwebpage.cgi" with "SORRY!" and some error resolve details.
The server has a web-site running under "/cPanel" and also WHM runs on ":2083".
I'm trying take control of the content served directly at the /, and replace that defaultwebpage.cgi with an index.html.
I've tried httpd -V to check where the httpd.conf, is and then spotted a <VirtualHost *> in that config file, which points to a DocumentRoot of /use/local/apache/htdocs . But if I place index.html in this folder and try to hit it via /index.html, I still get routed to that defaultwebpage.cgi. Can anyone help me understand why its rerouting and not picking up that index.html?
Thanks.
You may want to try /var/www/html, at least that's in Ubuntu
If it's not it, then try going to /etc/apache2/apache2.conf and find the DocumentRoot option.
Hope this helps!

Apache shows a directory listing instead of starting an application

when i browse in localhost/PhpMyAdmin i see the content of the directory with the title:
Index of /PhpMyAdmin
instead of starting the application.
System info:
Windows 7 professional 64bit
Apache 2.2
PHP 5.3.5.0
MySql Server 5.6
PhpMyAdmin install from phpMyAdmin-4.2.10-all-languages.zip file
Same result using both config.default.php and config.inc.php in the PhpMyAdmin directory.
Thank you in advance for your answer
In your Apache configuration, find the line for DirectoryIndex. You'll need to add index.php to the list. For example, mine looks like:
DirectoryIndex index.php index.html home.pl index.cgi
You probably don't need all of those and should only add index.php; don't just copy and paste my line, it's just given as an example.
This is the list of files that Apache looks for to run as the main page of a folder/subdirectory. If it can't find any of the listed files then it generally shows the listing of all files in that directory (which is controlled by mod_autoindex, if you're interested in learning more).

Apache: Copied files from another directory do not work

I recently set up my Apache server (2.2) with PHP (5.3) on my Oracle Linux computer. Initially, I created three files: index.html, index.php, and countries.html. I believe (do not recall 100%) that I created these files in my /var/www/html/ folder, and these files were automatically given root permissions for both owner and group. However, when I copied my index.html into my home directory (not root), I was no longer able to access the file (403 Message - Forbidden access), even after I moved it back into it's original /var/www/html/ folder and changed its permissions for owner and group back into root.
Notably, my index.php file was the default page, even though it wasn't listed in the DirectoryIndex. Furthermore, I experimented with my index.php file by copying it, deleting the original, moving the copied version back into the /var/www/html/ folder, and changing the permissions. Same result, where it didn't work. Only difference is that the php file threw an internal server error (HTTP Error 500).
I have added my countries.html file into my DirectoryIndex line, and it will now display as the default page. However, if I remove it and leave my DirectoryIndex line as it is:
DirectoryIndex index.html index.html.var
then it will default to my index.php page and output the internal server error.
Right now, I see a couple of problems:
The copied files do not work, despite having the same permissions. I believe my experiment with copying the index.php file is proof of this.
The default page, which was index.php, is not listed in the DirectoryIndex, yet it still is the default.
Any help/insight would be appreciated.
This might also happen in case when you are using old php version and in your php file there is some syntax related to new php version. As in php 5.3 we don't have short array notation but in 5.5 we have also in 5.4 i guess that also can gives internal server error.
See your php version by
php -v
and if its version 5.3 or less check your php file if contains any new things like new short array notation [].
Don't know am i talking in the same context in which you want. As i didn't understand the question very well.

Displaying homepage with Pubby / Apache Tomcat

Does anyone know how to go about displaying a custom homepage when Pubby is the root of Apache Tomcat?
My current setup is \Tomcat 6.0\webapps\ROOT\ <- Pubby folders WEB-INF and static are in this folder.
Whilst creating custom pages for e.g. localhost:8080/About is completely fine, (I just create a folder within my webapps folder called "About", and put my index.html in there), I don't how to get a custom index.html to display when I navigate to localhost:8080
I've tried sticking index.html files across my directories, but localhost:8080 won't resolve to any of them.
Thank you!
The index files for http://localhost:8080/ will be defined in $CATALINA_BASE/webapps/ROOT/WEB-INF/web.xml with defaults taken from $CATALINA_BASE/conf/web.xml
Assuming the ROOT app does not specify any welcome pages then an index.html placed at $CATALINA_BASE/webapps/ROOT/index.html should do the trick.