关于:redhat LAMP环境的搭建(源代码安装)
other /
2013年01月03日 22时48分 /
13107人浏览
LAMP环境的搭建
1.了解安装方式
Rpm 二进制 rpm命令 体积小 快 简单
.tar.gz 源代码 gcc 体积大 慢 麻烦
2.下载相应软件
1)Apache
2)Mysql
3)php
3.检查编译工具
我这里要装的是tar包,这种是源代码软件,需要使用gcc对它进行编译,编译成二进制可执行文件
[root@localhost ~]# gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.5/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)
4.卸载相应文件
系统默认安装的这几个软是rpm格式,我这里要装的是源代码形式的,这两种是有冲突,所以我们要把系统之前安装的apache、mysql、php删除
1)查询和删除apache
查询:[root@localhost ~]# rpm -qa |grep httpd
将查选出的结果依次卸载,删除命令如下:
删除:rpm -e httpd --nodeps
2)查询和删除mysql
查询:[root@localhost ~]# rpm -qa |grep mysql
将查选出的结果依次卸载,删除命令如下:
删除:rpm -e mysql --nodeps
3)查询和删除php
查询:[root@localhost ~]# rpm -qa |grep php
将查选出的结果依次卸载,删除命令如下:
删除:rpm -e php --nodeps
5.了解编译过程
.tar.gz
1)configure 配置
2)make 编译
3)make install 安装
6.安装相应软件
安装apache
1)tar -zxvf httpd.tar.gz
2)cd httpd-2.2.11/
3)对软件进行配置
[root@localhost Lamp]# cd httpd-2.2.11
[root@localhost httpd-2.2.11]# ./configure \
> --prefix=/usr/local/apache/ \
> --enable-so
4)生成可执行文件
make
5)安装
make install
6)启动apache
/usr/local/apache/bin/apachectl start
7)查端口
netstat –natup
80端口被httpd占用说明成功
安装mysql
groupadd mysql 新建mysql组
useradd -g mysql mysql 为mysql组添加mysql用户
tar -zxvf mysql-standard-5.0.27.tar.gz
mv mysql-standard-5.0.27 /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql 初始化数据库信息
chown -R root . 改变拥有者
chown -R mysql data 改变拥有者
chgrp -R mysql . 改变所属组
bin/mysqld_safe --user=mysql & 后台启动mysql服务
bin/mysql –u root 登陆mysql
安装php
tar -zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql
make
make install
Cd /usr/local/apache/conf,编辑apache的配置文件,在addType语句段之后(大约310行)处添加以下语句:
AddType application/x-httpd-php .php 表示解析php文件的类型
重启apache
开始测试
创建一个测试页面,输出phpinfo();
现在可以正常解析php,但通过phpinfo的输出我们得知,php没有配置文件,
到php的安装包中,将php.ini-dist复制到指定的目录下,如:
cp php.ini-dist /usr/local/php/lib/php.ini
并重启apache,即可看到加载到的php的配置文件!
设置开机自动启动
目前,所有的服务重启之后需要手动启动,可以这样设置自动开机启动:
vi /etc/rc.d/rc.local
/usr/local/apache/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe --user=mysql &