fedora16下PHP5.4编译安装笔记
今天重装了下PHP,顺便尝鲜一下5.4,期间涉及到的多数软件我都是选择的最新稳定版。这里要注意的就是PHP的一个编译参数:--with-gd=shared ,这里切不可把shared替换为gd2的安装目录/usr/local/gd2,不然会无法编译通过,网上查了下好像是PHP5.3-5.4的一个bug。
yum install -y gcc g-c++ gcc-c++ libtool openssl-devel pam-devel python-devel libxml2-devel
sourcepath="/opt/source/"
cd {$sourcepath}
wget http://fossies.org/unix/misc/zlib-1.2.6.tar.gz
mkdir /usr/local/zlib
tar zxvf zlib-1.2.6.tar.gz
cd zlib-1.2.6
./configure --prefix=/usr/local/zlib
make && make install
echo "/usr/local/zlib/lib" >> /etc/ld.so.conf
ldconfig
chcon -t textrel_shlib_t /usr/local/zlib/lib/libz.so*
cd {$sourcepath}
wget http://xmlsoft.org/sources/libxml2-2.7.8.tar.gz
tar zxvf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8
./configure --prefix=/usr/local/libxml2 --with-python
make
make install
LD_LIBRARY_PATH=/usr/local/lib
LD_LIBRARY_PATH=/usr/local/libxml2/lib
LD_LIBRARY_PATH=/usr/lib/python2.7/site-packages
echo "/usr/local/libxml2/lib" >> /etc/ld.so.conf
echo "/usr/lib/python2.7/site-packages" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget http://xmlsoft.org/sources/libxslt-1.1.26.tar.gz
mkdir /usr/local/libxslt
tar zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
make
make install
echo "/usr/local/libxslt/lib" >> /etc/ld.so.conf
echo "/usr/local/libxslt/lib/python2.7/site-packages" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget http://vps.googlecode.com/files/libiconv-1.13.1.tar.gz
mkdir /usr/local/libiconv
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make
make install
echo "/usr/local/libiconv/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget http://vps.googlecode.com/files/mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
echo "/usr/local/lib" >> /etc/ld.so.conf
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ldconfig
cd {$sourcepath}
wget http://vps.googlecode.com/files/libmcrypt-2.5.8.tar.gz
mkdir /usr/local/libmcrypt
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/libltdl
./configure --enable-ltdl-install
make
make install
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install
ln -s /usr/local/libmcrypt/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/libmcrypt/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/libmcrypt/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/libmcrypt/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
cp /usr/local/libmcrypt/bin/libmcrypt-config /usr/bin/libmcrypt-config
cp /usr/local/libmcrypt/lib/libmcrypt.* /usr/lib
echo "/usr/local/libmcrypt/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget http://vps.googlecode.com/files/mcrypt-2.6.8.tar.gz
mkdir /usr/local/mcrypt
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
LD_LIBRARY_PATH=/usr/local/lib
./configure --prefix=/usr/local/mcrypt --with-libmcrypt-prefix=/usr/local/libmcrypt --with-libiconv-prefix=/usr/local/libiconv
make && make install
cd {$sourcepath}
wget http://curl.cs.pu.edu.tw/download/curl-7.25.0.tar.gz
tar zxvf curl-7.25.0.tar.gz
cd curl-7.25.0
./configure
make && make install
ldconfig
cd {$sourcepath}
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.9.tar.gz
mkdir /usr/local/freetype2
tar zxvf freetype-2.4.9.tar.gz
cd freetype-2.4.9
./configure --prefix=/usr/local/freetype2
make && make install
echo "/usr/local/freetype2/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget http://freedesktop.org/software/fontconfig/release/fontconfig-2.9.0.tar.gz
mkdir /usr/local/fontconfig
tar zxvf fontconfig-2.9.0.tar.gz
cd fontconfig-2.9.0
export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
cp -r /usr/local/libxml2/include/libxml2/libxml/ /usr/include/
./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype2/bin/freetype-config
make && make install
echo "/usr/local/fontconfig/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.9.tar.gz
mkdir /usr/local/libpng2
tar zxvf libpng-1.5.9.tar.gz
cd libpng-1.5.9/
export LDFLAGS=-L/usr/local/zlib/lib
export CFLAGS=-I/usr/local/zlib/include
./configure --prefix=/usr/local/libpng2
make && make install
echo "/usr/local/libpng2/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget http://www.ijg.org/files/jpegsrc.v8d.tar.gz
mkdir /usr/local/jpeg8
mkdir /usr/local/jpeg8/include
mkdir /usr/local/jpeg8/lib
mkdir /usr/local/jpeg8/bin
mkdir /usr/local/jpeg8/man/man1/ -p
tar zxvf jpegsrc.v8d.tar.gz
cd jpeg-8d
./configure --prefix=/usr/local/jpeg8 --enable-shared --enable-static
make && make install
echo "/usr/local/jpeg8/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget http://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz
mkdir /usr/local/gd2
tar zxvf gd-2.0.35.tar.gz
cd gd/2.0.35
cp /usr/local/libpng2/include/pngconf.h {$sourcepath}gd/2.0.35/
./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib --with-jpeg=/usr/local/jpeg8 --with-freetype=/usr/local/freetype2 --with-xml=/usr/local/libxml2 --with-png=/usr/local/libpng2 --with-fontconfig=/usr/local/fontconfig --with-slt=/usr/local/libxslt
make && make install
echo "/usr/local/gd2/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
wget http://fossies.org/linux/misc/giflib-4.1.6.tar.gz
tar zxvf giflib-4.1.6.tar.gz
cd giflib-4.1.6
./configure
make && make install
cd {$sourcepath}
wget http://www.php.net/get/php-5.4.0.tar.gz/from/cn2.php.net/mirror
tar zxf php-5.4.0.tar.gz
cd php-5.4.0
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-gd=shared --with-jpeg-dir=/usr/local/jpeg8 --with-png-dir=/usr/local/libpng2 --enable-gd-native-ttf --with-zlib-dir=/usr/local/zlib --with-freetype-dir=/usr/local/freetype2 --enable-zip --with-libxml-dir=/usr/local/libxml2 --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql --with-pdo-pgsql=/usr/local/pgsql --with-curl --with-mcrypt=/usr/local/libmcrypt --enable-mbstring=all --with-mhash --enable-soap --enable-sockets --with-pear --enable-gd-native-ttf --enable-ftp --disable-ipv6 --with-iconv
make
make test
make install
修改/usr/local/apache2/conf/httpd.conf
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
下面添加
PHPIniDir "/etc"
AddType application/x-httpd-php .php
重启apache,搞定!

