Apache httpd.conf strange behavior and virtual host setup - apache

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.

Related

Apache - only main domain's root is not working

I've created a new domain and setup a php application on the webroot. All the following requests are working perfectly.
/index.php
/info.php
/?anyting ( Note this, without index.php only query string is working )
/css/app.css
Only the domain's root is not working domian.in
I have created an virtual host for the domain. I tried giving DirectoryIndex index.php also, but still it's not working. There is no htaccess and it's a fresh server setup.
Googled whatever was possible, couldn't get any solution.
And if i hit domain.in it's serving the apache's default page.
If you have an virtual host you cant acces files outside the document root.
Maybe your html files (or others) are in a htdocs folder or something, you cant access htdocs/../

How do I find my httpd.conf file?

*Edit: Anyone who's using MAMP PRO on a Mac running Mac OS X Lion may find it helpful to know that I finally tracked down my httpd.conf file in my personal library at Application Support > appsolute > MAMP PRO > httpd.conf. The reason I couldn't find it with a normal search is that it's a hidden directory. To access it, open Finder, Choose Go > Go To Folder, then type in ~/Library After tracking it down, you may then discover that it's almost impossible to edit your httpd.conf file. ); *
This is a weird one. I'm using MAMP on a Mac and want to modify my httpd.conf file so it defaults my URL's to lower case. So I navigated to Applications > MAMP > conf > apache > httpd.conf and added this line of code:
RewriteMap tolower int:tolower
I then modified one of my .htaccess files accordingly, but nothing happened. (Yes, I restarted my servers.)
I then reopened my httpd.conf file and added this code, which I understand is supposed to display "verbose" messages in my log file:
LogLevel trace8
I then opened my log file # Application > MAMP > logs > apache_error.log. There's code associated with the web pages I most recently visited, but they're just generic messages - not "verbose" messages.
Someone who understands Apache far better than me told me this indicates that the httpd.conf file I modified isn't being used by my server or sites. In other words, there must be another httpd.conf file out there somewhere.
Sure enough, I typed httpd.conf into Apple's finder and found half a dozens files with that name. I don't know where they came from; I recently tried to install Drupal and Aqquia, so that might be where some of them originated.
Anyway, I added the code (including LogLevel trace8) to EVERY httpd.conf file, restarted my servers, and I STILL don't see any changes on my websites, and I still just see generic code in my log file.
I'm completely snowed. It looks like the httpd.conf file in my MAMP folder is out of the loop, yet the Apache log file in the same folder is being used...or can errors be written to more than one Apache log file at the same time?
If I rename the httpd.conf file in my MAMP folder and restart my servers, my sites display fine, further suggesting that this httpd.conf is outside the flow. Yet if I rename a file that sits beside it named mime.types, my web pages don't display.
Anyway, does anyone have any idea how I can figure out what's going on?
If not, then can you advise me on Plan B? If I can't find my httpd.conf file, then I'll have to abandon ship and just do it online. I've found the path to my online httpd.conf file. I don't know how to open online files, but I assume I can copy it to my computer with an ftp program, open it and modify it, then publish it online.
So here are my questions: Am I correct in understanding that I can safely add the code RewriteMap tolower int:tolower to my online httpd.conf file without affecting any of my websites UNTIL I also modify a .htaccess file(s)? And if I modify my online config file, do i have to restart the server, just as I do on my computer?
Thanks.
First, use the ps command to find the full path to the running Apache process:
$ ps ax | grep httpd
28 ?? Ss 3:01.99 /usr/sbin/httpd -D FOREGROUND
On this system, Apache is /usr/sbin/httpd.
Second, run that binary with the -V option to show its configuration. This should include the path to the config file.
$ /usr/sbin/httpd -V
...
Server compiled with....
..
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
On this system, the running copy of Apache reads its config from /private/etc/apache2/httpd.conf.

Hosting not loading pages

