Apache: Copied files from another directory do not work - apache

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.

Related

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).

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.

Not following symbolic link after changing remote server PHP

After changing remote servers (but not the content being hosted in it), my symbolic links are no longer being followed by apache through virtual hosts.
When I go into the terminal and perform ls -alt it shows that the symlink is there and correct.
The path where the symlink is going to (and suppose to be going to is correct) and the content expected is still there.
I have performed svn switch on the root of the content that the symlink is going to so its updated to the current server.
I have checked and opened up all file permissions for the content and subdirectories
I have tried svn switch on the content that s symlinking to the shared content, but am presented with this error:
'.' appears to be part of version 1.7, please upgrade your client version.
I deleted the folder with symlink and re-checked it out through the new server, this is where the symlink doesnt work anymore.
Some of my older projects that were checked out through the old server do follow the symlink to the content with the svn re-directed to the new server.
Also my virtual host which states the option to follow symlinks has multiple places where the same symlink path is used. Each folder inside this vhost has the same substructure to it, but oddly some symlinks work, and others dont.
Any ideas on what I could try to get apache to follow the sym links?
Thanks a lot
Following symlinks is OFF by default on most Apache installs, because they're a security risk - they allow easy violation of document root "jails". if you allow symlinks, it's trivial to have something like ln -s / /site/documentroot/browse and now your entire filesystem is open for viewing by the world.
If you insist on allowing them, then you'll need
Options +FollowSymLinks
in the appropriate <directory>, <virtualhost> or .htaccess1. Relevant docs: http://httpd.apache.org/docs/current/mod/core.html#options

Apache not allowing access to sub directories

I installed Apache2, php, and mysql onto my Linux Mint machine with the hopes of continuing a website I had built. After copy and pasting all of the code I had I noticed a problem with one of my include statments:
<?php include("./dir/file1.html");
That wasn't working. Originally I thought the issue was with php but after a lot of trial and error I've concluded it's apache not allowing access to subdirectories in the /var/www/ directory.
Since I'm new to editing apache configuration files, I'm not really sure what to change to allow access to all subdirectories within /var/www/ on localhost. I've tried adding:
<Directory /var/www/*>
order allow,deny
allow from all
</Directory>
to my httpd.conf file (which was blank, which I learned had something to do with Linux Mint being Debian based) and confirmed that default in /sites-available had similar code. I'll post that if it's requested.
I'm unsure on what else I can do to get apache to allow access to subdirectories in my /var/www/ directory for localhost and none of my previous methods have worked.
UPDATE:
I believe it's an Apache issue because when trying to go to a subdirectory through the browser (like localhost/dir/), I get a 403 error. I don't have to be going to an actual webpage for that problem. Also, include statments including files in the current directory has no problem, only with subdirectories.
The Include statement above gives no errors or any other useful messages. Whatever the include statement is including is just not there. I've tried require but that gives me a 500 server error: the server may be down for maintenance (paraphrased).

apache - how to override index of /icons?

I wasn't aware of this, and it is kind of funny; when you name a directory icons in the root of your host, then if you point your browser to host.com/icons, apache does not read from that directory and shows you a listing of Public Domain Icons.
I added an icons directory to the root and placed a key.png file in that directory, yet accessing that image results in 404. I tried to find if/where this has been documented and how it could be turned off. I found nothing. Could someone provide a pointer?
P.S. I am using XAMPP 1.7.3 which basically is a WAMP and has Apache 2.2.14
Edit
Aparently lots of live servers have this turned on and index of /icons could be seen lots of places.
Open this file: %XAMPP_PATH%\apache\conf\extra\httpd-autoindex.conf
and change :
Alias /icons/ "X:/xampp/apache/icons/"
<Directory "X:/xampp/apache/icons/">
to this:
Alias /icons/ "./icons/"
<Directory "./icons/">
Restart your Apache Server.
I'd assume that you have an alias within your httpd.conf.
I'm not familiar with XAMPP's config files or their location (google suggests it's probably in \xampp\apache\conf\httpd.conf) but I'd suggest you're looking for a line like the following:
Alias /icons/ /usr/local/apache/icons/
See http://httpd.apache.org/docs/current/mod/mod_alias.html for more info.
EDIT:
According to XMAPP site, you need to check \xampp\apache\conf\httpd.conf and the extra subfolder.
I would look in either your apache config file (\xampp\apache\conf\httpd.conf) or your .htaccess files and see if there is a redirect going on.
EDIT: I think Grhm is correct in that an Alias is in your config file somewhere, per the XAMPP site:
The main configuration file for Apache. It's including other files from the subdirectory "extra".
See if there is a directory called extra in the \xampp\apache\conf\ directory and then go through the files in there and see if that Alias is present.