一.安裝mysql
1. 下載下傳mysql
wget http://download.softagency.net/MySQL/Downloads/MySQL-5.1/mysql-5.1.48.tar.gz
2. 安裝mysql
tar xvfz mysql-5.1.48.tar.gz
cd mysql-5.1.48
./configure --prefix=/usr/local/mysql
make
make install
3. 啟動mysql
/usr/local/mysql/bin/mysqld_safe
二.安裝apache
1.下載下傳apache
wget http://apache.freelamp.com/httpd/httpd-2.2.13.tar.gz
2.安裝apache
tar -xzvf httpd-2.2.13.tar.gz
cd httpd-2.2.13
./configure --prefix=/usr/local/apache --enable-mods-shared=most --enable-rewrite --enable-so
make;
make install
三.apache動态加載mysql認證子產品,apache安裝的時候沒有生成
1. 下載下傳子產品
Wget
http://ncu.dl.sourceforge.net/project/modauthmysql/modauthmysql/3.0.0/mod_auth_mysql-3.0.0.tar.gz
2. 針對apache2打更新檔
給mod_auth_mysql.c打更新檔,使該子產品支援apache2(更新檔檔案是apache2.2.diff)
cp apache2.2.diff mod_auth_mysql-3.0.0/
cd mod_auth_mysql-3.0.0
patch <apache2.2.diff
3. 生成子產品,具體怎麼生成可參考mod_auth_mysql-3.0.0目錄下的BUILD檔案
/usr/local/apache/bin/-c -L/usr/local/mysql/lib/mysql -I/usr/local/mysql/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c
/usr/local/apache/bin/apxs -i mod_auth_mysql.la
兩個指令敲完後會在apache的modules目錄下面生成mod_auth_mysql.so檔案
4. 修改apache配置檔案并重新開機apache程序,具體配置可參考/etc/httpd/conf.d/auth_mysql.conf 這個配置檔案,
vi /usr/local/apache/conf/httpd.conf
加載子產品:
LoadModule mysql_auth_module modules/mod_auth_mysql.so
對通路目錄認證
<Directory "/usr/local/apache/htdocs">
AuthBasicAuthoritative Off
AuthName "MySQL authenticated zone"
AuthType Basic
AuthMYSQLEnable on
AuthMySQLUser authuser
AuthMySQLPassword authpass
AuthMySQLDB auth
AuthMySQLUserTable users
AuthMySQLNameField user_name
AuthMySQLPasswordField user_passwd
require valid-user
</Directory>
配置說明:
AuthMySQLUser authuser 指定apache通路資料庫的使用者
AuthMySQLPassword authpass指定apache通路資料庫的密碼
AuthMySQLDB auth指定的是通路認證是使用的庫auth
AuthMySQLUserTable users指定的是通路認證使用的表
四.建立資料庫
1. 建立資料庫
CREATE DATABASE auth; //建立資料庫
USE auth;
CREATE TABLE users ( //建立表結構
user_name CHAR(30) NOT NULL,
user_passwd CHAR(20) NOT NULL,
PRIMARY KEY (user_name)
);
2. 在表中建立apache的登入認證使用者
INSERT INTO users VALUES ('test1', ENCRYPT('pass1'));
3. 為apache通路mysql建立連接配接使用者,賦予authuser所有權限通路auth庫,僅僅在實驗環境中才這樣哦,請不要模仿
Use mysql
grant all privileges on auth.* to [email protected] identified by 'authpass' with grant option;
五.安裝PHP,如果僅僅是支援apache和mysql下面的一些編譯參數都用不到,下列的一些參數在安裝cacti時要用到,否則要重新編譯安裝一次php
wget http://cn.php.net/distributions/php-5.3.3.tar.gz
tar xvfz php-5.3.3.tar.gz
cd php-5.3.3
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-gd --with-snmp --with-ldap --with-gettext --with-config-file-path=/usr/local/php/etc --enable-sockets
Make
Make install
轉載于:https://blog.51cto.com/xiaochong/415174