PHP在現代編程中仍然是一個強大且廣泛使用的工具,尤其在web開發領域。 1)PHP易用且與數據庫集成無縫,是許多開發者的首選。 2)它支持動態內容生成和麵向對象編程,適合快速創建和維護網站。 3)PHP的性能可以通過緩存和優化數據庫查詢來提升,其廣泛的社區和豐富生態系統使其在當今技術棧中仍具重要地位。

在PHP中,弱引用是通過WeakReference類實現的,不會阻止垃圾回收器回收對象。弱引用適用於緩存系統和事件監聽器等場景,需注意其不能保證對象存活,且垃圾回收可能延遲。

\_\_invoke方法允許對象像函數一樣被調用。 1.定義\_\_invoke方法使對象可被調用。 2.使用$obj(...)語法時,PHP會執行\_\_invoke方法。 3.適用於日誌記錄和計算器等場景,提高代碼靈活性和可讀性。

Fibers在PHP8.1中引入,提升了並發處理能力。 1)Fibers是一種輕量級的並發模型,類似於協程。 2)它們允許開發者手動控制任務的執行流,適合處理I/O密集型任務。 3)使用Fibers可以編寫更高效、響應性更強的代碼。

PHP社區提供了豐富的資源和支持,幫助開發者成長。 1)資源包括官方文檔、教程、博客和開源項目如Laravel和Symfony。 2)支持可以通過StackOverflow、Reddit和Slack頻道獲得。 3)開發動態可以通過關注RFC了解。 4)融入社區可以通過積極參與、貢獻代碼和學習分享來實現。

PHP和Python各有優勢,選擇應基於項目需求。 1.PHP適合web開發,語法簡單,執行效率高。 2.Python適用於數據科學和機器學習,語法簡潔,庫豐富。

PHP不是在消亡,而是在不斷適應和進化。 1)PHP從1994年起經歷多次版本迭代,適應新技術趨勢。 2)目前廣泛應用於電子商務、內容管理系統等領域。 3)PHP8引入JIT編譯器等功能,提升性能和現代化。 4)使用OPcache和遵循PSR-12標準可優化性能和代碼質量。

PHP的未來將通過適應新技術趨勢和引入創新特性來實現:1)適應云計算、容器化和微服務架構,支持Docker和Kubernetes;2)引入JIT編譯器和枚舉類型,提升性能和數據處理效率;3)持續優化性能和推廣最佳實踐。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

記事本++7.3.1
好用且免費的程式碼編輯器

Dreamweaver Mac版
視覺化網頁開發工具

SublimeText3 Linux新版
SublimeText3 Linux最新版