Red Hat Linux 9下部署LAMP环境--原创
作 者:Flyinger
Email:flyingercn#gmail.com
QQ:46715422
--转载请注明出处!
系统环境:
[root@RedHat9 php-5.2.9]# uname -a
Linux RedHat9 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux
[root@RedHat9 php-5.2.9]# gcc --version
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@RedHat9 php-5.2.9]# perl -v
This is perl, v5.8.0 built for i386-linux-thread-multi
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2002, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at , the Perl Home Page.
[root@RedHat9 php-5.2.9]# python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
检测完环境开始安装
安装MySQL之前先检查下系统中是否已经存在MySQL,这点很重要,有则先卸载:
[root@RedHat9 soft]# rpm -qa|grep mysql
推荐使用RPM方式安装MySQL:
[root@RedHat9 soft]# rpm -ivh MySQL-shared-5.1.34-0.glibc23.i386.rpm
[root@RedHat9 soft]# rpm -ivh MySQL-devel-5.1.34-0.glibc23.i386.rpm
[root@RedHat9 soft]# rpm -ivh MySQL-client-5.1.34-0.glibc23.i386.rpm
[root@RedHat9 soft]# rpm -ivh MySQL-shared-compat-5.1.34-0.glibc23.i386.rpm
[root@RedHat9 soft]# rpm -ivh MySQL-embedded-5.1.34-0.glibc23.i386.rpm
[root@RedHat9 soft]# rpm -ivh MySQL-debuginfo-5.1.34-0.glibc23.i386.rpm
[root@RedHat9 soft]# rpm -ivh MySQL-server-5.1.34-0.glibc23.i386.rpm --nodeps
设置mysql密码为root
[root@RedHat9 soft]# mysqladmin -u root password 'root'
安装libiconv-1.13.tar.gz库
[root@RedHat9 soft]# tar zxvf libiconv-1.13.tar.gz
[root@RedHat9 soft]# cd libiconv-1.13
[root@RedHat9 soft]# ./configure --prefix=/usr/local/libiconv
[root@RedHat9 soft]# make && make install
安装freetype-2.3.5.tar.gz库
[root@RedHat9 soft]# tar zxvf freetype-2.3.5.tar.gz
[root@RedHat9 soft]# cd freetype-2.3.5
[root@RedHat9 soft]# ./configure
[root@RedHat9 soft]# make && make install
安装libpng-1.2.33.tar.gz库
[root@RedHat9 soft]# tar zxvf libpng-1.2.33.tar.gz
[root@RedHat9 soft]# cd libpng-1.2.33
[root@RedHat9 soft]# cp scripts/makefile.linux makefile
[root@RedHat9 soft]# make && make install
安装jpegsrc.v6b.tar.gz库
[root@RedHat9 soft]# tar zxvf jpegsrc.v6b.tar.gz
[root@RedHat9 soft]# cd jpeg-6b
[root@RedHat9 soft]# mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
[root@RedHat9 soft]# ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
[root@RedHat9 soft]# make && make install && make install-lib
安装libxml2-2.6.31.tar.gz库
[root@RedHat9 soft]# tar zxvf libxml2-2.6.31.tar.gz
[root@RedHat9 soft]# cd libxml2-2.6.31
[root@RedHat9 soft]# ./configure
[root@RedHat9 soft]# make && make install
安装libmcrypt-2.5.8.tar.gz库
[root@RedHat9 soft]# tar zxvf libmcrypt-2.5.8.tar.gz
[root@RedHat9 soft]# cd libmcrypt-2.5.8
[root@RedHat9 soft]# ./configure
[root@RedHat9 soft]# make && make install
[root@RedHat9 soft]# /sbin/ldconfig
[root@RedHat9 soft]# cd libltdl
[root@RedHat9 soft]# ./configure --enable-ltdl-install
[root@RedHat9 soft]# make && make install
安装mhash-0.9.9.tar.gz库
[root@RedHat9 soft]# tar zxvf mhash-0.9.9.tar.gz
[root@RedHat9 soft]# cd mhash-0.9.9
[root@RedHat9 soft]# ./configure
[root@RedHat9 soft]# make && make install
安装mcrypt-2.6.7.tar.gz库
[root@RedHat9 soft]# tar zxvf mcrypt-2.6.7.tar.gz
[root@RedHat9 soft]# cd mcrypt-2.6.7
[root@RedHat9 soft]# cp /usr/local/lib/libmcrypt*.* /usr/lib
[root@RedHat9 soft]# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
[root@RedHat9 soft]# ./configure
[root@RedHat9 soft]# make && make install
安装curl-7.19.0.tar.gz库
[root@RedHat9 soft]# tar zxvf curl-7.19.0.tar.gz
[root@RedHat9 soft]# cd curl-7.19.0
[root@RedHat9 soft]# ./configure
[root@RedHat9 soft]# make && make install
安装zlib-1.2.3.tar.gz库
[root@RedHat9 soft]# tar zxvf zlib-1.2.3.tar.gz
[root@RedHat9 soft]# cd zlib/1.2.3/
[root@RedHat9 soft]# ./configure
[root@RedHat9 soft]# make && make install
安装gd-2.0.33.tar.tar库
[root@RedHat9 soft]# tar zxvf gd-2.0.33.tar.tar
[root@RedHat9 soft]# cd gd-2.0.33
[root@RedHat9 soft]# ./configure --with-libiconv-prefix --with-png --with-freetype --with-jpeg-dir=/usr/local/jpeg/
[root@RedHat9 soft]# make && make install
安装apache
[root@RedHat9 soft]# tar zxvf httpd-2.2.11.tar.gz
[root@RedHat9 soft]# cd httpd-2.2.11
[root@RedHat9 soft]# ./configure --prefix=/usr/local/apache --enable-so
[root@RedHat9 soft]# make && make install
设置linux启动时同时启动apache服务
[root@RedHat9 soft]# echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.d/rc.local
安装php-5.2.9.tar.gz
[root@RedHat9 soft]# tar zxvf php-5.2.9.tar.gz
[root@RedHat9 soft]# cd php-5.2.9
[root@RedHat9 soft]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-jpeg-dir=/usr/local/jpeg/ --with-libxml-dir --with-curl --with-gd --with-zlib-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-ttf --with-mcrypt --with-mhash --with-libmcrypt --with-mysql --enable-track-vars --enable-ftp --enable-soap --enable-mbstring=all
[root@RedHat9 soft]# make && make install
[root@RedHat9 soft]# cp php.ini-dist /usr/local/php/lib/php.ini
编辑/usr/local/php/lib/php.ini文件
[root@RedHat9 soft]# vi /usr/local/php/lib/php.ini
将“ ;default_charset = "iso-8859-1" ”改为“ default_charset = "utf-8" ”;将“ ;session.save_path = "/tmp" ”改为“ session.save_path = "/tmp" ”。
编辑apache配置文件httpd.conf
[root@RedHat9 soft]# vi /usr/local/apache/conf/httpd.conf
要改的有如下几处:
找到LoadModule php5_module modules/libphp5.so,将前面的#号去掉;
找到#AddType application/x-gzip .gz .tgz
在下面加二行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
还有找到
DirectoryIndex index.html
改为
DirectoryIndex index.html index.php index.htm index.phtml
找到DocumentRoot "/usr/local/apache/htdocs" 和
把/usr/local/apache/htdocs改为你存放网页文件的路径,比如DocumentRoot "/www"和
在/www目录下建立php测试文件如下:
[root@RedHat9 soft]# vi /www/test.php
内容如下
phpinfo();
?>
然后在浏览器中输入:将会看见php和系统的相关信息。
阅读(1757) | 评论(0) | 转发(0) |