rhel5.5(linux)LAMP 源码安装(修正)

系统:redhat Enterprise Linux5.5

如若需要相关包 可以联系我QQ:429240967

1、安装mysql

下载mysql-5.1.56.tar.gz

tar -zxvf mysql-5.1.56.tar.gz
cd mysql-5.1.56
./configure /
--prefix=/usr/local/mysql /
--with-charset=utf8 /
--with-charset=gbk /
--with-charset=gb2312 /
--with-extra-charsets=utf8,gbk,gb2312 /
--enable-thread-safe-client /
--enable-assembler /
--with-readline /
--with-big-tables /
--with-innodb
make
make install

拷贝配置文件
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf

/usr/local/mysql/bin/mysql_install_db
将Mysql的目录权限进行设置
chown -R root /usr/local/mysql

chgrp -R mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/var
chmod 777/usr/local/mysql/var -R (这步如果没做 会影响到mysql无法启动,具体错误给忘了下次记的再贴)
自启动设置如下:

注意:启动MYSQL /usr/local/mysql/share/mysql/mysql.server start(restart|stop)
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
cd /etc/rc.d/rc3.d
设置数据库密码
/usr/local/mysql/bin/mysqladmin -u root password "123456"
至此 mysql数据库安装完成

2:安装APACHE

下载 httpd-2.2.3.tar.gz

apahce apr安装
#tar -zxvf apr-1.4.2.tar.gz
#cd apr-1.4.2
#./configure
#make
#make install

#tar -zxvf apr-util-1.3.9.tar.gz
#cd apr-util-1.3.9
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make
#make install

tar -zxvf httpd-2.2.3.tar.gz
cd httpd-2.2.3
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-maintainer-mode --with-mpm=prefork --enable-rewrite=shared --enable-userdir --enable-vhost-alias=shared --enable-cgi --enable-cgid --enable-expires=shared --enable-mem-cache=shared --enable-disk-cache=shared --enable-cache=shared --enable-deflate --enable-modules=all --enable-mods-shared=all
make
make install
注意:启动apache:/usr/local/apache2/bin/httpd -k start(restart|stop)
如果重新安装 要删除原来的安装目录 否则会出现问题
测试一下Apache配置文件的语法
/usr/local/apache2/bin/apachectl –t
启动Apache
/usr/local/apache2/bin/apachectl -k start&
将Apache添加到自动启动中
echo '/usr/local/apache2/bin/apachectl -k start&'>>/etc/rc.d/rc.local
检查Apache的端口是否跑起来了
netstat -an |grep 80


3:安装PHP(相关的包比较多 可以选择定制,红色为常用,其他的可以根据实际情况安装)

##### zlib #####
Zlib 软件包包含 zlib 库,很多程序中的压缩或者解压缩函数都会用到这个库.
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make && sudo make install

##### FreeType #####

tar -jxvf freetype-2.3.5.tar.bz2
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype
make && sudo make install

##### LibPNG #####

tar -zxvf libpng-1.2.20.tar.gz
cd libpng-1.2.20
cp scripts/makefile.linux makefile
./configure --prefix=/usr/local/libpng
make && make install

##### Jpeg (让GD支持JPEG)#####

tar -zxvf jpegsrc.v6b.tar.gz

mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make && make install

##### GD Library #####
tar -zxvf gd-2.0.35.tar.gz
cd gd-2.0.35

./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png --with-zlib=/usr/local/zlib

make && make install

安装过程可能出现以下错误信息

把报错信息“configure.ac:64: error: possibly undefined macro: AM_ICONV”


解决办法 (文件包已下载好)
到 http://www.gnu.org/software/gettext/下载了gettext-0.18.1.1.tar.gz
cp /usr/lib/libattr.* /lib/ (这个在转载的文章里没说,是因为make的时候报错说没有libattr.la这个文件,所以要复制过去)
tar xzf gettext-0.17.tar.gz
cd gettext-0.17
./configure
make
make install

经过以上操作,回去安装g d 就没有问题了!
##### ClibPDF ##### (跳过)

cd /tmp/ClibPDF-2.02/source
cp Makefile.Linux makefile
make && sudo make install

##### libxml2 #####

tar -zxvf libxml2-2.6.26.tar.gz
cd libxml2-2.6.26
./configure --prefix=/usr/local/libxml2 --with-zlib=/usr/local/zlib
make && make install

##### libxslt #####

tar -zxvf libxslt-1.1.17.tar.gz
cd libxslt-1.1.17
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
make && make install

##### curl #####

tar -zxvf curl-7.21.6.tar.gz
cd curl-7.21.6
mkdir -p /usr/local/curl
./configure --prefix=/usr/local/curl --with-ssl
make && make install

##### libmcrypt (加密扩展--有不少的加密算法)#####

tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install

##### mhash #####
tar -zxvf mhash-0.9.9.9.tar.g
cd mhash-0.9.9.9
./configure --prefix=/usr/local/mhash
make && make install
##### OpenSSL ##### (可选)

tar -zxvf openssl-1.0.0d.tar.gz
cd openssl-1.0.0d
./config --prefix=/usr/local/ssl /
--openssldir=/usr/local/ssl /
shared /
make && make install
ln -s /usr/local/ssl /usr/lib/ssl
_________________

##### PHP #####
tar -zxvf php-5.3.5.tar.gz
cd php-5.3.5


./configure --prefix=/usr/local/php5 /
--with-apxs2=/usr/local/apache2/bin/apxs /
--with-gd /
--enable-gd-native-ttf /
--with-jpeg-dir=/usr/local/jpeg--with-png /
--with-ttf /
--with-zlib /
--with-zlib-dir=/usr/local/zlib /
--with-mcrypt=/usr/local/libmcrypt /
--with-curl=/usr/local/curl /
--with-freetype-dir=/usr/local/freetype /
--with-mysql=/usr/local/mysql /
--with-mysql-sock=/tmp/mysql.sock /
--with-iconv /
--with-mbstring /
--enable-mbstring=all /
--enable-mbregex/
--enable-force-cgi-redirect/
--enable-ftp/
--with-openssl=/usr/local/ssl /
--with-openssl-dir=/usr/local/ssl /
--with-mhash=/usr/local/mhash /
--with-dom=/usr/local/libxml2 /
--with-xml-dir=/usr/local/libxml2 /
--with-xslt-dir=/usr/local/libxslt /
--with-pear=/usr/local/php/pear

make && sudo make install

cp php.ini-development /usr/local/php/lib/php.ini

在编译时加上-mcrypt选项时出错:

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
分析:
如果需要mcrypt,那么需要安装libltdl

解决办法:

cd /xok.la/tools/libmcrypt-2.5.8/libltdl
./configure -enable-ltdl-install
make


到这边LAMP环境安装完成
配置
##### 修改 Apache&PHP 配置文件 #####

vim /usr/local/apache2/conf/httpd.conf

LoadModule php4_module modules/libphp4.so
下添加:
AddType application/x-httpd-php .php .php3 .phtml
AddType application/x-httpd-php-source .phps

DirectoryIndex index.html
修改为
DirectoryIndex index.html index.php index.php3 index.phtml

DocumentRoot "/usr/local/apache2/htdocs"
修改为
DocumentRoot "/home/htdocs"


修改为


sudo gedit /usr/local/apache2/conf/php.ini

; UNIX: "/path1:/path2"
include_path = ".:/php/includes"
修改为
; UNIX: "/path1:/path2"
include_path = ".:/usr/local/php/includes"

doc_root =
修改为
doc_root = "/home/htdocs"

你可能感兴趣的:(linux)