`

linux下apache+php+mysql升級安裝過程

阅读更多

由於伺服器linux版本太低,apache+php+mysql版本都太低,初次學習linux經過三天除了吃飯睡覺終於把apache+php+mysql給升級了!現說下升級過程:

    一刪除apache+php+mysql:

    判斷是不是rpm安裝如:rpm -q php 返回php版本,則是rpm安裝,用 rpm -e php --nodeps 即可徹底刪除系統自帶的php

    如果不返回PHP版本則是二進位安裝,直接刪除目錄就可以!同理apache mysql也一樣!

    二安裝apache

    下載httpd-2.2.4.tar.gz

    tar xzvf httpd-2.2.4.tar.gz
    cd httpd-2.2.4
    ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-cgi --enable-rewrite --enable-deflate --with-mpm=worker
    make
    make install

    三 安裝mysql

    # chmod 755 mysql-5.0.45-linux-i686-glibc23.tar.gz //設置mysql-5.0.45-linux-i686-glibc23.tar.gz屬性為755
    # tar xzvf mysql-5.0.45-linux-i686-glibc23.tar.gz //解壓
    # cp -r mysql-5.0.45-linux-i686-glibc23 /usr/local //
    # mv mysql-5.0.45-linux-i686-glibc23 mysql //
    # cd mysql //
    # groupadd mysql // 建立mysql組
    # useradd mysql -g mysql //建立mysql用戶並且加入到mysql組中
    # cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
    在 support-files目錄下有4個模版文件,我們選擇其中一個座位Mysql的配置文件,覆蓋/etc/my.cnf(系統默認的配置,其中設置了性能參數和Mysql的一些路徑參數)
    # cd /usr/local/mysql 進入mysql目錄
    # ./scripts/mysql_install_db --user=mysql //初試化表並且規定用mysql用戶來訪問。初始化表以後就開始給mysql和root用戶設定訪問許可權
    # chown -R root //設定root能訪問/usr/local/mysql
    # chown -R mysql data //設定mysql用戶能訪問/usr/local/mysql/data 裏面存的是mysql的數據庫文件.這個目錄是在/etc/my.cnf中有配置,在mysql_install_db時產生。
    # chown -R mysql data/ //設定mysql用戶能訪問/usr/local/mysql/data/mysql下的所有文件
    # chgrp -R mysql //設定mysql組能夠訪問/usr/local/mysql
    # /usr/local/mysql/bin/mysqld_safe --user=mysql & 運行mysql 如果沒有問題的話,應該會出現類似這樣的提示:
    [1] 42264
    # Starting mysqld daemon with databases from /usr/local/mysql/var
    如果出現 mysql ended這樣的語句,表示Mysql沒有正常啟動,你可以到log中搜尋問題,Log文件的通常在/etc/my.cnf中配置。大多數問題是許可權設置 不正確引起的。
    # /usr/local/mysql/bin/mysqladmin -u root password yourpassword //默認安裝密碼為空,為了安全你必須馬上修改.
    # cp support-files/mysql.server /etc/rc.d/init.d/mysqld 設置使mysql每次啟動都能自動運行
    # chmod 700 /etc/init.d/mysqld
    # chkconfig --add mysqld
    # chkconfig --level 345 mysqld on
    # service mysqld start //啟動mysqld服務
    # netstat -atln //查看3306端口是否打開。要注意在防火牆中開放該端口。

    四安裝php

    1. 安裝zlib (安裝libpng和gd前需要先安裝zlib),
    # tar zxvf zlib-1.2.3.tar.gz
    # cd zlib-1.2.3
    # ./configure
    # make;make install

    2. 安裝libpng,
    # tar zxvf libpng-1.2.12.tar.gz
    # cd libpng-1.2.12
    # ./configure
    # make;make install

    3. 安裝freetype,
    # tar zxvf freetype-2.2.1.tar.gz
    # cd freetype-2.1.10
    # ./configure --prefix=/usr/local/freetype
    # make;make install

    4. 安裝jpeg,
    # tar zxvf jpegsrc.v6b.tar.gz
    # cd jpeg-6b
    # 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

    5. 安裝gd,
    # 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
    //編譯過程中會看到如下資訊
    ** Configuration summary for gd 2.0.33:

    Support for PNG library: yes
    Support for JPEG library: yes
    Support for Freetype 2.x library: yes
    Support for Fontconfig library: no
    Support for Xpm library: no
    Support for pthreads: yes
    //可以看到png 、 jpeg 、 freetype都已經安裝上了
    # make
    # make install

    6. 正式安裝php
    # tar zxvf php-5.2.3.tar.gz
    # cd php-5.2.3
    # ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/gd --with-zlib --with-libpng --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --enable-sockets --with-iconv --enable-mbstring --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php5/etc
    # make
    # make install

    7.整合php和apache
    cp php.ini-dist /usr/local/php5/etc/php.ini
    vi /usr/local/php5/etc/php.ini
    將extension=php_mysql.dll前面的#去掉
    注意在/usr/local/apache2/conf/httpd.conf加上下代碼使apache執行PHP

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php3 .php3
    AddType application/x-httpd-php4 .php4
    AddType application/x-httpd-php-source .phps

    8. 安裝ZendOptimizer
    # tar zxvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
    # cd ZendOptimizer-3.0.1-linux-glibc21-i386
    # ./install.sh

    附:幾個軟體下載地址:

    apache 2.26 http://apache.mirror.phpchina.com/httpd/httpd-2.2.6.tar.gz
   mysql 5.0.22: download.mysql.cn/src/2006/0710/5544.html
   php 5.25: http://cn.php.net/get/php-5.2.5.tar.gz/from/this/mirror
   zlib 1.2.3: http://www.zlib.net/zlib-1.2.3.tar.gz

   libpng 1.2.23:http://jaist.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.23.tar.gz

   freetype 2.3.5:http://nchc.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.5.tar.gz

   jpeg: http://www.ijg.org/files/jpegsrc.v6b.tar.gz
    gd 2.0.35: http://www.libgd.org/releases/gd-2.0.35.tar.gz

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics