三 Mysql
1.卸载MySQL的RPM包
rpm -e mysql --nodeps
2.安装cmake包
tar zxf cmake-2.8.6.tar.gz
cd cmake-2.8.6
./configure
gmake && gmake install
3.创建数据库程序账户和组
groupadd mysql
useradd -M -s /sbin/nologin mysql -g mysql
4.编译安装MySQL
(1)解压:tar zxf mysql-5.5.22.tar.gz -C /usr/src/
(2)配置:cd /usr/src/mysql-5.5.22/
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql (注:MySQL安装目录)
-DSYSCONFDIR=/etc (注:MySQL配置文件路径)
-DDEFAULT_CHARSET=utf8 (注:字符集)
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
(3)编译: make
(4)安装: make install
5.安装后调整
[[email protected] ~]# chown -R mysql:mysql /usr/local/mysql (注:更改MySQL安装目录属主,属组)
[[email protected] mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf (注:复制MySQL配置文件)
[[email protected] mysql-5.5.22]# /usr/local/mysql/scripts/mysql_install_db
--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ (注:初始化数据库)
[[email protected] mysql-5.5.22]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile (注:添加环境变量)
[[email protected] mysql-5.5.22]# . /etc/profile (注:刷新环境变量)
6.注册成系统服务
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
7.启动服务
service mysqld start
8.设置数据库用户的密码
mysqladmin -u root [-p] password 新密码
四 LAMP
1.卸载PHP
rpm -e php --nodeps
2.安装加密工具
数据加密工具libmcrypt、mhash、mcrypt
(1)安装libmcrypt
tar zxf libmcrypt-2.5.8.tar.gz -C /usr/src/
cd /usr/src/libmcrypt-2.5.8/
./configure
make && make install
ln -s /usr/local/lib/libmcrypt. /usr/lib/
(2) 安装mhash
tar zxf mhash-0.9.9.9.tar.gz -C /usr/src/
cd /usr/src/mhash-0.9.9.9/
./configure
make && make install
ln -s /usr/local/lib/libmhash /usr/lib/
(3) 安装mcrypt
tar zxf mcrypt-2.6.8.tar.gz -C /usr/src/
cd /usr/src/mcrypt-2.6.8/
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure
make && make install
3.安装PHP
tar zxf php-5.3.28.tar.gz -C /usr/src/
cd /usr/src/php-5.3.28/
./configure --prefix=/usr/local/php5
--with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs
--with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5
--enable-mbstring
make
make install
4.配置文件/usr/local/php5/php.ini调整
(1)复制模板:cp /usr/src/php-5.3.28/php.ini-development /usr/local/php5/php.ini
(2)修改配置: vim /usr/local/php5/php.ini
default_charset = "utf-8”
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
post_max_size = 8M
short_open_tag = On
(3)添加zend优化模块
tar zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ 、
cp ZendGuardLoader.so /usr/local/php5/lib/php/
vim /usr/local/php5/php.ini
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
5.apache配置文件修改
vim /usr/local/httpd/conf/httpd.conf
LoadModule php5_module modules/libphp5.so (注:如果正常,则自动填写)
AddType application/x-httpd-php .php (注:需要个人添加)
DirectoryIndex index.php index.html
6.重启Apache
/usr/local/httpd/bin/apachectl restart
7.测试PHP能否正确显示
vim /usr/local/httpd/htdocs/test1.php
<?php
phpinfo( );
?>
8.测试数据库能否正常访问
vi /usr/local/httpd/htdocs/test2.php
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘123456‘);
if($link) echo "恭喜你,数据库连接成功啦!!";
mysql_close();
?>
9.配置phpMyAdmin数据库管理套件
(1)解包,并复制到网站目录
tar zxf phpMyAdmin-4.2.5-all-languages.tar.gz
mv phpMyAdmin-4.2.5-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin
(2)建立配置文件config.inc.php
cd /usr/local/httpd/htdocs/phpMyAdmin
cp config.sample.inc.php config.inc.php
(3)在浏览器访问http://域名或IP/phpMyAdmin/
原文地址:http://blog.51cto.com/13550558/2087772