今天在Ubuntu 8.10里手動編譯了php5+MySQL5+Apache2,編譯好的PHP5支持GD、apache支持URL重寫(mod_rewrite)。
你還可以看看《openSUSE 11.0安裝PHP5+MYSQL5+APACHE2全記錄》和《Red Hat Enterprise Linux 5安裝LAMP》
以下是編譯過程,其中的諸如mysql-5.0.67.tar.gz之類的源碼包,可以直接在GOOLGE搜索:在搜索框輸入mysql-5.0.67.tar.gz即可。
安裝 ncurses:
sudo apt-get install libncurses5-dev
安裝MYSQL
sudo groupadd mysql
sudo useradd -g mysql -d /usr/local/mysql/data mysql
tar -zxvf mysql-5.0.67.tar.gz
cd mysql-5.0.67
./configure
--prefix=/usr/local/mysql --sysconfdir=/etc
--localstatedir=/usr/local/mysql/data --enable-assembler
--with-mysqld-ldflags=-all-static --with-charset=utf8
--with-extra-charsets=all
make
sudo make install
sudo /usr/local/mysql/bin/mysql_install_db
sudo chown -R mysql:mysql /usr/local/mysql/data
sudo cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
sudo update-rc.d mysqld defaults
sudo cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
sudo ln -s /usr/local/mysql/bin/mysql /bin/mysql
sudo /etc/init.d/mysqld start
mysql
安裝apache
tar -zvxf httpd-2.2.10.tar.gz
cd httpd-2.2.10
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite
make
sudo make install
#編譯rewrite模塊
tar -zxvf gdbm-1.8.3.tar.gz
./configure
make
sudo make install
sudo make install-compat
cd /home/lly/install/php/httpd-2.2.10/modules/mappers/
sudo /usr/local/apache/bin/apxs -c mod_rewrite.c -lgdbm
sudo gcc -shared -o mod_rewrite.so mod_rewrite.o -lgdbm
sudo /usr/local/apache/bin/apxs -i -A -n rewrite mod_rewrite.so
sudo cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
sudo update-rc.d httpd defaults
sudo /etc/init.d/httpd start
建立目錄
sudo -p mkdir /usr/local/modules/jpeg6/man/man1
sudo mkdir /usr/local/modules/jpeg6/bin
sudo mkdir /usr/local/modules/jpeg6/lib
sudo mkdir /usr/local/modules/jpeg6/include
安裝zlib
安裝libxml2
sudo apt-get install libxml2-dev
安裝freetype
tar -xvf freetype-2.3.7.tar.bz2
cd freetype-2.3.7
./configure --prefix=/usr/local/modules/freetype
make
sudo make install
安裝libpng
tar xzvf libpng-1.2.5.tar.gz
cd libpng-1.2.5
cp scripts/makefile.std makefile
make
sudo make install
安裝JPEG
tar xzvf jpegsrc.v6b.tar.gz
./configure --prefix=/usr/local/modules/jpeg6 --enable-shared --enable-static
make
sudo make install
安裝gettext
安裝GD
tar xzvf gd-2.0.33.tar.gz
./configure
--prefix=/usr/local/modules/gd --with-jpeg=/usr/local/modules/jpeg6
--with-png --with-zlib --with-freetype=/usr/local/modules/freetype
make
sudo make install
安裝mcrypt --為了使用phpMyAdmin
tar zxvf libmcrypt-2.5.7.tar.gz
./configure --prefix=/usr/local
make
sudo make install
安裝PHP
tar xvf php-5.2.8.tar.bz2
cd php-5.2.8/
./configure
--prefix=/usr/local/php5 --with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/lib
--with-gd=/usr/local/modules/gd
--with-jpeg-dir=/usr/local/modules/jpeg6 --with-zlib --with-png-dir
--with-freetype-dir=/usr/local/modules/freetype --with-xmlrpc
--with-config-file-path=/usr/local/php5/etc --enable-sockets
--with-mcrypt=/usr/local/lib
#vim libtool
#deplibs_check_method="pass_all"
make #如果make出錯,請執行上面2行
sudo make install
sudo cp ./php.ini-dist /usr/local/php5/etc/php.ini
sudo vim /usr/local/apache/conf/httpd.conf
加載php模塊,去掉注釋「#」,如沒有此行,請加上。
LoadModule php5_module modules/libphp5.so
加上此兩行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
sudo /usr/local/apache/bin/httpd -k restart
安裝ZendOptimizer
tar -zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-i386
sudo ./install.sh
*/usr/local/php5/etc
*/usr/local/apache/bin/apachectl