redhat 搭建LAMP环境
1.安装mysql
这里用rpm包安装,需要一下四个rpm包:
MySQL-server-5.0.45-0.i386.rpm
MySQL-devel-5.0.45-0.i386.rpm
MySQL-client-5.0.45-0.i386.rpm
MySQL-shared-5.0.45-0.i386.rpm
直接执行:
#rpm –ivh Mysql-*.rpm
设置密码:
# mysqladmin -u root password 密码。
配置:
这部分转自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/10/18/2216087.html
/**********************************************************************/
[mysqld]后添加添加lower_case_table_names设成1来不区分表名的大小写
grant all on *.* to user_1@'localhost' Identified by '123';
grant all on *.* to 'root'@'ip' identified by 'password';
/***********************************************************************************/
2.安装apache
这部分转自:http://www.cnblogs.com/huzhiwei/archive/2012/07/19/2599854.html
/***********************************************************************************/
不知道为什么在安装apache2.2.22版本的时候没有任何问题,直接使用命令
./configure --prefix=/usr/local/apache2 –-sysconfdir=/etc/httpd --enable-proxy --enable-so --enable-mods-shared=most --with-mpm=worker --enable-shared=max --enable-module=rewrite --enable-module=so
没有任何问题,不过在安装新版本2.4.2的时候就会报错。
解决方案如下:
#./configure --prefix……检查编辑环境时出现:
checking for APR... no
configure: error: APR not found . Please read the documentation.
可以用./configure –help | grep apr 查看帮助。
--with-included-apr Use bundled copies of APR/APR-Util
--with-apr=PATH prefix for installed APR or the full path to apr-config
--with-apr-util=PATH prefix for installed APU or the full path to
安装APR(Apache Portable Runtime )
[root@localhost ~]# cd /tmp/52lamp/ //源码存放位置
[root@localhost 52lamp]# tar -zxvf apr-1.4.2.tar.gz //unzip -o apr-1.4.2.zip
[root@localhost 52lamp]# cd apr-1.4.2
[root@localhost apr-1.4.2]# ./configure
[root@localhost apr-1.4.2]# make
[root@localhost apr-1.4.2]# make install
再次检查编译环境出现
checking for APR-util... no
configure: error: APR-util not found . Please read the documentation.
[root@localhost httpd-2.2.16]# ./configure –help | grep apr-util
--with-apr-util=PATH prefix for installed APU or the full path to
[root@localhost 52lamp]# tar -zxvf apr-util-1.3.9.tar.gz
[root@localhost 52lamp]# cd apr-util-1.3.9
[root@localhost apr-util-1.3.9]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.3.9]# make
[root@localhost apr-util-1.3.9]# make install
./configure仍提示APR-util not found,增加--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util后出现
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@localhost httpd-2.2.16]# ./configure –help | grep pcre
--with-pcre=PATH Use external PCRE library
[root@localhost 52lamp]# unzip -o pcre-8.10.zip
[root@localhost 52lamp]# cd pcre-8.10
[root@localhost cd pcre-8.10]# ./configure --prefix=/usr/local/pcre
[root@localhost cd pcre-8.10]# make
[root@localhost cd pcre-8.10]# make install
继续安装Apache/httpd,./configure 时加上参数 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre,这个问题就解决了。
/***********************************************************************************/
测试一下Apache配置文件的语法
/usr/local/apache2/bin/apachectl –t
启动Apache
/usr/local/apache2/bin/apachectl -k start&
我在安装的时候就有明明安好,但是无法启动apache的现象,百思不得其解。后来换了个低版本的安装,就发现能够正常启动了。好像是apache对apr和apr-util的版本是有要求的。
将Apache添加到自动启动中
echo '/usr/local/apache2/bin/apachectl -k start&'>>/etc/rc.d/rc.local
检查Apache的端口是否跑起来了
netstat -an |grep 80
将Apache添加到系统服务中去
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc4.d/S61httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc5.d/S61httpd
vim /etc/rc.d/init.d/httpd
在第二行处添加:
#chkconfig:345 61 61
#description:Apache
执行:
chkconfig --add httpd
ok,apache安装完毕
3、安装PHP
这部分转自:http://www.fkblog.org/blog619
##### 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 就没有问题了!
##### 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
##### PHP #####
下载php
php下载地址:http://php.net/downloads.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-curl=/usr/local/curl --with-freetype-dir=/usr/local/freetype --with-mysql --with-iconv --with-mbstring --enable-mbstring=all --enable-ftp --with-libxml=/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
如果编译时出现错误,请注意错误提示!
到这边LAMP环境安装完成
4、Apache+PHP配置
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .php5 .phtml
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.php index.php5 index.phtml
DocumentRoot"/var/www"