centos手動編譯安裝apache、php、mysql

來源:互聯網
上載者:User
文章目錄
  • 先修改更新源為國內的更新源
  • 清理殘留檔案然後更新標準庫,再升級

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 httpdsudo yum erase php php-clisudo 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.bz2tar -jxvf httpd-2.2.19.tar.bz2cd httpd-2.2.19sudo yum install gcc./configure --prefix=/opt/httpd --enable-so --enable-rewritemakesudo make installsudo /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 libaiosudo rpm -i MySQL-client-5.5.13-1.rhel5.x86_64.rpmsudo rpm -i MySQL-server-5.5.13-1.rhel5.x86_64.rpmsudo /etc/init.d/mysql start/usr/bin/mysqladmin -u root password '1'sudo cp /usr/share/mysql/my-medium.cnf /etc/my.cnfsudo /etc/init.d/mysql restartmysql -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-develtar -jxvf php-5.3.6.tar.bz2cd 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=mysqlndmakesudo make installsudo cp php.ini-development /opt/php/lib/php.inisudo ln -s /opt/php/bin/php /usr/bin/phpsudo 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 .phpsudo /opt/httpd/bin/httpd -k restartsudo vi /opt/httpd/htdocs/phpinfo.php

phpinfo.php的內容如下:

<?phpphpinfo();?>

安裝完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/httpdsudo 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/httpdsudo /sbin/chkconfig --add httpdsudo /sbin/chkconfig --list httpdsudo ln -s /sbin/chkconfig /usr/bin/chkconfigsudo 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.dsudo mv CentOS-Base.repo CentOS-Base.repo.savesudo wget http://centos.ustc.edu.cn/CentOS-Base.repo
清理殘留檔案然後更新標準庫,再升級
sudo yum clean allsudo yum update glibc\*sudo yum update yum\* rpm\* python\*sudo yum clean allsudo yum updatesudo 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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.