PHPMyAdmin and Security on XAMPP not working after changing DocumentRoot in httpd.conf - apache

SUMMARY
I am unable to run localhost/phpadmin and localhost/security after changing the DirectoryRoot in XAMPP httpd.conf. This leads to two questions.
If I am using XAMPP on Windows, is there any way to run PHP files outside the localhost directory that I have set in the httpd.conf?
If "no", then how does one run files such as phpmyadmin or the security module on the local machine, if the phpmyadmin files reside in the c:\xampp directory but the DocumentRoot path in httpd.conf points to a different directory?
More detail is set out below.
BACKGROUND INFO
My installation is as follows.
Operating system: Windows 7
Version of XAMPP: xampp-portable-lite-win32-1.8.1-VC9.7z
Installation directory: c:\xampp-portable
Code files saved in: d:\dropbox\websites_user1\...
I then modified the httpd.conf as follows:
Line 191: DocumentRoot "D:/Dropbox/websites_user1"
Line 222: <Directory "D:/Dropbox/websites_user1">
The default httpd-xampp.conf configuration is unchanged - e.g.:
Line 99: Alias /phpmyadmin "/xampp-portable/phpMyAdmin/"
Line 100: <Directory "/xampp-portable/phpMyAdmin">
Line 121: <LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
THE PROBLEM
After changing the directory root in httpd.conf as above, I can run php files successfully from local host - e.g. localhost/project01/demo.php.
However, I now can't run PHP files from any location other than those located in the new localhost directory (i.e. d:/Dropbox/websites_user1/..). This means that I can no longer run PHP files in locations such c:\xampp\PHPMyAdmin or C:\xampp-portable\security\htdocs\security.php.
Also, the configuration for the PHPMyAdmin and Security are clearly no longer correct. For instance, if I enter "localhost/phpmyadmin" or "localhost/security", I get a "page not found" error.
This leads to two sets of questions (as summarised at the start of this question).
Is the directory configured as the localhost the ONLY location from which PHP files can be run? Is it possible to configure PHP to run from any location on my C or D drives?
If not, how do I run files such as those in PHPMyAdmin or security.php or any of the innumerable files in the other xampp directories? Do I need to copy and paste the phpmyadmin folder into my localhost folder at D:/Dropbox/websites_user1? Or into each of the individual website folders beneath that? If yes, do I then need to reconfigure any files such as http-xampp.conf?
I am relatively new to PHP and new to XAMPP. Everything was working perfectly until I ran into this ... and now I'm completely stuck if I can't use PHPMyAdmin, and can't even use the Security module to set my passwords.
Will be very grateful for advice!!

I believe you cant run anything higher than your root as a security feature. Imagine some remote person knowing your IP address and accessing all your files above your document root.

Related

PHPmyadmin and Wordpress directories access denied

Running wordpress locally on a centOS 7 server running the latest apache, PHPmyadmin and mariadb-server.
IP/wordpress and IP/phpmyadmin on systems within the local network yields "403 forbidden" "you dont have permission to access (directory) on this server."
How can I fix this to allow the website to be seen on the public internet?
Could be a lot of things.
In your main Apache configuration file (e.g. /etc/httpd/conf/httpd.conf on Arch Linux), confirm your DocumentRoot path. The files you want to serve must reside there, or in sub-directories from there (If not, you might want to use an Alias to specify another path). Since you call IP/wordpress and IP/phpmyadmin, then you probably have directories called wordpress and phpmyadmin under your DocumentRoot path.
You also want to check the Directory groups in your Apache configuration file. Under those, the main culprit would be the Require directive set to all denied or something else too much restrictive like ip your_ip.
Finally, PHP can restrict path access with the open_basedir directive. Look for it in your php configuration file (e.g. /etc/php/php.ini on Arch Linux). If the line is commented, you're fine. But if a path is specified, your wordpress and phpmyadmin files must reside there.
Depending on your setup, any directive mentioned above could be in another Apache configuration file (e.g. /etc/httpd/conf/extra/* on Arch Linux).
Take a look at Apache and PHP online documentation for information about those directives.
Probably there is an issue with your directory privileges.
Use the follwing command to check it:
cd your_site_directory
ls -l
You can have a look to have a better understanding on directory privileges here.
As mentioned here apache runs under "apache" user.
Have a look at this post here to fix the issue.
All files should belong at least to apache group. To do it you can use
cd your_site_directory
chgrp -R apache ./*

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.

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

MAMP just ONE virtual host not working

I wanted to start a (my first) wordpress project on my mac.
I run apache with MAMP, and wanted to make another (I allready have a few) virtual host for this particular project.
I added the host to my httpd.conf and etc/hosts file as i've done many times before.
When I browse to the url i've chosen I just end up in the directory that i've specified as root folder in my MAMP settings.
Apache seems to ignore the changes made in the httpd.conf file, but if I remove (rename) the httpd.conf file (to _httpd.conf) it apache doesn't start. so it looks like changes to this file are ignored, BUT if I put something wrong in the file apache doesn't start either...
this is what I put in the httpd.conf file to add a virtual host:
<VirtualHost *>
DocumentRoot "/Users/username/Sites/site_dir/"
ServerName local.sitename.com
<Directory "/Users/username/Sites/site_dir/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
can this have anything to do with WP?
greets,
R.
On Windows:
Try putting it in the conf/extras/httpd-vhosts.conf instead and try
where port 80 is whatever port you have apache running on (:80 by default on windows)
and try not to use .org .com or any ending common on the web in your server name/alias use if you are developing the project on your localhost use something like sitename.local instead.
On Mac:
Not sure how it would work
On Ubuntu 11.04:
I just:
Set up a different vhost file for each site inside of /etc/apache2/sites-available
Then enable the site via a2ensite or just make a copy to the file using cp to the sites-enabled folder (all this is done via the ssh or a terminal on mac)
I then reload and restart apache and wallah!
I'm having a similar problem on one of my ubuntu servers. I'm doing something that I've done several times but all of a sudden it doesn't work. Go figure, lol! Typo? Who knows, definitely scour the web, an answer is sure to surface.

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