i am new to web hosting, but i purchased a domain from namecheap.com and i purchased web hosting from ramnode.com to host my domain, i am using centOS 32bit as my server, and i have pointed my domain to ramnode nameservers that were provided to me.
The problem i am having here is that everytime i load my website, it just says
Index Of/
cgi-bin/
even though i have placed my web page files in var/www, and var/www/html like ramnode support told me too, it still does not want to work. Any suggestions?
It all depends on how your server is setup but here are a few things to check.
What are the permission levels for your files, who owns them and what group are they in? If you don't have proper permissions set they may not show. If the wrong person owns them they may not show.
Read over your httpd.conf (centos should have it in /etc/httpd/conf) see how your server is setup. It may not have a default setup, perhaps your using a virtual host?
In a nutshell we need more information to help you out.
You should have an
.htaccess or htaccess.txt file in your WWW root, whithin that file you need the following line:
DirectoryIndex index.htm index.html index.php
That is the priority order of your index page. (Your web project needs an index page)
So in otherwords your webserver will serve the first matching file that it finds in that list.
A quick fix if you cant find the htaccess file, is just make sure you have an index.html file in your var/www
I just reset my nameservers to point to ramnode's last night and am experiencing the same issue as the OP this morning.
I previously had no FQDN for the ramnode server and simply used my /etc/hosts file locally to point to the ramnode server. Through that method, I was able to make sure everything was setup just so - apache virtualhosts, .htaccess files, apache.conf, and httpd.conf files all operating as desired.
It seems to have something to do with the installation of the cpanel, which auto-fills DNS A records with a different IP than the one I was provided. changing it to ramnode's original IP simply leads to the same cgi-bin directory index. But going going to the original ip in the browser leads to my site, as I have the apache virtualhost set for the IP.
Ramnode sets subdomain a records such as cpanel.mydomain.com all set to the same new IP and those do function, so it leads me to believe a ramnode server is capturing the trafic elsewhere and should be sending it on but isn't.
It's a bit confusing where cpanel is taking me and why redirecting to my the domain.com. A record to the original IP seems to have no effect.

wamp - www directory doesnt open new document root

I have changed default c:/wamp/www/ path to new directory c:/projectfolder/www/ in http.conf
The change has reflected, however when I click on the www directory in the wamp system tray (in windows 7), its still opening the old location c:/wamp/www/
I have restarted the service and exited wamp and relaunched and also rebooted the system but it still opens the old location.
Is this path taken from wamp settings somewhere instead of httpd.conf?
Note: Its not an issue for me except that I have to create a shortcut in explorer but I am running with another issue with flex, which I am not sure is anyway related to this.
Change the following part in the file C:\wamp\wampmanager.ini
[Menu.Left]
Type: item; Caption: "www directory"; Action: shellexecute; FileName: "c:/projectfolder/www/"; Glyph: 2
Here change the FileName to your new folder
Also change the following line in C:\wamp\scripts\config.inc.php
$wwwDir = 'c:/projectfolder/www';//To ur new project directory
If WAMP has default installation then you need to make changes into following file to change the directory of "www"
go to C:\wamp\bin\apache\Apache2.2.17\conf
Open httpd.conf file
Search for
DocumentRoot "c:/wamp/www/"
replace this line with your new directory
e.g DocumentRoot "d:/Sites/www/"
Then search for <Directory "c:/wamp/www/">
and replace with <Directory "d:/Sites/www/s">
Hope it will helps ..
Just as I had tried everything (including all the suggestions above and uninstalling and starting with a clean install), I was about to call the Exorcist. That's when it dawned on me that Virtual Hosts might be interfering with how URLs are mapped to files (a far fetch obviously, but all other possibilities had been exhausted).
Anyway, long story short, commenting out this line towards the bottom of httpd.conf did the magic for me.
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
I am not sure how this gotcha could be happening only to me. Alternatively, I don't get why this is not more prominently documented, since I expect that many, like me, are installing WAMP to have a quick LAMP environment on their windows machine. Wampserver 3.0.4 here...

File Not found - very basic web dev help

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.