Server Error 500 Php - apache

Good day
Im trying to install a GamePanel with PHP called Swiftpanel on my VPS Centos7 64bit
i installed LAMP on my vps and html files work perfectly.
But my gamepanel doesnt work
and the gamepanel is located at:
http://51.255.199.40/gpanel/
as you can see when i try reaching my gpanel it gives me the SERVER ERROR 500
i looked at my apache error logs and this is what i get:
[Fri Mar 04 15:53:53.533162 2016] [autoindex:error] [pid 18753] [client 46.99.59.98:51034] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
Here is my httpd.conf and php.conf:
http://pastebin.com/HJfH3gWQ
I need some help fixing this, im a begginer in coding.
With respect
Benjamin Selmani

In httpd.conf, try changing the line:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
to
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
and restart Apache.

OK, edit your httpd.conf file and change the following line:
Options Indexes FollowSymLinks
to:
Options +Indexes +FollowSymLinks
then restart your Apache server. If this doesn't work, it's likely we are editing the wrong httpd.conf file. You'd be surprised how many you might find on your computer including all the conf files in sub directories (look at the last line of your httpd.conf file). Somewhere there is probably a line that looks like this:
Options -Indexes
Which is the explicit cause of the problem. But try my earlier suggestion first.

Related

Why Apache configuration works when I use root directory

I have a VirtualHost that I am using to serve requests to files in /var/www/project/src.
I also have a Perl script (CGI binary) that is in /var/www/project/src/cgi-bin/index.pl.
Here's the part of the directive relevant to my question:
<VirtualHost example.com:443>
...
DocumentRoot "/var/www/project/src"
<Directory "/var/www/project/src">
Require all granted
Options +MultiViews +ExecCGI
AddHandler cgi-script .pl
DirectoryIndex /cgi-bin/index.pl
</Directory>
</VirtualHost>
The server starts, but access to the host fails as I get a 403 error.
The Apache logs indicate that the web server cannot find {document-root}/cgi-bin/index.pl:
[Thu Nov 09 11:37:03.578316 2017] [autoindex:error]
[pid 122783] [client example-client.com:57203] AH01276:
Cannot serve directory /var/www/project/src/: No matching
DirectoryIndex (/cgi-bin/index.pl) found, and server-
generated directory index forbidden by Options directive
This directory and index.pl file are in the right location, are owned by the apache user, and have permissions which allow others to read the contents of directories and execute the index.pl CGI-bin.
Moreover, if I change paths in DocumentRoot and Directory variables, the following configuration works:
<VirtualHost example.com:443>
...
DocumentRoot "/"
<Directory "/">
Require all granted
Options +MultiViews +ExecCGI
AddHandler cgi-script .pl
DirectoryIndex /var/www/project/src/cgi-bin/index.pl
</Directory>
</VirtualHost>
Apache starts up, and my access to the host in turn loads /cgi-bin/index.pl, which is rendered correctly.
Question: What would cause the first set of directives to fail, where the second set works?
More specifically: What is preventing the first set of directives from finding /cgi-bin/index.pl in the specified document root, while the second set correctly finds the fully-qualified path /var/www/project/src/cgi-bin/index.pl?
Note: The items in ... do not seem relevant to the issue — whether I remove them, alter them, or leave them, the error and log messages are the same in any case — so I am leaving them out for brevity.
Try changing permissions for /var/www, /var/www/project, /var/www/project/src and/or /var/www/project/src/cgi-bin
Update: Also, don't forget to restart Apache server after making changes.
What's happening is your excessive zeal an excess in your zeal... in the first example, DirectoryIndex /cgi-bin/index.pl points towards your ROOT directory, then searching for a folder caller cgi-bin. This also happens in the second example, but since you give the full path, Apache finds it. Try removing the / before cgi-bin and the issue should fix itself.

Apache won't autoindex

