XAMPP, Can't access htdocs - apache

I have problem accessing << localhost/htdocs >>
URLs tried: localhost/htdocs
localhost:80/htdocs
ip:80/htdocs
Always same error
ERROR:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
All services are running correctly I am using port :80
I looked into apache conf :
Here is Doc Root
DocumentRoot: The directory out of which you will serve your
documents. By default, all requests are taken from this directory, but
symbolic links and aliases may be used to point to other locations.
DocumentRoot "C:/xampp/htdocs"
Please help I can't find the solution..
Thanks
Command Line:
Setting environment for using XAMPP for Windows.
c:\xampp
httpd -S
VirtualHost configuration:
*:443 is a NameVirtualHost
default server www.example.com (C:/xampp/apache/conf/extra/httpd-ssl.co
nf:83)
port 443 namevhost www.example.com (C:/xampp/apache/conf/extra/httpd-ss
l.conf:83)
port 443 namevhost www.example.com (C:/xampp/apache/conf/extra/httpd-ss
l.conf:83)
ServerRoot: "C:/xampp/apache"
Main DocumentRoot: "C:/xampp/htdocs"
Main ErrorLog: "C:/xampp/apache/logs/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/xampp/apache/logs/" mechanism=default
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "C:/xampp/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Does that seam correct?

DocumentRoot points to the root directory for a given virtual host. So you don't need to append htdocs to the URI if it is already specified in the DocumentRoot. Try:
http://localhost
Also, make sure you restart apache every time you edit a virtualhost/configuration file, since they are only checked/loaded once and that is on server startup.
If you still cannot get it to work, then httpd -S in command line to ensure the respective vhost is correctly loaded.

I think this is a port issue, I faced same kind of issue and I solved it following way
I opened the xampp control panel and clicked on the cofig button for apache service, opened the first link, Apache(httpd.conf) - this can be found in xampp\apache\conf directory also.
Then searched '80'(without quoatation) and changed them to 81 and saved the file.
Restarted the apache service.
Typed 'localhost:81/project_folder/' in the browser.
Then it worked fine.

I have been facing the same problem of late. It is because I have been including htdocs in the URI but it unnecessary thats why the error occurs.
Try this Working with XAMPP
Under XAMPP root directory there is a folder called htdocs. That is where you should put your web site related stuff. For each web site you create, it is better to create a folder inside htdocs folder and then put content inside that to avoid conflicts.
For an example, you can create a folder called learnphp inside htdocs folder and put welcome.php inside that. Then you can access it via the URL
http://localhost/learnphp/welcome.php.
Hope it helps.

You need to configure the VHosts Config file to point at your htdocs folder
Read the docs at:
http://127.0.0.1/dashboard/docs/configure-vhosts.html

Related

Apache Apache/2.4.7 (Ubuntu) ProxyPass

I'm trying to configure a simple ProxyPass using this file (as simple as possible) linked in /etc/apache2/sites-enable form sites-avalable (same file seems to work on apache 2.2 but may be i have done other configuration on previous installation and i canìt remember those configuration)
Note i use an IPADDRESS and not a Server Name but i think this is not the problem.
Note 2: i'm not an apache web server expert :)!
ServerName IP_SERVER_ADDRESS
# Redmine
ProxyPass /redmine http://IP_SERVER_ADDRESS:8555/redmine
# test1
ProxyPass "/test1" "http://IP_SERVER_ADDRESS:9180/test1/"
ProxyPassReverse "/test1" "http://IP_SERVER_ADDRESS:9180/test1/"
# test2
ProxyPass /test2 http://IP_SERVER_ADDRESS:8880/test2
ProxyPassReverse /test2 http://IP_SERVER_ADDRESS:8880/test2
DocumentRoot /var/www
But it didn't work, so the url
http://IP_SERVER_ADDRESS:8880/test2
work fine , but the proxied url
http://IP_SERVER_ADDRESS/test2
did not work , with the error
Not Found
The requested URL /redmine was not found on this server
Output of apache2ctl -S seems strange as apparently no VirtualHost configuration is used (?)
VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex proxy: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
Quite sure i'm missing some simple thing but i can't find it!
This answer is tested in Apache Apache/2.4.7 (Debian) ProxyPass.
See /etc/apache2/apache2.conf:
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
previous version was
# Include the virtual host configurations:
Include sites-enabled/
So basically in apache 2.4 (Debian and derivated) you must use file with a .conf extension to limit headache....
In Apache 2.2 the .conf extension in file name is not needed.
Other Details:
In sites-enabled configuration files (a soft link to sites-available) MUST be have an extension .conf so WHATEVER_YOU_WANT.conf
You MUST use a2ensite to enable a configuration, because if the file in sites-available did not have the "right" extension ".conf" it say "ERROR: Site WHATEVER_YOU_WANT does not exist!". So for example if you use a file named mysite and try to enable the configuration mysite with the command "a2ensite mysite" you receive an error. If you use a file named myfile.conf same command will work fine... If you manually create a soft link in sites-enabled to a conf file without the "conf" extension , the site will not work!!
You can create a soft link in sites-available with the right extension (.conf) to a file WITHOUT the right extension alredy peresent in sites-available. In such a case the configuration will work but if you use a2dissite to disable the site it will say "ERROR: Site WHATEVER_YOU_WANT does not exist!"
After finding the solution i found some link around
https://www.linode.com/docs/security/upgrading/updating-virtual-host-settings-from-apache-2-2-to-apache-2-4

apache vhost setup doesnt work

