I have apache+mysql+phpmyadmnin under Gentoo.
phpmyadmin-3.2.2
It worked fine before, but now, when I'm loading http://localhost/phpmyadmin I get a list of flies in phpmyadmin-directory, and when I chose index.php, I get it's own code.
What I did wrong?
It means that apache does not recognizes neither of your files as php executables. Maybe you run an 'emerge update world' and then an 'env-update' which install a new apache2 version and then re-write the old apache config file. As LiraNuna mentioned, you need to check that the phpMyAdmin directory contains the proper instruction to load the proper PHP module. In this way apache will know how to handle the php files.
This is what I have on /etc/apache2/vhosts.d/default_vhost.include under the phpMyAdmin Directory definition:
Alias /phpMyAdmin /var/www/localhost/htdocs/phpMyAdmin
<Directory /var/www/localhost/htdocs/phpMyAdmin>
Options Indexes FollowSymLinks
DirectoryIndex index.php
# Authorize for setup
<Files setup.php>
# For Apache 1.3 and 2.0
<IfModule mod_auth.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
# For Apache 2.2
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
Require valid-user
</Files>
<IfModule mod_php4.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>
</Directory>
This should solve your problem.
Is mod_php5 installed? If so, do you have the php handler set up to handle .php files?
<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml .php4 .php3
AddType application/x-httpd-php-source .phps
</IfModule>
If you are not using mod_php5, do you use any form of CGI? Do the .php files have execute permissions?
Related
My server doesn't render any images under the cgi directory, I know that this is because apache is told to run every file under that directory as a cgi program.
I would like to adjust the settings to tell apache to run all the .cgi and .pl as cgi programs but run the rest of files as they should be.
For instance, if I go to example.com/x.gif from a browser I can see the image, but if I go to example.com/cgi-bin/x.gif I can't. (being the image in both dirs, of course, and with 775)
The problem is that I don't know how to tell that to apache, this is the httpd.include
<Directory /var/www/vhosts/example.com/httpdocs>
<IfModule mod_perl.c>
<Files ~ (\.pl$)>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Files> </IfModule> <IfModule mod_python.c>
<Files ~ (\.py$)>
SetHandler python-program
PythonHandler mod_python.cgihandler
</Files> </IfModule> <IfModule mod_fcgid.c>
<Files ~ (\.fcgi)>
SetHandler fcgid-script
Options +FollowSymLinks +ExecCGI
</Files> </IfModule> <IfModule mod_fcgid.c>
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
Options +ExecCGI
allow from all
</Files> </IfModule>
SSLRequireSSL
Options -Includes +ExecCGI
</Directory>
I found a solution.
As I said, apache is told to run every file under that directory as a cgi program. So are needed new rules to tell apache to use a default handler for those filetypes different from .php , .pl or .cgi:
<Directory /var/www/vhosts/example.com/httpdocs/cgi-bin>
<FilesMatch "^(?!.*\.(cgi|php|pl)$).*$">
SetHandler default-handler
</FilesMatch>
</Directory>
If you can't access the httpd.conf for any reason you still can do the trick with .htaccess adding this three lines to the .htaccess file of the cgi-bin folder:
<FilesMatch "^(?!.*\.(cgi|php|pl)$).*$">
SetHandler default-handler
</FilesMatch>
I've looked at quite a few answers for this, but all seem apparently out of date. I'm using Ubuntu 14.04 and Apache 2.4.7. My /etc/apache2/conf.d/phppgadmin file looks like this:
Alias /phppgadmin /usr/share/phppgadmin
<Directory /usr/share/phppgadmin>
DirectoryIndex index.php
AllowOverride all
order deny,allow
#deny from all
#allow from 127.0.0.0/255.0.0.0 ::1/128
Require all granted
<IfModule mod_php5.c>
php_flag magic_quotes_gpc Off
php_flag track_vars On
#php_value include_path .
</IfModule>
<IfModule !mod_php5.c>
<IfModule mod_actions.c>
<IfModule mod_cgi.c>
AddType application/x-httpd-php .php
Action application/x-httpd-php /cgi-bin/php
</IfModule>
<IfModule mod_cgid.c>
AddType application/x-httpd-php .php
Action application/x-httpd-php /cgi-bin/php
</IfModule>
</IfModule>
</IfModule>
</Directory>
Also have a file 000-default in /etc/apache2/sites-enabled while looks like:
<Directory "/usr/share/phpPgAdmin">
AuthUserFile /etc/phpPgAdmin/.htpasswd
AuthName "Restricted Area"
AuthType Basic
require valid-user
</Directory>
And I've modified /etc/phppgadmin/.htpasswd appropriately.
Nonetheless, when I try to log into it remotely I get a 403: Forbidden error.
Any ideas? Further, could this error be imposed by the type of network I'm on? (it's a campus network).
Try is
sudo cp /etc/apache2/conf.d/phppgadmin /etc/apache2/conf-enabled/phppgadmin.conf
Restart httpd2 (Apache)
sudo /etc/init.d/apache2 restart
or
sudo service apache2 start
For Ubuntu 14.04
I'm trying to secure my web server by changing the url of phpmyadmin (/phpmyadmin).
I have edited the file /etc/phpmyadmin/apache.conf :
Alias /secure-db /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen Off
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/
</IfModule>
Now, I can access phpmyadmin via /secure-db, and also via /phpmyadmin
I do not understand why /phpmyadmin is still available. Of course, I did restart apache.
By the way, I'm using ISPConfig 3.0.5.4p1
Any idea? Is there another kind of vhost somewhere?
EDIT :
I had another file "phpmyadmin.conf.bak.20140429" in the same folder which contained the alias /phpmyadmin. After removing it I could not go to the url /phpmyadmin. So I guess that this backup file was read by apache.
I have a server for 10 domains. all domains are working fine with ServerAlias so if user type www.domain.com or just domain.com works perfect. However, only one domain does not work. If I type www.xxxxx.com, it works. If I type just xxxxx.com, it goes to default page. Since other domains does not have this problem, How can I fix it? or how can I check ServerAlias result in httpd?
<VirtualHost 202.64.x.x:80>
ServerName www.xxxxx.com:80
ServerAdmin webmaster#xxxxx.com
DocumentRoot /var/www/web185/web
ServerAlias xxxx.com.hk
DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
Alias /cgi-bin/ /var/www/web185/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
ErrorLog /var/www/web185/log/error.log
AddType application/x-httpd-php .php .php3 .php4 .php5
php_admin_flag safe_mode On
php_admin_value open_basedir /var/www/web185/
php_admin_value file_uploads 1
php_admin_value upload_tmp_dir /var/www/web185/phptmp/
php_admin_value session.save_path /var/www/web185/phptmp/
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddType application/vnd.wap.wmlscriptc .wmlsc .wsc
AddType text/vnd.wap.wml .wml
AddType text/vnd.wap.wmlscript .ws .wmlscript
AddType image/vnd.wap.wbmp .wbmp
Alias /stats "/var/www/web185/web/webalizer"
Alias /error/ "/var/www/web185/web/error/"
AliasMatch ^/~([^/]+)(/(.*))? /var/www/web185/user/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web185/user/$1/web/$3
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
</VirtualHost>
ServerAlias xxxx.com.hk
This means that the alias is xxxx.com.hk and not xxxx.com and hence xxxx.com goes to the default page.
There is a number of similar questions, but none of them help.
I have the following rule in my .htaccess
RewriteRule ^images/.*$ - [F]
so for folders like /images/goods/ or /images/nonexistentfile.jpg I get 'Forbidden' which is what I want. The problem is if an existent file is requested, my rules are ignored and the file is served. In fact if I make a deliberate mistake in .htaccess I don't get an Internal Server Error as I would when requesting folders or non-existent files. What should I look for?
apache2.conf
<VirtualHost 1.2.3.4:8080>
ServerName domain.com
DocumentRoot /var/www/s3/data/www/domain.com
SuexecUserGroup s3 s3
CustomLog /var/www/httpd-logs/domain.com.access.log combin$
ErrorLog /var/www/httpd-logs/domain.com.error.log
ServerAlias www.domain.com
ServerAdmin example#domain.com
AddDefaultCharset utf-8
php_admin_value open_basedir "/var/www/s3/data:.:/tmp"
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f example#domain.com
php_admin_value upload_tmp_dir "/var/www/s3/data/mod-tmp"
php_admin_value session.save_path "/var/www/s3/data/mod-tmp"
AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
AddType application/x-httpd-php-source .phps
</VirtualHost>
anything else I should post here?
I had a similar issue.
I put the following .htaccess in to the images folder to forbid access to jpg files (in my case)
IndexIgnore */*
<Files ~ ".*\.jpg$">
Order deny,allow
Deny from all
</Files>
It looks like you're htaccess file isn't being applied. Try adding an AllowOverride directive in your vhost config:
<Directory "/var/www/s3/data/www/domain.com/">
AllowOverride All
</Directory>
By default, AllowOverride should be set to All, but it's possible your host set it to something else at the server config level.
in case someone has the same problem, it is painfully trivial. The default ISPManager installation puts nginx in front of Apache for static files...