在Debian下源碼安裝apache2+PHP5+MySQL

來源:互聯網
上載者:User

在Debian下源碼安裝apache2+PHP5+MySQL

作者:丟丟 添加時間:2004-06-18
關鍵字:php5

Debian實在是太棒了,但是有些更新卻讓人覺得很慢,比如LAMP的這一套更新其實就很慢。
沒辦法,那就源碼安裝唄。
(其實apache和mysql是安全可以用debian包安裝的
apt-get install apache2-common apache2-mpm-perfork mysql-common mysql-server mysql-client
我呢是手痒痒,就一塊編譯了。對於mysql主要還是用debian包安裝在做資料庫鏡象的時候挺麻煩的。
)。
1、安裝mysql:
編譯mysql是最不費什麼事情的,因為它的文檔INSTALL-SOURCE已經說的非常詳細的。
先下載mysql-4.0.20.tar.gz.
shell>groupadd mysql
shell>useradd -g mysql mysql
shell>tar zxvf mysql-4.0.20.tar.gz
shell>cd mysql-4.0.20
shell>./configure --prefix=/usr/local/mysql (我裝系統會把/usr/local作為一個獨立的分區專門用來安裝這一類源碼編譯的東東)
shell>make && make install
shell>support-files/my-medium.cnf /etc/my.cnf
shell>support-files/mysql.server /etc/init.d/mysql
shell>chmod +x /etc/init.d/mysql #然後通過rcconf選擇mysql就可以作為服務每一次都自動啟動了。
shell>cd /usr/local/mysql
shell>/bin/mysql_install_db --user=mysql
shell>chown -R root .
shell>chown -R mysql var
shell>chgrp -R mysql .
shell>bin/mysqld_safe --user=mysql & 或者 shell>/etc/init.d/mysql start
OK,完成!

2、安裝apache2:
下載httpd-2.0.49.tar.gz。
shell>tar zxvf httpd-2.0.49.tar.gz
shell>./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-mods-shared --enable-ssl --enable-track-vars
shell>make && make install
安裝完成。
應該在這兒修改設定檔httpd.conf了,不過因為安裝php後還需要修改,所以這兒就先不管他吧。

3、安裝PHP5:
下載php-5.0.0RC3.tar.gz。
shell>tar zxvf php-5.0.0RC3.tar.gz
因為我要讓php同時支援mysql,postgresql,gd2(gif,jpeg,png)所以指定選項比較多:
shell>./configure --with-apxs2=/usr/local/apache2/bin/apxs / --with-mysql=/usr/local/mysql --with-gd --with-mm / --enable-gd-native-ttf --enable-ftp --with-zlib / --with-openssl --with-pgsql --with-png-dir --with-ttf / --with-freetype-dir --with-jpeg-dir --with-zlib-dir
對於debian來說,用--with-mm參數需要安裝libmm-dev(apt-get install libmm-dev)
用--with-gd參數需要安裝gd2的庫(apt-get install libgd2-dev)
用--with-openssl則需要安裝openssl和libssl-dev
--with-png和--with-jpeg都需要相應的庫,libpng,libjpeg
在debian下源碼編譯是非常方便的,因為所有少的軟體包都可以直接通過apt-get install 安裝。非常方便。
然後是編譯:
shell>make && make install
shell>cp php.ini-dist /usr/local/lib/php.ini

接下來就是修改/usr/local/apache2/conf/httpd.conf。
LoadModule php5_module modules/libphp5.so #這一行php5安裝的時候就應該已經自動添加上了。
添加下面的兩行:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
根據需要修改ServerName等參數。
記得修改AddDefaultCharset這一行,要不顯示中文時就是亂碼。
AddDefaultCharset GB2312
然後重啟apache2:
shell>/usr/local/apache2/bin/apachectl restart
在/usr/local/apache2/htdocs中添加index.php檔案。(如果修改了DocumentRoot就不是這個路徑)。
<?php
phpinfo();
?>
然後瀏覽器中輸入:
http://localhost/index.php
應該可以顯示系統的配置資訊了吧。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.