First things first .. im pretty new to apache configuration.
I'm trying to configure vhosts locally for an apache
(Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 according to phpinfo()).
Its set up via XAMPP (xampp-win32-5.6.3-0).
Operating system is Windows 7 Home Premium SP1.
So i already read some articles about setting up vhosts (also some in this forum).
My host file looks as follows:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 test.local
My C:\xampp56\apache\conf\extra\httpd-vhosts.conf contains the following code:
<VirtualHost *:80>
ServerName test.local
ServerAlias test.local
DocumentRoot "C:/xampp56/htdocs/test.local"
DirectoryIndex app.php
</VirtualHost>
It is loaded in the C:\xampp56\apache\conf\httpd.conf file.
Include conf/extra/httpd-vhosts.conf
The Module mod_log_config.so is also loaded in the httpd.conf
LoadModule log_config_module modules/mod_log_config.so
(After all editing in the config files i saved them and restarted apache.)
When I type test.local (or http://test.local) in FireFox it always says "test.local was not found". When i call up localhost however its working.
I havn't found any answers yet except to check if the vhost and the host file are set up correctly (which seems to be the case here to me).
Sorry for the long post and I am sorry in case it's just some stupid mistake i made here.
Thx for any help!
EDIT:
Here is also the output from the httpd -S command:
VirtualHost configuration:
*:80 test.local (C:/xampp56/apache/conf/extra/httpd-vhosts.conf:44)
*:443 www.example.com (C:/xampp56/apache/conf/extra/httpd-ssl.conf:80)
ServerRoot: "C:/xampp56/apache"
Main DocumentRoot: "C:/xampp56/htdocs"
Main ErrorLog: "C:/xampp56/apache/logs/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/xampp56/apache/logs/" mechanism=default
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
PidFile: "C:/xampp56/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
I found the solution.
It was Avira blocking access to my host file .. disabled that option in avira and vhosts work fine now.
Beside that i needed admin rights which were not set for the account i was working with ..

Using Apache VirtualHosts to serve multiple subdomains from same global ip address

I have a domain myexample.com which I would like to have multiple subdomains for, using the same IP address. I want to use Apache VirtualHosts without showing the client that redirection is happening. Here are the rules I want:
www.myexample.com gets content from the /var/www folder
www1.myexample.com gets content from the /var/www1 folder
www2.myexample.com gets content from the /var/www2 folder
The problem here is that all three must run on the same computer all on port 80 and I don't want to use 301 redirection because then the client can see what is happening. How do I configure VirtualHosts to do this? I can't figure out how to use mod_rewrite. Im running Ubuntu 14.04 with Apache2.
Thanks!
To add virtual hosts it is recommendable to write each virtual host in a separate file or write all of the virtual hosts for a specific user in one file. This improves the manageability of your server and makes it easy for you to find which file to edit when you want to change a specific setting for 1 domain.
When editing your apache2.conf file in /etc/apache2 there should be a line that says include sites-enabled/ at the bottom of your file. If it isn't there add it.
then create a new file for either your domain or your user in the sites-enabled folder. For easy editing I would do nano <filename>.conf which will open the editor and set the filename and extension.
Insert the following code into the file.
<VirtualHost 0.0.0.0:80>
ServerName www1.example.com
ServerAdmin admin#www1.example.com
DocumentRoot /var/www1
</VirtualHost>
To get everything on the same IP you could either enter *:80 in place of 0.0.0.0 to listen on all IP's on the system or enter the specific public IP address the server has for enhanced security.
Also, other directives may be required if you want to set specific PHP values or if you want to move your log files to a different file use:
CustomLog custompath/domainname.log
ErrorLog custompath/domainname.error.log
Hopes that solves your problem

XAMPP server document root for specific website

I just installed XAMPP, and I've found how to change the document root in the Apache config file, but I only want to change it for a specific site. The reason I need this is because all of my links are absolute links (i.e. /url not just url).
I tried changing it with .htaccess, but that gave me errors saying the limited recursion had been exceeded. So I went and changed that to 200, and it too a really long time, and then said that the recursion had been exceeded.
I would use aliases, but that would mean saying that any request to / goes somewhere else.
So is there anyway for me to specify that files inside of directory dir should have their document root as dir?
Thanks.
I found the solution, but it's a bit involved. You have to change the Apace config file, and the hosts file.
In the Apache config file, I added this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/absolute path/from/C/drive"
ServerName site.local
</VirtualHost>
Then I had to add this in the hosts file:
127.0.0.1 site.local
You can read up more on the virtual host here: http://httpd.apache.org/docs/2.2/vhosts/examples.html

How do I point Apache document root to a specific folder in Ubuntu?

I have a site that the root points to /var/www
I have set up two folders under /var/www
/var/www/old
/var/www/new
for the old folder, I have used the following to deny any access:
touch /var/www/old/.htaccess && echo deny from all >> /var/www/old/.htaccess
I now want the server to point the root to /var/www/new so that when people visit http://example.com the content in /var/www/new will serve, what should I do?
In Ubuntu the Apache configuration is located at /etc/apache2. There should be two folders, sites-available and sites-enabled. Inside sites-enabled are symlinks to config files in sites-available.
You simply have to change the document root in your activated configuration. Thats probably /etc/apache2/sites-enabled/000-default
Have a look for DocumentRoot and change it to /var/www/new, then reload your apache.
depends a LOT on how your apache server is configured.
I don't have an Ubuntu machine around, but what you're looking for is the DocumentRoot directive. On RedHat based machines it's normally in /etc/httpd/conf/httpd.conf but if memory serves Debian based systems use apache instead of httpd.
If that doesn't work be sure to check in /etc/httpd/conf.d since the files there are loaded dynamically.
Hope this helps :)