国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

php5.3.10的安裝配置步驟詳解

2024-08-27 23:58:45
字體:
來源:轉載
供稿:網友

在linux中php安裝配置與windows中有不小的區別了,在linux中幾乎都是代碼形式了,下面我們一起來看看php5.3.10的安裝配置步驟詳解,希望下文可幫助到各位.

下面以最新的php-5.3.10為例進行安裝.

  1. wget http://cn.php.net/distributions/php-5.3.10.tar.gz 
  2. tar -zxvf php-5.3.10.tar.gz 
  3. cd php-5.3.10 
  4. ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap 

上面的具體參數可以使用./configure --help查看.

  1. make ZEND_EXTRA_LIBS='-liconv' 
  2. make test 
  3. make && make install   (此處最好分開做,因為make的時候會有報錯出現). 

我在上面的make時就報了下面的錯誤:

  1. root/source/php-5.3.10/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory 
  2. make: *** [ext/phar/phar.php] Error 127 

解決辦法是:我的mysql安裝目錄是/usr/local/msyql,這個視自己的mysql安裝路徑而定.

ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib/

64位系統應使用下面的這行:

ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/

若報下面的錯,就是編繹mysql的時候沒有加上mysqli這一項,把下面標紅的那部分取消掉,重新編繹就行了.

  1. make: *** [ext/mysqli/mysqli.lo] Error 1 
  2. ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap 

另外,也有報下面錯的可能,該問題有可能是沒有安裝iconv這個編碼轉換的包,也有可以裝了,但是仍有這個錯.

  1. sapi/cli/php: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory 
  2. make[1]: *** [install-pear-installer] Error 127 
  3. make: *** [install-pear] Error 2 

find / -name libiconv.so.2在/usr/lib/libiconv.so.2位置發現libiconv已經安裝,于是運行/sbin/ldconfig,再重新編譯,不再報上面的錯,ldconfig用于加載最新編繹過的包.

注:上面很多需要的包我都是通過通過./configure --prefix=/usr --libdir=/usr/lib --sysconfdir=/etc參數編繹,這樣其在默認的目錄就能找到該包了.

  1. cp php.ini-production /usr/local/php/etc/php.ini 
  2. cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm  
  3. cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf 

修改php.ini文件和php-fpm文件中參數,可以手動更改也可以用下面的sed命令更改.

  1. sed -i 's#short_open_tag = Off#short_open_tag = On#g' /usr/local/php/etc/php.ini 
  2. sed -i 's#;pid = run/php-fpm.pid#pid = run/php-fpm.pid#g' /usr/local/php/etc/php-fpm.conf 
  3. sed -i 's#pm.max_children = 5#pm.max_children = 32#g' /usr/local/php/etc/php-fpm.conf 
  4. sed -i 's#pm.start_servers = 2#pm.start_servers = 16#g' /usr/local/php/etc/php-fpm.conf 
  5. sed -i 's#pm.min_spare_servers = 1#pm.min_spare_servers = 8#g' /usr/local/php/etc/php-fpm.conf 
  6. sed -i 's#pm.max_spare_servers = 3#pm.max_spare_servers = 32#g' /usr/local/php/etc/php-fpm.conf 
  7. sed -i 's#;pm.max_requests = 500#pm.max_requests = 120#g' /usr/local/php/etc/php-fpm.conf  --Vevb.com 

php官方也給出了其中所有參數項的解釋說明,具體見:http://www.php.net/manual/en/install.fpm.configuration.php

設置開機啟動:

  1. chmod 755 /etc/init.d/php-fpm 
  2. chkconfig --add php-fpm 
  3. /etc/init.d/php-fpm start 

至此,php的安裝完畢,最后可以再安裝一些php的擴展包和開戶php加速,具體軟件包可以視網上的最新版進行安裝:

  1. tar zxvf memcache-2.2.5.tgz 
  2. cd memcache-2.2.5/ 
  3. /usr/local/php/bin/phpize 
  4. ./configure --with-php-config=/usr/local/php/bin/php-config 
  5. make 
  6. make install 
  7. cd ../ 
  8. tar jxvf eaccelerator-0.9.6.1.tar.bz2 
  9. cd eaccelerator-0.9.6.1/ 
  10. /usr/local//php/bin/phpize 
  11. ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config 
  12. make 
  13. make install 
  14. cd ../ 
  15. tar zxvf PDO_MYSQL-1.0.2.tgz 
  16. cd PDO_MYSQL-1.0.2/ 
  17. /usr/local/php/bin/phpize 
  18. ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql 
  19. make 
  20. make install 
  21. cd ../ 
  22. tar zxvf ImageMagick.tar.gz 
  23. cd ImageMagick-6.5.1-2/ 
  24. ./configure 
  25. make 
  26. make install 
  27. cd ../ 
  28. tar zxvf imagick-2.3.0.tgz 
  29. cd imagick-2.3.0/ 
  30. /usr/local/php/bin/phpize 
  31. ./configure --with-php-config=/usr/local/php/bin/php-config 
  32. make 
  33. make install 
  34. cd ../ 

修改php.ini文件

