Deploy phpMyAdmin and configure Apache to authenticate with LDAP

Source: Internet
Author: User
Tags install php ldap phpmyadmin fully qualified domain name

In fact, the configuration of Apache using LDAP authentication example, the previous PLA and Lam is a typical case, but this time to separate the configuration of Apache and LDAP integration, and the other is to build a lamp on Windows, the general will use such as XAMPP, such as integrated software , one-click installation of unified management apache/mysql/php, although we generally do not use a similar method on Linux (building lamp also has a variety of methods), but phpMyAdmin is also a simple and quick way to manage MySQL, so configure it here.

1. Preparatory work

/etc/init.d/iptables stopiptables-l-nsetenforce 0getenforceecho "192.168.49.134 phpmyadmin" >>/etc/hosts

2. Install and configure Apache

Yum-y Install httpd/etc/init.d/httpd Start

At this point, the general Apache boot will have the following tips:

Starting httpd:httpd:Could not reliably determine the server's fully qualified domain name, using 192.168.49.134 for Ser Vername

The servername can be added via sed and then restarted httpd service to resolve.

Sed-i '/#ServerName/aservername 192.168.49.134:80 '/etc/httpd/conf/httpd.conf/etc/init.d/httpd restartchkconfig HTTPD on

3. Install and configure MySQL

Yum-y install MySQL mysql-servermv/etc/my.cnf/etc/my.cnf.bak$ (date +%f) cp/usr/share/mysql/my-medium.cnf/etc/my.cnf /etc/init.d/mysqld startchkconfig mysqld onmysql_secure_installation# use Mysql_secure_ Installation script to set the password for the root user of MySQL or other settings/etc/init.d/mysqld restartmysql-uroot-p123456# test MySQL root account login

4. Install and configure PHP

Yum-y Install PHP php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcryp T Php-bcmath php-mhash libmcrypt# the PHP and other MySQL-related modules are installed here [[email protected] ~]# php--versionphp 5.3.3 (CLI) (Built:au G-20:33:53) Copyright (c) 1997-2010 the PHP groupzend Engine v2.3.0, Copyright (c) 1998-2010 Zend technologies# View P HP version [[email protected] ~]# mysql-vmysql Ver 14.14 distrib 5.1.73, for Redhat-linux-gnu (x86_64) using ReadLine 5.1# view Mys QL version

5. Download phpMyAdmin and configure directory permissions

wget Https://files.phpmyadmin.net/phpMyAdmin/4.0.10.17/phpMyAdmin-4.0.10.17-all-languages.zip-- NO-CHECK-CERTIFICATECP Phpmyadmin-4.0.10.17-all-languages.zip/var/www/html/cd/var/www/html/unzip Phpmyadmin-4.0.10.17-all-languages.zip MV Phpmyadmin-4.0.10.17-all-languages Phpmyadminchown-r Apache:apache phpMyAdmin

6. Browser Test phpMyAdmin

Enter http://192.168.49.134/phpmyadmin/in the browser and the phpMyAdmin login interface appears as follows:

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/87/3E/wKioL1fY5hLQNpvoAAEXsOSyiMk408.png-wh_500x0-wm_3 -wmp_4-s_553745205.png "style=" Float:none; "title=" 102.png "alt=" Wkiol1fy5hlqnpvoaaexsosyimk408.png-wh_50 "/>

Enter the root account password for MySQL and execute it.

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/87/3E/wKioL1fY5hSDvXqqAAIUw3gCBB8853.png-wh_500x0-wm_3 -wmp_4-s_3830726526.png "style=" Float:none; "title=" 104.png "alt=" Wkiol1fy5hsdvxqqaaiuw3gcbb8853.png-wh_50 "/>

Log in successfully, you can see the MySQL database, tables, users and other information, and here also shows the information about the server. Because only test phpMyAdmin installation configuration, not to hide or modify such information configuration, of course, if the production environment, Apache and MySQL need to be more detailed configuration, here is not more instructions.

7. Install Apahce LDAP module MOD_AUTHZ_LDAP

Yum-y Install Mod_authz_ldap

8. Configure Apache to authenticate through LDAP

cp/etc/httpd/conf.d/authz_ldap.conf/etc/httpd/conf.d/authz_ldap.conf.bak$ (Date +%f)

Check the contents of the/etc/httpd/conf.d/authz_ldap.conf file first

[Email protected] ~]# egrep-v "#|^$"/etc/httpd/conf.d/authz_ldap.conf

LoadModule Authz_ldap_module modules/mod_authz_ldap.so

<ifmodule mod_authz_ldap.c>

</IfModule>

Then edit the file and add the following below the <ifmodule mod_authz_ldap.c> statement:

<Directory/var/www/html/phpmyadmin> #这里定义那个目录需要使用ldap模块认证

Authzldapmethod LDAP

Authzldapserver 192.168.49.138

Authzldapuserbase ou=people,dc=contoso,dc=com

Authzldapuserkey UID

Authzldapuserscope Base


AuthType Basic

AuthName "Test LDAP auth"

Require Valid-user


</Directory>

[Email protected] ~]# diff/etc/httpd/conf.d/authz_ldap.conf.bak2016-09-13/etc/httpd/conf.d/authz_ldap.conf

9a10,23

> <Directory/var/www/html/phpmyadmin>

> Authzldapmethod LDAP

>

> Authzldapserver 192.168.49.138

> Authzldapuserbase ou=people,dc=contoso,dc=com

> Authzldapuserkey UID

> Authzldapuserscope Base

>

> AuthType Basic

> authname "Test LDAP auth"

> Require Valid-user

>

> </Directory>

>

/ETC/INIT.D/HTTPD restart

#最后重启httpd服务

9. Test Apache Using LDAP authentication

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/87/3E/wKioL1fY6OGwVDa0AAEgG3bb0-A700.png-wh_500x0-wm_3 -wmp_4-s_3891407069.png "style=" Float:none; "title=" 105.png "alt=" Wkiol1fy6ogwvda0aaegg3bb0-a700.png-wh_50 "/>

Open the browser, enter the address of the phpMyAdmin, found this time does not display the login interface, but requires authentication, enter the LDAP username and password, log in.

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/87/41/wKiom1fY6OLC2SemAAEU99tdymI564.png-wh_500x0-wm_3 -wmp_4-s_2413492209.png "style=" Float:none; "title=" 106.png "alt=" Wkiom1fy6olc2semaaeu99tdymi564.png-wh_50 "/>

After successful login, the login screen of phpMyAdmin is displayed, so you can log in with the root user of MySQL. Note that this article is to configure Apache to use LDAP to log in, not MySQL using LDAP login, so here is still to enter the MySQL username password login, and use the LDAP username password Authentication is only the browser to open the connection when the identity authentication, If you cannot log in to MySQL without authentication, even if you know the root password is not possible, this is a phpmyadmin to manage the MySQL reinforcement solution.


This article is from "it Little two lang" blog, please make sure to keep this source http://jerry12356.blog.51cto.com/4308715/1852711

Deploy phpMyAdmin and configure Apache to authenticate with LDAP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.