CentOS 5.5 x64 源码安装 LAMP
1.系统 CentOS5.5 x64 配置好IP地址,主机名等信息
2.安装必备软件
yum install -y gcc-c++ yum install -y make yum install -y unzip yum install -y openssl-devel yum install -y libxml2-devel yum install -y ncurses-devel yum install -y gettext gettext-devel 安装包 httpd-2.2.14.tar.gz fontconfig-2.8.0.tar.gz freetype-2.3.5.tar.gz gd-2.0.35.tar.gz jpegsrc.v6b.tar.gz libmcrypt-2.5.7.tar.gz libpng-1.2.26.tar.gz libtool-2.2.6a.tar.gz mysql-5.1.49.tar.gz ncurses-5.6.tar.gz php-5.2.9.tar.tar zlib-1.2.3.tar.gz phpMyAdmin-3.3.5-all-languages.tar.gz 将源码包上传到 /usr/local 目录下
3.检查系统是否已经安装 apache 或 mysql
检查 apache rpm -qa|grep httpd 如果存在 则 卸载 apache rpm -e httpd --nodeps 检查 mysql rpm -qa|grep mysql 如果存在 则 卸载 mysql rpm -e mysql --nodeps
4.开始安装
4.1 安装apache
cd /usr/local/ tar zxvf httpd-2.2.14.tar.gz cd httpd-2.2.14 cd srclib/apr ./configure --prefix=/usr/local/apr && make && make install cd .. cd apr-util ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install cd ../.. ./configure --prefix=/usr/local/apache2214 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-expires --enable-ssl --enable-modules --enable-rewrite --enable-dav --enable-so --enable-maintainer-mode --with-expat --enable-proxy --enable-headers --enable-deflate && make && make install
设置Apache随系统启动,拷贝一个启动shell
cp /usr/local/apache2214/bin/apachectl /etc/rc.d/init.d/httpd2214 chmod 700 /etc/rc.d/init.d/httpd2214
编辑/etc/rc.d/init.d/httpd2214,在
# # |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| # --------------------
后面添加如下三行并保存:
#Comments to support chkconfig on RedHat Linux #chkconfig: 2345 90 90 #description:http server
继续配置Apache随系统启动:
chkconfig --add httpd2214 chkconfig --level 345 httpd2214 on
启动apache:
/etc/rc.d/init.d/httpd2214 start
检查启动是否成功:
netstat -tnlap | grep httpd
安装MySQL数据库添加mysql用户:
useradd mysql
开始安装mysql:
tar zxvf mysql-5.1.49.tar.gz cd mysql-5.1.49 ./configure --prefix=/usr/local/mysql5149 --sysconfdir=/etc/mysql5149/ --enable-static --enable-assembler --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312,binary,ascii --with-mysqld-user=mysql --with-plugins=all --with-readline --with-ssl --with-vio && make && make install
配置文件和mysql启动脚本:
mkdir -p /etc/mysql5149 cp support-files/my-medium.cnf /etc/mysql5149/my.cnf cp support-files/mysql.server /etc/rc.d/init.d/mysqld5149
设置开机自动启动:
chmod 700 /etc/rc.d/init.d/mysqld5149 chkconfig --add mysqld5149 chkconfig --level 345 mysqld5149 on
初始化授权表:
useradd mysql /usr/local/mysql5149/bin/mysql_install_db --user=mysql --datadir=/usr/local/mysql5149/var/
启动mysql:
/etc/rc.d/init.d/mysqld5149 start
把mysql客户端启动加入环境变量:
ln -s /usr/local/mysql5149/bin/mysql /usr/bin/mysql
给数据库root用户加入密码
mysqladmin -u root password 你的密码
安装php1.安装ncurses-5.6
tar zxvf ncurses-5.6.tar.gz cd ncurses-5.6 ./configure --prefix=/usr --with-shared --without-debug && make && make install
2.安装zlib2
tar zxvf zlib-1.2.3.tar.gz cd zlib-1.2.3 CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/zlib make && make install
3.安装PNG
tar zxvf libpng-1.2.26.tar.gz cd libpng-1.2.26 cp scripts/makefile.linux ./makefile ./configure --prefix=/usr/local/libpng && make && make install
4.安装ttf
tar zxvf freetype-2.3.5.tar.gz cd freetype-2.3.5 ./configure --prefix=/usr/local/freetype && make && make install
5.安装JPEG6
tar zxvf jpegsrc.v6b.tar.gz cd jpeg-6b mkdir -pv /usr/local/libjpeg/{,bin,lib,include,man/man1,man1} ./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static && make && make install
如果使用上述方法系统出现如下错误:
./libtool --mode=compile gcc -O2 -I. -c ./jcapimin.c make: ./libtool: Command not found make: *** [jcapimin.lo] Error 127
原因在于libtool版本过低导致的,重新下载新版本的libtool以默认方式安装:
wget http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz tar xvfz libtool-2.2.6a.tar.gz cd libtool-2.2.6 ./configure && make && make install
然后进入jpeg-6b的源码目录,执行:
cd jpeg-6b mkdir -pv /usr/local/libjpeg/{,bin,lib,include,man/man1,man1} cp /usr/local/share/libtool/config/config.sub . cp /usr/local/share/libtool/config/config.guess . ./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static make mkdir -p /usr/local/man/man1 make install
6.安装 libmcrypt-2.5.7.tar.gz
tar zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure && make && make install
7.安装Fontconfig
tar -zxvf fontconfig-2.8.0.tar.gz cd fontconfig-2.8.0 ./configure --prefix=/usr --with-freetype-config=/usr/local/freetype/bin/freetype-config && make && make install
8.安装GD库
tar zxvf gd-2.0.35.tar.gz cd gd-2.0.35 ./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/libjpeg --with-fontconfig
看到如下支持信息,说明我们的安装进展顺利:
Support for PNG library: yes Support for JPEG library: yes Support for Freetype 2.x library: yes Support for Fontconfig library: yes Support for Xpm library: no Support for pthreads: yes
然后
make && make install
继续
tar zxvf php-5.2.9.tar.gz cd php-5.2.9
64位系统:
./configure --prefix=/usr/local/php529 --with-apxs2=/usr/local/apache2214/bin/apxs --with-mysql=/usr/local/mysql5149 --with-gd --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --with-libxml-dir=/usr --with-zlib-dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets
64位系统如果需要支持汉字写入图片,即GD库支持中文写入图片,需要更改为:
./configure --prefix=/usr/local/php529 --with-apxs2=/usr/local/apache2214/bin/apxs --with-mysql=/usr/local/mysql5149 --with-gd --enable-gd-native-ttf --with-ttf --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --with-libxml-dir=/usr --with-zlib-dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets
成功提示信息是:Thank you for using PHP.
如果出现错误提示:undefinedreferenceto`libiconv_open’,一般情况此服务器升级过libiconv,解决方法:
生成makefile参数增加–with-iconv=/usr/local即可,具体取决于当时安装libiconv的路径。
继续make和makeinstall。
拷贝一个配置文件作为php.inicp php.ini-dist /usr/local/php529/lib/php.ini
修改 apache 配置文件 httpd.conf,加一行代码使之支持PHP:
AddType application/x-httpd-php .php
然后重启 apache
/etc/rc.d/init.d/httpd2214 restart
给php加入环境变量:
ln -s /usr/local/php529/bin/php /usr/bin/php
相关推荐
全文使用的环境如题,主机使用的是腾讯云主机。内容应该会是linux和apache这些所有部分都有一点,因为是遇见一个问题就记录一个。 尝试清除浏览器缓存/换一个浏览器验证/重启服务器的apache服务