手工修改:查找/usr/local/php/etc/php.ini中的extension_dir = "./",修改為extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"

并在此行后增加以下幾行,然后保存:

  1. extension = "memcache.so" 
  2. extension = "pdo_mysql.so" 
  3. extension = "imagick.so" 

再查找output_buffering = Off,修改為output_buffering = On,再查找; cgi.fix_pathinfo=0,修改為cgi.fix_pathinfo=0,防止Nginx文件類型錯誤解析漏洞.

配置eAccelerator加速PHP:

  1. mkdir -p /opt/webserver/eaccelerator_cache 
  2. vi /usr/local/php/etc/php.ini 

在php.ini配置文件的最末尾,加上以下配置信息:

  1. [eaccelerator] 
  2. zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so" 
  3. eaccelerator.shm_size="64" 
  4. eaccelerator.cache_dir="/opt/webserver/eaccelerator_cache" 
  5. eaccelerator.enable="1" 
  6. eaccelerator.optimizer="1" 
  7. eaccelerator.check_mtime="1" 
  8. eaccelerator.debug="0" 
  9. eaccelerator.filter="" 
  10. eaccelerator.shm_max="0" 
  11. eaccelerator.shm_ttl="3600" 
  12. eaccelerator.shm_prune_period="3600" 
  13. eaccelerator.shm_only="0" 
  14. eaccelerator.compress="1" 
  15. eaccelerator.compress_level="9" 

php的安全性設置:

找到:;open_basedir =

修改為:open_basedir = .:/tmp/   #防止php木馬跨站,重要.

找到:disable_functions =

修改為:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

#列出PHP可以禁用的函數,如果某些程序需要用到這個函數,可以刪除,取消禁用.

找到:;date.timezone =

修改為:date.timezone = PRC

找到:expose_php = On

修改為:expose_php = OFF  #禁止顯示php版本的信息

找到:display_errors = On

修改為:display_errors = OFF  #關閉錯誤提示

關于模塊的安裝我給各位補充一篇文章

1、靜態安裝

將先將在安裝php之前先將需要安裝的程序裝上,如ftp、mhash、mcrypt……安裝完成后,解壓php安裝包,執行./configure --with-ftp --with-mhash --wth-mcrypt等等。后面具體跟的參數可以參看./configure --help查看。編譯好后,執行make && make install 就行了。

2、動態安裝

而在往往我們進行編譯php時經常會忘記添加某擴展,后來想添加擴展,但是因為安裝php后又裝了一些東西如PEAR等,不想再重新裝php,于是可以采用phpize來動態加載需要安裝的模塊。

具體實現方法如下(這里以忘記安裝pdo_mysql模塊為例):

  1. cd /root/source/php-5.3.10/ext/pdo_mysql 
  2. /usr/local/php/bin/phpize 

在安裝完mysql后,并不是進入/root/source/mysql-5.5.21目錄運行phpize,而是進入php的源文件中要增加的擴展模塊的文件目錄---也就是/root/source/php-5.3.10/ext/pdo_mysql目錄執行phpize。如果不是這樣操作的話就會提示下面的錯誤:

  1. Cannot find config.m4. 
  2. Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module 

關于上面的這個錯誤,我不得不鄙視下網上有些自以為是的家伙,自認為對所有的安裝操作很懂,報上面的錯誤的時候,去修改源代碼,搞的亂七八糟,誤人子弟,根本不按php官方的文檔操作.

目錄/root/source/php-5.3.10/ext/pdo_mysql,在運行phpize命令前并沒有configure文件,只有config.m4文件,運行phpize就生成了一個可執行的configure文件,此時就可以按照下的方法編譯了:

./configure --with-php-config=/usr/bin/php-config  (還可以加一些其他的參數,可通過./configure --help查看).

make

make install

編譯完成后會提示擴展模塊生成在/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626目錄。

修改php.ini文件

vi /usr/local/php/etc/php.ini

在其文件結尾加入下面的內容:

extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"

extension=pdo_mysql.so

安裝完成后,重啟php-fpm和web服務器,因為我用的是php-fpm和tengine,如果用的是apache則也重啟相應的程序,重新加載就行了.

本文中其實關于加速的部分是錯誤的,因為當時我測試時,只是把php安裝好以后,后面的eaccelerator加速部分是直接復制的原來的安裝部分,并未進行測試,后來因為生產環境的需要,進行安裝時,發現eaccelerator不支持最新的php5.3.10,于是換成更新速度最快的xcache發現支持.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 旺苍县| 姚安县| 泗水县| 兴宁市| 宜宾县| 阿荣旗| 曲水县| 湘阴县| 浪卡子县| 张家川| 新干县| 宁陕县| 珲春市| 平罗县| 涟水县| 漳州市| 遂昌县| 平潭县| 宁阳县| 芜湖市| 天峻县| 崇阳县| 文水县| 溆浦县| 登封市| 邯郸市| 桃源县| 保德县| 全椒县| 古交市| 夏津县| 兴文县| 九江市| 阿鲁科尔沁旗| 沂源县| 友谊县| 福泉市| 顺昌县| 错那县| 马鞍山市| 酒泉市|