1.卸载旧的lamp环境
命令:rpm -qa | grep httpd
说明:查看是否安装了httpd软件包
命令:netstat -tnl
说明:查看现在端口的状态,主要关注80端口(apache) 3306端口(MySQL)
命令:rpm -e httpd-manual-2.2.3-43.el5.CentOS --nodeps
命令:rpm -e httpd-2.2.3-43.el5.centos --nodeps
命令:rpm -e system-config-httpd-1.3.3.3-1.el5 --nodeps
说明:卸载软件包, --nodeps 如果有连带关系,也强制卸载
命令:cd /etc/httpd/
命令:rm -rf *
说明:到原来的apache安装目录下,将其所有的安装目录和文件都删掉
命令:rpm -qa | grep mysql
命令:rpm -e mysql-5.0.77-4.el5_4.2 --nodeps
说明:卸载mysql
命令: rpm -qa | grep php
命令: rpm -e php-common-5.1.6-27.el5 --nodeps
命令: rpm -e php-ldap-5.1.6-27.el5 --nodeps
命令: rpm -e php-cli-5.1.6-27.el5 --nodeps
命令: rpm -e php-5.1.6-27.el5 --nodeps
说明:卸载PHP
2.安装LAMP
(1).安装libxml2
cd libxml2-2.6.30/
./configure --prefix=/usr/local/libxml2
make
make install
(2).安装libmcrypt
cd libmcrypt-2.5.8/
./configure --prefix=/usr/local/libmcrypt
make && make install
(3).安装zlib
cd zlib-1.2.3/
./configure --prefix=/usr/local/zlib
make && make install
(4)安装libpng
cd libpng-1.2.31/
./configure --prefix=/usr/local/libpng
make && make install
(5)安装jpeg6
这个软件包安装有些特殊,其它软件包安装时如果目录不存在,
会自动创建,但这个软件包安装时需要手动创建
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man/man1
cd jpeg-6b/
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make && make install
(6)安装freetype
cd freetype-2.3.5/
./configure --prefix=/usr/local/freetype
make && make install
(7)安装autoconf
cd autoconf-2.61/
./configure //安装到系统库即可
make
make insatll
(8)安装GD库
cd gd-2.0.35/
./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/
make
make install
(9)安装apache
cd httpd-2.2.17/
./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --with-z=/usr/local/zlib --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support
make && make install
设置:apache(/etc/httpd/httpd.conf)
a.将LoadModule deflate_module modules/mod_deflate.so 注释掉
b.将ServerName :80 改为:ServerName localhost:80 并将前面的注释去掉
启动apache: /usr/local/apache2/bin/apachectl start
重启apache: /usr/local/apache2/bin/apachectl restart
停止apache: /usr/local/apache2/bin/apachectl stop
查看80端口是否开启
netstat -tnl|grep 80
(10)安装MySql
A.安装
groupadd mysql
useradd -g mysql mysql
./configure --prefix=/usr/local/mysql --with-extra-charsets=all
make && make install
B.配置
//创建mysql配置文件
cp support-files/my-medium.cnf /etc/my.cnf
//用mysql用户创建授权表,创建成功后,会在/usr/local/mysql目录下生成一个var目录
cd /usr/local/mysql/
./bin/mysql_install_db --user=mysql
//将文件的所有属性改为root用户
chown -R root .
//将数据目录的所有属性改为mysql用户
chown -R mysql var
//将组属性改为mysql组
chgrp -R mysql .
C.开启mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &
说明:‘&’表示在后台运行
//查看3306是否开启
netstat -tnl
//查看mysql版本信息
/usr/local/mysql/bin/mysqladmin version
//查看所有mysql参数
bin/mysqladmin variables
D.安全性
进入mysql 此时密码为空
/usr/local/mysql/bin/mysql -uroot
查看mysql 用户权限信息
msql>select * from mysql.user \G
删除非localhost的主机
DELETE FROM mysql.user WHERE Host!='localhost' AND User='';
刷新授权表
FLUSH PRIVILEGES;
为root用户添加密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
E.开启root用户的远程访问(如果是本地开发的话)
mysql>GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
mysql>flush privileges;
'%'表示任何主机都可以访问,最后面的‘root’为密码
F.关闭MySQL数据库
bin/mysqladmin -u root –p shutdown(如果有密码则-p 没有不需要写)