centos手动编译安装apache、php、mysql

64位centos 5.5手动安装lamp,要求curl、json、pdo_mysql、gd,记录如下。

centos 5.4、5.5、5.6的内核都是2.6.18,都可以安装php 5.3。

卸载旧版本apache、php、mysql:

sudo yum erase httpd
sudo yum erase php php-cli
sudo yum erase mysql

下载编译安装apache 2.2.19:

http://httpd.apache.org/download.cgi

cd ~
wget http://mirror.bjtu.edu.cn/apache/httpd/httpd-2.2.19.tar.bz2
tar -jxvf httpd-2.2.19.tar.bz2
cd httpd-2.2.19
sudo yum install gcc
./configure --prefix=/opt/httpd --enable-so --enable-rewrite
make
sudo make install
sudo /opt/httpd/bin/httpd -k start

安装完apache,用浏览器访问http://localhost,能正常显示说明装好了。

下载安装mysql 5.5.13:

http://dev.mysql.com/downloads/mysql/#downloads

下载这2个(64位的): MySQL-client MySQL-server

sudo yum install libaio
sudo rpm -i MySQL-client-5.5.13-1.rhel5.x86_64.rpm
sudo rpm -i MySQL-server-5.5.13-1.rhel5.x86_64.rpm
sudo /etc/init.d/mysql start
/usr/bin/mysqladmin -u root password '1'
sudo cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
sudo /etc/init.d/mysql restart
mysql -uroot -p1

下载编译安装php 5.3.6:

http://php.net/downloads.php

sudo yum install libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel libtool-ltdl-devel
tar -jxvf php-5.3.6.tar.bz2
cd php-5.3.6
./configure --prefix=/opt/php -with-apxs2=/opt/httpd/bin/apxs --with-curl --with-mcrypt --enable-mbstring --with-iconv --with-gd -with-jpeg-dir=/usr/local/lib --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd
make
sudo make install
sudo cp php.ini-development /opt/php/lib/php.ini
sudo ln -s /opt/php/bin/php /usr/bin/php
sudo vi /opt/php/lib/php.ini

把include_path前面的分号删除,改成include_path = "/opt/php/lib/php"
sudo vi /opt/httpd/conf/httpd.conf
在最下面加入一行AddHandler application/x-httpd-php .php
sudo /opt/httpd/bin/httpd -k restart
sudo vi /opt/httpd/htdocs/phpinfo.php

phpinfo.php的内容如下:

<?php
phpinfo();
?>

安装完php,重启apache,用浏览器访问http://localhost/phpinfo.php,能正常显示说明php装好了。搜索mysqlnd、pdo_mysql、mysqli,如果有,则说明php能访问mysql。

PHP常用配置

http://www.cnblogs.com/sink_cup/archive/2011/10/28/php_ini.html

把apache加入系统service,开机自启动

sudo cp /opt/httpd/bin/apachectl /etc/init.d/httpd
sudo vi /etc/init.d/httpd
在文件开头加入下面几行:
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server. 
sudo chmod +x /etc/init.d/httpd
sudo /sbin/chkconfig --add httpd
sudo /sbin/chkconfig --list httpd
sudo ln -s /sbin/chkconfig /usr/bin/chkconfig
sudo ln -s /sbin/service /usr/bin/service

把mysql加入系统service,开机自启动

sudo /sbin/chkconfig --list mysql

通过rpm安装的mysql,已经开机自启动了。

安装php扩展ssh2

先安装libssh2

http://sourceforge.net/projects/libssh2/

./configure

make

sudo make install

再安装ssh2

http://pecl.php.net/package/ssh2

/opt/php/bin/phpize && ./configure --with-ssh2 && make

sudo make install

在/opt/php/lib/php.ini中加1行:

extension=ssh2.so

centos 5.4升级到5.6:

先修改更新源为国内的更新源

cd /etc/yum.repos.d
sudo mv CentOS-Base.repo CentOS-Base.repo.save
sudo wget http://centos.ustc.edu.cn/CentOS-Base.repo

清理残留文件然后更新标准库,再升级

sudo yum clean all
sudo yum update glibc\*
sudo yum update yum\* rpm\* python\*
sudo yum clean all
sudo yum update
sudo reboot

Linux 设置服务器时区 UTC 0区

http://www.cnblogs.com/sink_cup/archive/2011/10/28/linux_utc_timezone.html

参考资料:

http://blog.chinaunix.net/u3/115899/showart_2258825.html

http://www.zhuoda.org/xiezhi/103050.html

http://dev.mysql.com/doc/refman/5.1/zh/installing.html#installation-layouts

http://ervanmardianto.com/php-ssh2-extensions

posted @ 2010-11-22 14:41 sink_cup 阅读(...) 评论(...) 编辑 收藏
Creative Commons License

本站原创作品采用知识共享署名 3.0许可协议进行许可。