XAMPP: Accessing html pages in subdirectories of root - html

This is most likely a beginner's issue, but I can't seem to find the fix anywhere, and the few posts I found dealing with it are unanswered (e.g. xampp in window 7 cannot access files in subfolder inside C:/xampp/htdocs).
So far I have a working localhost using XAMPP (had to change the port to 8080), located in a custom document root. I can load the index.html, but when I click on a link towards a subdirectoy:
<li></li>
I get the following error:
Service unavailable!
The server is temporarily unable to service your request due to
maintenance downtime or capacity problems. Please try again later.
If you think this is a server error, please contact the webmaster.
Error 503
localhost Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30
Even if I type in the address (http://localhost:8080/examples/test.html) directly in the browser, it also doesn't work.
Could someone please indicate if this should be working? Or if I should specify something in the apache config file?
I could also note that when simply viewing the html files in my browser (outside of the localhost), the pages work fine and load regardless of their position in the directories. Thanks for any help!
Edit:
Here is my modified conf file DocumentRoot section:
#DocumentRoot "F:/Apps/xampp/htdocs"
DocumentRoot "F:/me/GitWorkDir/myproject_io"
<Directory "F:/me/GitWorkDir/myproject_io">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>

It turns out the issue was due to an unlucky coincidence preventing a subdirectory to be called, precisely, "examples"...
See this page which discusses the issue and proposes a fix.
In short, you can:
Either go to the file C:\xampp\apache\conf\extra\httpd-ajp.conf
and add a "#" to comment out the conflicting line:
ProxyPass /examples ajp://127.0.0.1:8009/examples smax=0 ttl=60 retry=5
Or simply rename the "examples" directory differently (e.g. examples2)

Mostly if you install XAMPP on windows it runs without any problem. Only thing which give issue on windows is permission. which you could resolve by right click on htdocs folder and go to security tab and give all rights to everyone.

Related

How to solve XAMPP PHPMyAdmin 403 Forbidden Error

I am using Apache/2.4.41 (Win64) OpenSSL/1.0.2s PHP/7.1.32 my phpmyadmin is suddenly not accessible its shows following error:
Access forbidden! You don't have permission to access the requested
directory. There is either no index document or the directory is
read-protected.
If you think this is a server error, please contact the webmaster.
I had tried everything but still not able to get it right
I had some error like this once, I just edit the httpd-xampp.conf from Require local to Require all granted in the LocationMatch tag. Or configure the http-vhosts.conf Directory tag to
<Directory>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride none
Require all granted
</Directory>
I hope it helps you!
Go to below file
C:\xampp\apache\conf\extra\httpd-xampp.conf
Then go to Directory tag as below:
<Directory "C:/xampp/phpMyAdmin">
and then in the Directory tag change as below:
From
Require local
To
Require all granted
Restart the Xampp
That's it!

Can not access to Server at Port 8080(Forbidden) Centos 6.5 Apache 2.2.15

I have a Lab server and made 27 accounts for students at /home/info02/
"info02" is a group name and info9042 is an account in example.
I'm info9042 and i wrote a simple html document in "/home/info02/info9042/public_html/index.html" but when i type URL in chrome(Window 10), I get message below.
enter image description here
Here is my "/etc/httpd/conf/httpd.conf" file.
What should i change code in conf file?
# 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 "/var/www/html"
#DocumentRoot "/home/nlp"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
## Options FileInfo AuthConfig Limit
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# The path to the end user account 'public_html' directory must be
# accessible to the webserver userid. This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a "403 Forbidden" message.
#
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#
<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disabled root
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir public_html
</IfModule>
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory /home/*/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
OK, I see several issues here that could be causing your issue(s), moreso than just the httpd config file. So basically your index.html file is a web page (I'm assuming you want to give students access to or someone else). One of the possible problems with what you are doing is, you have the html file (website) located in a folder you made in the /home/ directory. When you created websites, particularly in Apache, they should go under the "/var/www/" directory, because Apache by default sets up security and server settings to use that directory as like a web server directory. So a start to solve your issue would be to move your files/folders under the /var/www folder (or the /var/www/html folder). This can be customized/configured accordingly.
Another problem you have is that, you have two directory initiatives in your httpd file (you should just have one I believe), and your document root is pointing to /var/www/html. A third problem that could be causing a conflict; typically apache/virtual host is configured to load web pages on port 80, which are you trying to access on port 8080 (localhost). You may nave never specified it to load on localhost, and you may not have the ports open either. Your httpd file (I haven't worked with centos two much) doesn't seem to have the Virtual Host surrounding tags I am familair with, but typically you create a virtual host container that specifies a port to load those web pages over.
I don't know, I hope that points you in the right direction. I would definitely start by putting those files into the /var/www/html folder if you intend on using this as a webserver/webpage, it's not good practice (not safe) to use the home folder for such applications. Change the config file to point to that directory. If you need to give students access to modify/execute files, you will need to assign their usergroup permissions to work with the files in the /var/ww/html folder.

Changing Apache directives on GoDaddy shared server

The site I'm working on is hosted on GoDaddy's shared servers. I need to increase the limit on the Apache directive LimitRequestBody. I've tried adding the following to .htaccess:
LimitRequestBody 20250000
But that doesn't have any effect. I've called GoDaddy support several times, and nobody there seems to know how to help.
Any ideas?
Make sure your .htaccess file is affecting the correct directory - the one where the script you want to limit lives. To affect only that directory, put your .htaccess file in the root directory(above your script) and wrap your directive with
<Directory "/var/www/path/to/script">
LimitRequestBody 20250000
</Directory>
After you change the .htaccess file, you need to run
# service httpd reload
I hope this helps.

How do I change the default index page in Apache?

I would like to change the default web page that shows up when I browse my site. I currently have a reporting program running, and it outputs a file called index.html. I cannot change what it calls the file. Therefore, my landing page must be called something else. Right now, when I browse my site it takes me to the reporting page.
From what I see, whatever you call index.html it will pull that up as your default. I want to change that to landing.html. How do I do this?
I am a folder (Folding # Home). The reporting program is HFM.net. HFM can output an html file with my current folding statistics. It names the html file index. I do not want that to be my default home page. I would like a menu-like landing where I can choose if I want to see my stats, or something else. The website is at /home/tyler/Documents/hfm/website (landing.html and hfm's index.html are here). Apache2 is in its default directory.
I'm also running Ubuntu 13.04.
I recommend using .htaccess. You only need to add:
DirectoryIndex home.php
or whatever page name you want to have for it.
EDIT: basic htaccess tutorial.
1) Create .htaccess file in the directory where you want to change the index file.
no extension
. in front, to ensure it is a "hidden" file
Enter the line above in there. There will likely be many, many other things you will add to this (AddTypes for webfonts / media files, caching for headers, gzip declaration for compression, etc.), but that one line declares your new "home" page.
2) Set server to allow reading of .htaccess files (may only be needed on your localhost, if your hosting servce defaults to allow it as most do)
Assuming you have access, go to your server's enabled site location. I run a Debian server for development, and the default site setup is at /etc/apache2/sites-available/default for Debian / Ubuntu. Not sure what server you run, but just search for "sites-available" and go into the "default" document. In there you will see an entry for Directory. Modify it to look like this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Then restart your apache server. Again, not sure about your server, but the command on Debian / Ubuntu is:
sudo service apache2 restart
Technically you only need to reload, but I restart just because I feel safer with a full refresh like that.
Once that is done, your site should be reading from your .htaccess file, and you should have a new default home page! A side note, if you have a sub-directory that runs a site (like an admin section or something) and you want to have a different "home page" for that directory, you can just plop another .htaccess file in that sub-site's root and it will overwrite the declaration in the parent.
You can also set DirectoryIndex in apache's httpd.conf file.
CentOS keeps this file in /etc/httpd/conf/httpd.conf
Debian: /etc/apache2/apache2.conf
Open the file in your text editor and find the line starting with DirectoryIndex
To load landing.html as a default (but index.html if that's not found) change this line to read:
DirectoryIndex landing.html index.html
I had a similar problem. When providing http://server/appDirectory I got a directory listing instead of index.html even though I had
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
in my httpd.conf file.
My solution was to uncomment the
LoadModule setenvif_module modules/mod_setenvif.so
line in httpd.conf
Apache version: 2.4
In Ubuntu you can add in file:
/etc/apache2/mods-enabled/dir.conf
line
DirectoryIndex myhomepage.htm
and then restart apache service
sudo systemctl restart apache2
In Unbuntu, you can update the default page on a site-by-site basis with the site config files eg:
/etc/apache2/sites-available/your.domain.conf
Same syntax for the key line in the file, eg mine is;
DirectoryIndex default.htm index.htm
Then don't forget to enable and reload:
sudo a2ensite your.domain.conf
sudo systemctl reload apache2

Apache giving 403 forbidden errors

Ok, so i've previously set up two virtual hosts and they are working cool. they both house simple web projects and work fine with http://project1 and http://project2 in the browser.
Anyway, I've come to add another vhost. I edited the /etc/hosts file with 127.0.0.1 project3 and also updated the httpd-vhosts.conf file by copy and pasting the previous entries for project2 and editing the file path.
I've checked all the file and folder permissions (in fact I copied and pasted from project2) and simply put a "hello world" message in the index.php file.
I get a 403 forbidden permission denied message when accessing http://project3
Why is this, I just can figure out what step I've missed as everything seems to be set up correct.
Check that :
Apache can physically access the file (the user that run apache, probably www-data or apache, can access the file in the filesystem)
Apache can list the content of the folder (read permission)
Apache has a "Allow" directive for that folder. There should be one for /var/www/, you can check default vhost for example.
Additionally, you can look at the error.log file (usually located at /var/log/apache2/error.log) which will describe why you get the 403 error exactly.
Finally, you may want to restart apache, just to be sure all that configuration is applied.
This can be generally done with /etc/init.d/apache2 restart. On some system, the script will be called httpd. Just figure out.
I just fixed this issue after struggling for a few days. Here's what worked for me:
First, check your Apache error_log file and look at the most recent error message.
If it says something like:
access to /mySite denied (filesystem path
'/Users/myusername/Sites/mySite') because search permissions
are missing on a component of the path
then there is a problem with your file permissions. You can fix them by running these commands from the terminal:
$ cd /Users/myusername/Sites/mySite
$ find . -type f -exec chmod 644 {} \;
$ find . -type d -exec chmod 755 {} \;
Then, refresh the URL where your website should be (such as http://localhost/mySite).
If you're still getting a 403 error, and if your Apache error_log still says the same thing, then progressively move up your directory tree, adjusting the directory permissions as you go. You can do this from the terminal by:
$ cd ..
$ chmod 755 mySite
If necessary, continue with:
$ cd ..
$ chmod Sites
and, if necessary,
$ cd ..
$ chmod myusername
DO NOT go up farther than that. You could royally mess up your system.
If you still get the error that says search permissions are missing on a component of the path, I don't know what you should do. However, I encountered a different error (the one below) which I fixed as follows:
If your error_log says something like:
client denied by server configuration:
/Users/myusername/Sites/mySite
then your problem is not with your file permissions, but instead with your Apache configuration.
Notice that in your httpd.conf file, you will see a default configuration like this (Apache 2.4+):
<Directory />
AllowOverride none
Require all denied
</Directory>
or like this (Apache 2.2):
<Directory />
Order deny,allow
Deny from all
</Directory>
DO NOT change this! We will not override these permissions globally, but instead in your httpd-vhosts.conf file.
First, however, make sure that your vhost Include line in httpd.conf is uncommented. It should look like this. (Your exact path may be different.)
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
Now, open the httpd-vhosts.conf file that you just Included. Add an entry for your webpage if you don't already have one. It should look something like this. The DocumentRoot and Directory paths should be identical, and should point to wherever your index.html or index.php file is located. For me, that's within the public subdirectory.
For Apache 2.2:
<VirtualHost *:80>
# ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/Users/myusername/Sites/mySite/public"
ServerName mysite
# ErrorLog "logs/dummy-host2.example.com-error_log"
# CustomLog "logs/dummy-host2.example.com-access_log" common
<Directory "/Users/myusername/Sites/mySite/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
The lines saying
AllowOverride All
Require all granted
are critical for Apache 2.4+. Without these, you will not be overriding the default Apache settings specified in httpd.conf. Note that if you are using Apache 2.2, these lines should instead say
Order allow,deny
Allow from all
This change has been a major source of confusion for googlers of this problem, such as I, because copy-pasting these Apache 2.2 lines will not work in Apache 2.4+, and the Apache 2.2 lines are still commonly found on older help threads.
Once you have saved your changes, restart Apache. The command for this will depend on your OS and installation, so google that separately if you need help with it.
I hope this helps someone else!
PS: If you are having trouble finding these .conf files, try running the find command, such as:
$ find / -name httpd.conf
restorecon command works as below :
restorecon -v -R /var/www/html/
Notice that another issue that might be causing this is that, the "FollowSymLinks" option of a parent directory might have been mistakenly overwritten by the options of your project's directory. This was the case for me and made me pull my hair until I found out the cause!
Here's an example of such a mistake:
<Directory />
Options FollowSymLinks
AllowOverride all
Require all denied
</Directory>
<Directory /var/www/>
Options Indexes # <--- NOT OK! It's overwriting the above option of the "/" directory.
AllowOverride all
Require all granted
</Directory>
So now if you check the Apache's log message(tail -n 50 -f /var/www/html/{the_error_log_file_of_your_site}) you'll see such an error:
Options FollowSymLinks and SymLinksIfOwnerMatch are both off, so the RewriteRule directive
is also forbidden due to its similar ability to circumvent directory restrictions
That's because Indexes in the above rules for /var/www directory is overwriting the FolowSymLinks of the / directory. So now that you know the cause, in order to fix it, you can do many things depending on your need. For instance:
<Directory />
Options FollowSymLinks
AllowOverride all
Require all denied
</Directory>
<Directory /var/www/>
Options FollowSymLinks Indexes # <--- OK.
AllowOverride all
Require all granted
</Directory>
Or even this:
<Directory />
Options FollowSymLinks
AllowOverride all
Require all denied
</Directory>
<Directory /var/www/>
Options -Indexes # <--- OK as well! It will NOT cause an overwrite.
AllowOverride all
Require all granted
</Directory>
The example above will not cause the overwrite issue, because in Apache, if an option is "+" it will overwrite the "+"s only, and if it's a "-", it will overwrite the "-"s... (Don't ask me for a reference on that though, it's just my interpretation of an Apache's error message(checked through journalctl -xe) which says: Either all Options must start with + or -, or no Option may. when an option has a sign, but another one doesn't(E.g., FollowSymLinks -Indexes). So it's my personal conclusion -thus should be taken with a grain of salt- that if I've used -Indexes as the option, that will be considered as a whole distinct set of options by the Apache from the other option in the "/" which doesn't have any signs on it, and so no annoying rewrites will occur in the end, which I could successfully confirm by the above rules in a project directory of my own).
Hope that this will help you pull much less of your hair! :)
it doesn't, however, solve the problem, because on e.g. open SUSE Tumbleweed, custom source build is triggering the same 401 error on default web page, which is configured accordingly with Indexes and
Require all granted
The server may need read permission for your home directory and .htaccess therein
You can try disabling selinux and try once again using the following command
setenforce 0
In my case it was failing as the IP of my source server was not whitelisted in the target server.
For e.g. I was trying to access https://prodcat.ref.test.co.uk from application running on my source server.
On source server find IP by ifconfig
This IP should be whitelisted in the target Server's apache config file. If its not then get it whitelist.
Steps to add a IP for whitelisting (if you control the target server as well)
ssh to the apache server
sudo su -
cd /usr/local/apache/conf/extra (actual directories can be different based on your config)
Find the config file for the target application for e.g. prodcat-443.conf
RewriteCond %{REMOTE_ADDR} <YOUR Server's IP>
for e.g.
RewriteCond %{REMOTE_ADDR} !^192\.68\.2\.98
Hope this helps someone
Add
<Directory "/path/to/webroot">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow, deny
Allow from all
Require all granted
</Directory>
What this does is tell Apache2 to override any previous configs, and allow (200) from all before denying. (403) It also requires all requests to be granted. This code will have to go in every vhost file, but it does work. I have been using this for over a year.
to your config file (e.g. /etc/apache2/sites-enabled/000-default.conf)
Tested LAMP stack Debian 11