LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   What is the right method to install phpMyAdmin on my centos 6.2 (https://www.linuxquestions.org/questions/linux-software-2/what-is-the-right-method-to-install-phpmyadmin-on-my-centos-6-2-a-944569/)

newbie14 05-12-2012 08:27 AM

What is the right method to install phpMyAdmin on my centos 6.2
 
Dear All,
Currently I get the latest phpMyAdmin unzip and load into my www folder and just run it. Recently there was an attack via phpMyAdmin. So what is the correct method I should install to avoid this type of vulnerable attack ony my server in future? My os is centos and the attack was due to this PhpMyAdmin vulnerability CVE-2011-2505 (http://www.cve.mitre.org/cgi-bin/cve...=CVE-2011-2505)

bathory 05-13-2012 08:20 AM

Hi,

Apart from always using the latest version, you can obscure the phpMyAdmin url, by using something known only to you. So rename the phpMyAdmin-x.y.z directory to "cannot-be-found" for example. You can then use http://hostname/cannot-be-found to do your job, while bots scanning for vulnerable installations cannot find it.
Of course you can deploy mod_security and/or fail2ban and maybe other security measures to reduce risks even more.

Regards

newbie14 05-13-2012 08:27 AM

Dear Bathory,
I have another idea is that to keep the whole folder cannot-be-found in another location and only copy into /var/www/html when I need to use then delete? Ok next thing I am trying this .htaccess method. I did this first I set .htaccess folder and type this in it.

Quote:

AuthUserFile /var/www/html/phpMyAdmin-3.4/.htpasswd
AuthName "phpMyAdmin Login Page"
AuthType Basic
Require valid-user
The I created the username and password using this command

sudo htpasswd -c .htpasswd iamadmin
...and I could see both the .htaccess and .htpasswd files are in the folder.


Another thing done is the httpd.conf.

Quote:

<Directory />
Options FollowSymLinks
AllowOverride AuthConfig
</Directory>
But when I go my link it never prompt for the additional username and password. My OS is centos 6.2

bathory 05-13-2012 08:42 AM

Quote:

I have another idea is that to keep the whole folder cannot-be-found in another location and only copy into /var/www/html when I need to use then delete?
You could, but I think it's a waste of time copying and deleting that directory.

Quote:

<Directory />
Options FollowSymLinks
AllowOverride AuthConfig
</Directory>
You should do this for the docroot (or just for the phpMyAdmin (or whatever you want to call it) directory). E.g.
Code:

<Directory /var/www/html/cannot-be-found>
Options FollowSymLinks
AllowOverride AuthConfig

And of course place the .htaccess into that directory
Attn: The .htpasswd should be located into a directory not accessible from the web (e.g. in /var/www)

newbie14 05-13-2012 08:46 AM

Dear Bathory,
So should I add this into my httpd config file is it?
Quote:

<Directory /var/www/html/cannot-be-found>
Options FollowSymLinks
AllowOverride AuthConfig
</Directory>
Why is this <Directory /> not taking effect ya? Now I saw the .htpasswd is also in the same location in the phpMyAdmin directory. So should I move it to where is best location? If I move will it be able to detect then the password?

bathory 05-13-2012 09:05 AM

Quote:

So should I add this into my httpd config file is it?
Yup


Quote:

Why is this <Directory /> not taking effect ya?
I'm not familiar with centos apache configuration, but I guess that there is another "AllowOverride None" for docroot.


Quote:

So should I move it to where is best location? If I move will it be able to detect then the password?
You should move it to somewhere not accessible from the web (that is outside the docroot). It's just a precaution, as the default apache configuration prohibits access to .ht* files.
Don't forget to change AuthUserFile with the new path to .htpasswd. Also make sure both .htaccess and .htpasswd are owned by the apache user and can be read only from it

newbie14 05-13-2012 09:38 AM

Dear Bathory,
I managed to solve the problem was in my httpd.conf. But when I do ls-ls I dont find both my .htaccess and .htpasswd file any reason for it? When I created both the file I was under the root account is that ok?

bathory 05-13-2012 09:52 AM

You need to run ls -la to see files starting with a dot
Anyways if you were root, then chances are that both files are in /root

John VV 05-14-2012 12:24 AM

Quote:

/var/www/html/phpMyAdmin-3.4
i would not have installed it there
the html folder is ALWAYS a problem

something like this with the doc root set to "html"
/var/www/cgi-bin
/var/www/html/"your CMS" -- and all it's folders
/var/www/MySql
/var/www/phpMyAdmin

then set the permissions, this way you can not edit "/var/www/phpMyAdmin" from within the "/var/www/html/" folder

This is how i set up a Cent / RHEL server and Apache 2
I do not use the rhel or cent rpm's . Because i like to keep things together and not scattered all over the place


All times are GMT -5. The time now is 07:56 PM.