Oracle Linux 7.3 (RHEL derivative)
Apache 2.4.6
I'm setting up a repository in /srv/www for yum, scripts, and kickstart files, served via httpd. I want an auto-index, so I don't have any index.html. And, this is the only thing this internal server will do. So, httpd.conf:
DocumentRoot "/srv/www"
<Directory "/srv/www">
AllowOverride all
Options Indexes FollowSymLinks
Require all granted
</Directory>
However, I still get the error message:
[autoindex:error] [pid 12345] [client <IP address>:<port>] AH01276: Cannot serve directory /srv/www: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive.
Except that the Options directive allows auto-indexing! I've tried Options All. I've tried Options +Indexes +FollowSymLinks. I've looked at 7 or 8 Google hits. Nothing is working.
Setting LogLevel debug doesn't increase messaging.
What have I missed?
As noted here, in the absence of an index.html (or other configured index file), the welcome page configured at /etc/httpd/conf.d/welcome.conf will take precedence over other configurations via its LocationMatch directive. Rename the file so it doesn't end in .conf and auto-indexing works.
Obviously landing in another virtualhost or Directory without indexes enabled, or a .htaccess getting in the way.
Set "AllowOverride none" first, since it is absurd to have it active if you are not using any .htaccess file (and since you have access to the main server you don't need it). Once you set AllowOverride, restart the server in case you added Indexes recently and didn't restart to apply changes.
If the issue persists, run apachectl -S and make sure you are landing in the correct virtualhost.
I just want to add that, after updating my mac to Catalina, my apache stopped working with that same error.
I had to:
uncomment the required modules (php7, rewrite, directory, etc...)
add a + sign to the Options (Options +FollowSymLinks +Multiviews +Indexes)
This worked for me.
Solution:
Ensure two apache modules are running:
mod_autoindex.so
mod_dir.so
In your case, mod_autoindex.so is running. Now enable the second one.
PS: Keep Options -Indexes. It's important. It makes sure that directory listings are disabled, as you shouldn't allow anyone to pay a visit to every directory on your server (some with rather private content such as CMS's directories).

Apache virtual host issue

I am trying to get Symfony to work without using the built in PHP server, however, I always get 403 when trying to access it via my virtual host address. My virtual host conf file looks like this:
<VirtualHost *:80>
ServerName www.symfony2.local
ServerAlias symfony2.local
DocumentRoot /var/www/vhosts/symfony2.local/web
<Directory /var/www/vhosts/symfony2.local/web>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/symfony2-error.log
CustomLog /var/log/httpd/symfony2-access.log combined
</VirtualHost>
My hosts file looks like this:
127.0.0.1 symfony2.local
The .htaccess in web/ is the default Synfony2 installed file.
Whenever I try to access http://synfony2.local I get the following error in my log file:
(13)Permission denied: [client 127.0.0.1:32858] AH00529: /var/www/vhosts/symfony2.local/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/vhosts/symfony2.local/web/' is executable
-rwxr-xr-x. 1 apache apache 2.8K Mar 1 00:48 .htaccess
drwxr-xr-x. 3 apache apache 4.0K Mar 1 01:24 web
Can someone please point out what I am missing here?
There could be serveral reasons for the 403 foribben.
Reduce the permissions on the .htaccess file. You have the wrong
permissions on the htaccess file. You have it as 755 which should be used on directories and it should
be 644 rw-r--r--. Change it. My guess is that's the problem.
Make sure you have an index file in the web root. Of course if you have a web app there then make sure you have the DirectoryIndex index.php specified in the Apache config file.
Make sure the parent folder is 755 symfony2.local also which has been known to restrict access.
Option 2 and 3 are something to check if 1 doesn't fix it. Although you need to change the perms on htaccess regardless.
The solution by Panama Jack was useful and the points raised valid, however, it did not resolve the issue (although it may have had an effect).
I finally managed to get it to work after disabling SeLinux.

How to enable FastCGI with Apache 2.4 and PHP 5.4

What I have done:
Install apache 2.4 and php 5.4 from source.
apache config:
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event
php config
./configure --prefix=/usr/local/php \
--with-mysql=mysqlnd\
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--enable-mbstring \
--with-freetype-dir \
--with-jpeg-dir\
--with-png-dir\
--with-zlib \
--with-libxml-dir=/usr/local/libxml2 \
--enable-xml \
--enable-sockets \
--enable-fpm \
--with-mcrypt \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-bz2\
--with-apxs2=/usr/local/apache/bin/apxs
In the httpd.conf file, I enabled the mod_proxy.so and mod_proxy_fcgi.so and add the following config:
<IfModule proxy_module>
ProxyRequests off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/$1
</IfModule>
from phpinfo(), I see the Server API is FPM/FastCGI
My Problem:
I set the DirectoryIndex as below. I have index.html in the DirectoryRoot which is "/var/www". When I visit localhost, I am supposed to see the content of index.html. But it gave a 404 file not found.
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
When I switch the position of index.html and php in the above code. This time the html file is in front of php file. Then when I visit localhost, I can see the right content.
And I checked the apache error log. It says:
[Thu May 01 23:21:15.968659 2014] [proxy_fcgi:error] [pid 3415:tid 140603093 993216] [client 192.168.1.157:60384] AH01071: Got error 'Primary script unkn own\n'
When there is only index.php file in the /var/www, and leaving the httpd.conf like
<IfModule dir_module> DirectoryIndex index.html index.php</IfModule>
Also got 404, visiting the localhost.
My Question:
How do I fix the above problem?
I did some research on the configuration of fastcgi. like this and this
They dont mention the mod_proxy_fcgi, but all refering this
"FastCGIExternalServer /var/www/cgi-bin/php5.fcgi -host
127.0.0.1:9000"
So I am not sure if I am using the FastCgi the right way? Does this wrong way cause the above problem?
【P.S.】
Thank you regilero. I'm not using vhost and I had checked the error.log. It seems having something to do with php-fpm. The response page in the browser says "file not found", not "404", although the response code is 404. Here is what's in the error.log
[Thu May 01 23:21:15.968659 2014] [proxy_fcgi:error] [pid 3415:tid 140603093 993216] [client 192.168.1.157:60384] AH01071: Got error 'Primary script unknown\n'
I try to forward all the requersts ended with ".php" to fcgi. But the error above looks like that when I request index.html, it is also forwarded to the fcgi, which fcgi cannot handle it.(This is my guess) For the config about this forwarding, please see the code above, or search this page for "fcgi://".
Here is my Directory config. I'm not sure if this is what you need.
DocumentRoot "/var/www"
<Directory "/var/www">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
This is somewhat of a linked answer however it's one I share with many who come across the problem you are facing now and it seems to do the trick.
Checkout this GIST -> https://gist.github.com/diemuzi/3849349
There you will find all my working configurations for Apache and PHP-FPM. It seems like a better place to organize my configurations instead of pasting them here and confusing others. This link will not expire so no worries about that.
Perhaps also you can compare my working examples with what you have and find something missing that you currently are not using. Hope this helps!

Apache mod_rewrite enabled, but not working

Battling second day against problems with using mod_rewrite.
System OS: Windows XP
HTTP server: Apache 2.2 httpd
couple related lines from httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
DocumentRoot "N:/Web-dev/www"
<Directory "/">
Options Indexes +FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "N:/Web-dev/www">
Options Indexes +FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
.htaccess contains:
RewriteEngine on
RewriteRule ^alice.html$ bob.html
php info says
Loaded Modules core mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias mod_asis mod_auth_basic mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_setenvif mod_rewrite mod_proxy mod_php5
Both files are existing, loading alice.html, it still loads it, in rewrite.log, it shows:
127.0.0.1 - - [25/Apr/2011:11:01:27 +0300] [localhost/sid#7b5148][rid#2bc70b0/initial] (1) [perdir N:/Web-dev/www/] pass through N:/Web-dev/www/alice.html
I eaven tried to test, if it is reading .htaccess file, by adding some jibberish to rewrite engine command, and it proved:
[Mon Apr 25 10:47:04 2011] [alert] [client 127.0.0.1] N:/Web-dev/www/.htaccess: Invalid command 'ReDELETEMEwriteEngine', perhaps misspelled or defined by a module not included in the server configuration
But making same, to RewriteRule, changes nothing, like if it ignores those. I'm out of options, what to do!?
Making more tests, I get to strange results - added some DELETEME before RewriteEngine command - it fails with error, if I add anything afterwards, it ignores it, like if there would be no errrs!
Then I recall my experience with regex and text analysis, I wondered, if tampering with CRLF would do any good, and uncovering, what is current file new line symbols, uncovered that they where CR's. As I know, Apache is unix based software, I thought, it could misunderstood those, so I converted them to LF's and that was it, everything worked afterwards!
Note to future - make sure, with your editor (EditPlus, Notepad++, etc), that your .htaccess new line symbols are multiplatform compatible (CRLF), or at least unix compatible (LF), if working with apache!