LAMP配置详解

2010-08-09 15:13:23   2765

#chown -R root .
#chown -R mysql data
#chown -R mysql .

#./bin/mysqld_safe --user=mysql &
#cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

#chmod 700 /etc/rc.d/init.d/mysqld
#chkconfig --add mysqld
//
测试安装
#/usr/local/mysql/bin/mysqladmin ping
//
会显示mysql  alive
#/usr/local/mysql/bin/mysqladmin version
//
会显示mysql版本
#/usr/local/mysql/bin/mysql
//
会进入mysql命令提示符,可输入select 1+1;进行简单测试
//
添加root密码
#/usr/local/mysql/bin/mysqladmin -uroot -p
2
、安装zlib-1.2.3
#tar zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.3
#./configure --prefix=/usr/local/zlib
#make
#make install
3
、安装Apache
#tar zxvf httpd-2.2.6.tar.gz
#cd httpd-2.2.6
#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-track-vars --enable-rewrite --with-z-dir=/usr/local/zlib
#make
#make install
//
设置linux启动时同时启动apache服务
#echo "/usr/local/apache/bin/apachect1 start" >> /etc/rc.d/rc.local
4
、安装libpng-1.2.8
#tar zxvf libpng-1.2.8.tar.gz
#cd libpng-1.2.8
#cp scripts/makefile.linux makefile
#make
#make install
5
、安装freetype
#tar -zvxf freetype-2.1.10.tar.gz
#cd freetype-2.1.10
#mkdir -p /usr/local/freetype
#./configure --prefix=/usr/local/freetype
#make;make install
6
、安装jpegsrc.v6b
//
先建立目录
#mkdir -p /usr/local/jpeg6
#mkdir -p /usr/local/jpeg6/bin
#mkdir -p /usr/local/jpeg6/include
#mkdir -p /usr/local/jpeg6/man
#mkdir -p /usr/local/jpeg6man1
#mkdir -p /usr/local/jpeg6/man/man1
//
开始安装
#tar zxvf jpegsrc.v6b.tar.gz
#./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
#make
#make install
#make install-lib
7
、安装libxml2
#tar -zxvf libxml2-2.6.11.tar.gz
#cd libxml2-2.6.11
#mkdir -p /usr/local/libxml2
#./configure --prefix=/usr/local/libxml2
#make
#make install
#cp xml2-config /usr/bin
//
提示请按‘Y’进行确认
8
、安装gd
#tar -zvxf gd-2.0.33.tar.gz
#mkdir -p /usr/local/gd2
#cd gd-2.0.33
#./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype/
#make;make install
9
、安装php
#tar zvxf php-5.2.4.tar.gz
#mkdir -p /usr/local/php
#cd php-5.2.4
#./configure --prefix=/usr/local/php  \
>--with-apxs2=/usr/local/apache/bin/apxs  \
>--with-mysql-dir=/usr/local/mysql  \
>--with-xml=/sur/local/libxml2  \
>--with-png=/usr/local/lib  \
>--with-jpeg-dir=/usr/local/jpeg6  \
>--with-zlib=/usr/local/zlib  \
>--with-freetype=/usr/local/freetype  \
>--with-gd=/usr/local/gd  \
>--with-mysql-dir=/usr/local/mysql/bin/mysql_config  \
>--enable-track-vars  \
>--enable-soap  \
>--enable-mbstring=all  \
#make
#make install
#cp php.ini-dist /usr/local/php/lib/php.ini
//
使用vi修改httpd.conf
#vi /etc/httpd/httpd.conf
找到"#AddType application/x-gzip.gz.tgz"在下边加入一行:
AddType application/x-httpd-php .php
保存退出
启动apache服务
/usr/local/apache/bin目录下输入命令:./httpd -k start


到此,lamp已配置完成,可在/usr/local/apache/htdocs目录下放置php测试文件
test.php
内容包含:
<?php
phpinfo();
?>
然后在浏览器输入地址:http://localhost/test.php
若显示下图,则表明配置成功


这里有个问题,apache并没随系统一起启动

如果提示不能连接到localhost时,请在shell里进入目录
#cd /usr/local/apache/bin
#./httpd -k start
来启动apache
然后进行测试

 

LAMP配置详解,具体配置过程
声明:本教程经过在RedHat Linux 9上测试通过(使用VM虚拟机装的linux系统)
首先请下载软件包,共有9,包括库文件,分别为:
mysql_5.0.41
-linux-i686.tar.gz    zlib-1.2.3.tar.gz   httpd-2.2.6.tar.gz  
libpng-1.2.8.tar.gz  freetype-2.1.10.tar.gz  jpegsrc.v6b.tar.gz   
libxml2-2.6.11.tar.gz   gd-2.0.33.tar.gz  php-5.2.4.tar.gz
共计9个源码包,
请将下载的文件到到/root/soft目录下(soft文件夹自己建立)
然后在shell或终端下输入:cd soft
************************************************
注意:‘//’为注释或解释,不在命令范围
1
、安装mysql
#tar zxvf mysql-5.0.41-linux-i686.tar.gz
//
等待解压
#mv mysql-5.0.41-linux-i686 /usr/local/mysql
#groupadd mysql
#useradd -d /usr/local/mysql/data -s /sbin/nologin -g mysql mysql
#cd /usr/local/mysql
#./scripts/mysql_install_db --user=mysql