phplibmcrypt
PHP的安裝雖然有時候很簡單,可是如果應用一多,我們安裝起來就很頭痛了!出錯最多的就是安裝PHP擴展的時候了。其實不管是你是Apache類的應用還是Nginx類的,PHP的安裝都不是很簡單,雖然網上有很多configure參數,但是那不一定是適合你的,因為很多都直接關系著你的系統版本和內核。因此要自己親自不斷的調試,才能完全安裝成功。
本文總結了一些常見的configure錯誤信息和解決這些錯誤的經驗。
1、configure: error: No curses/termcap library found
網上有的說法是:–with-named-curses-libs=/usr/lib/libncursesw.so.5
其實是不對的,雖然能解決configure的錯誤,但是make的時候會提示錯誤,正確的做法應該是
centos: yum -y install ncurses-devel
debian: apt-get install libncurses5-dev
2、configure: error: xml2-config not found. Please check your libxml2 installation.
centos: yum -y install libxml2 libxml2-devel
debian: apt-get install libxml2-dev
3、configure: error: Cannot find OpenSSL』s
centos: yum -y install openssl-devel
4、configure: error: libjpeg.(a|so) not found
centos: yum -y install gd
centos: yum -y install gd-devel
debian: apt-get install libjpeg-dev
5、configure: error: libpng.(a|so) not found.
apt-get install libpng12-dev
6、configure: error: cannot find output from lex; giving up
yum -y install flex
7、configure: error: mod_deflate has been requested but can not be built e to prerequisite failures
centos: yum -y install zlib-devel openssl-devel
debian: apt-get install zlib1g-dev
8、configure: error: libxpm.(a|so) not found.
centos: yum -y install libxpm-dev
debian: apt-get install libxpm-dev
9、configure: error: freetype.h not found.
centos: yum install freetype-devel
debian: apt-get install libfreetype6-dev
10、configure: error: …No recognized SSL/TLS toolkit detected
centos: yum -y install libssl-dev
debian: apt-get install libssl-dev
11、Configure: error: Please reinstall the BZip2 distribution
centos: yum install bzip2 bzip2-devel
debian: apt-get install bzip2-devel
12、Configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/
centos: yum install curl curl-devel (For Redhat & Fedora)
# install libcurl4-gnutls-dev (For Ubuntu)
13、Configure: error: Unable to locate gmp.h
centos: yum install gmp-devel
14、Configure: error: Cannot find Mysql header files under /usr. Note that the MySQL client library is not bundled anymore!
yum install mysql-devel (For Redhat & Fedora)
# apt-get install libmysql++-dev (For Ubuntu)
15、Configure: error: Please reinstall the ncurses distribution
Solutions :
centos: yum install ncurses ncurses-devel
16、Checking for unixODBC support… configure: error: ODBC header file 『/usr/include/sqlext.h』 not found!
Solutions :
centos: yum install unixODBC-devel
17、Configure: error: Cannot find pspell
Solutions :
centos: yum install pspell-devel
18、configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Solutions :
yum install libmcrypt libmcrypt-devel (For Redhat & Fedora)
# apt-get install libmcrypt-dev
19、Configure: error: snmp.h not found. Check your SNMP installation.
Solutions :
yum install net-snmp net-snmp-devel
20、開啟LDAP服務還需要
yum -y install openldap-devel openldap-servers openldap-clients
21、configure: error: cannot find output from lex; giving up
centos: yum -y install flex
22、configure: error: mod_deflate has been requested but can not be built e to prerequisite failures
centos: yum -y install zlib-devel openssl-devel
debian: apt-get install zlib1g-dev
『貳』 PHP中2個加密擴展庫openssl mcrypt有何區別
Mcrypt擴展庫可以實現加密解密功能,就是既能將明文加密,也可以密文還原。 1.安裝PHP加密擴展Mcrypt 要使用該擴展,必須首先安裝mcrypt標准類庫,注意的是mcrypt軟體依賴libmcrypt和mhash兩個庫。 2.PHP加密擴展庫Mcrypt的演算法和加密模式 Mcrypt庫支持20多種加密演算法和8種加密模式,具體可以通過函數mcrypt_list_algorithms()和mcrypt_list_modes()來顯示,結果如下: Mcrypt支持的演算法有:cast-128 gost rijndael-128 twofish arcfour cast-256 loki97 rijndael-192 saferplus wake blowfish-中國pat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes Mcrypt支持的加密模式有:cbc cfb ctr ecb ncfb nofb ofb stream 這些演算法和模式在應用中要以常量來表示,寫的時候加上前綴MCRYPT_和MCRYPT_MODE_來表示,如下面Mcrypt應用的例子: DES演算法表示為MCRYPT_DES; ECB模式表示為MCRYPT_MODE_ECB; 3.PHP加密擴展庫Mcrypt應用 先看一個例子,了解Mcrypt的工作流程,再來看看部分流程使用的函數: <?php $str = "我是李雲"; $key = "123qwe.019860905061X"; $cipher = MCRYPT_RIJNDAEL_128; $mode = MCRYPT_MODE_ECB; $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher,$mode),MCRYPT_RAND); echo "原文:".$str."
"; $str_encrypt = mcrypt_encrypt($cipher,$key,$str,$mode,$iv); echo "加密後的內容是:".$str_encrypt."
"; $str_decrypt = mcrypt_decrypt($cipher,$key,$str_encrypt,$mode,$iv); echo "解密後的內容:".$str_decrypt."
"; ?> 運行結果: 原文:我是李雲 加密後的內容是:??Z懍e e??? 解密後的內容:我是李雲 //手冊里的寫法: //指定初始化向量iv的大小: $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); //創建初始化向量: $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); //加密密碼: $key = "123qwe.019860905061x"; //原始內容(未加密): $text = "My name is Adam Li!"; echo $text. "
\n"; //加密後的內容: $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); echo $crypttext. "\n
"; //解密已經加密的內容: $str_decrypt = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $crypttext, MCRYPT_MODE_ECB, $iv); echo $str_decrypt; 註:加密和解密函數中的參數cipher、key和mode必須一一對應,否則數據不能被還原。關於MCRYPT_RAND參見筆記linux中的隨機數文件 /dev/random /dev/urandom。 PHP的Mcrypt擴展的mcrypt_create_iv, 如果你不指定的話, 默認使用/dev/random(Linux上), 作為隨機數產生器. 這里的問題就在於/dev/random, 它的random pool依賴於系統的中斷來產生. 當系統的中斷數不足, 不夠產生足夠的隨機數, 那麼嘗試讀取的進程就會等待, 也就是會阻塞住 當20個並發請求的時候, 伺服器的中斷數不夠, 產生不了足夠的隨機數給mcrypt, 繼而導致PHP進程等待, 從而表現出, 響應時間變長 解決的辦法就是, 改用/dev/urandom, /dev/urandom也是一個產生隨機數的設備, 但是它不依賴於系統中斷。 $ rngd -r /dev/urandom -o /dev/random -t 1 用urandom的結果填充entropy池子,這樣既保證了entropy池的數量,也保證了隨機性 然而, 為什麼PHP使用/dev/random作為默認, 這是因為理論上來說, /dev/urandom在一定的情況下, 可能會被可預測(參看: /dev/random), 所以一般上認為, /dev/urandom不如/dev/random安全
『叄』 linuxphp網站怎麼安裝
配置php服務
安飢塌裝yasm匯編器(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvfyasm-1.2.0.tar.gz
[root@linuxprobesrc]cdyasm-1.2.0
[[email protected]]./configure
[[email protected]]make
[[email protected]]makeinstall
安裝libmcrypt加密演算法擴展庫(解爛銀圓壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibmcrypt-2.5.8.tar.gz
[root@linuxprobesrc]cdlibmcrypt-2.5.8
[[email protected]]./configure
[[email protected]]make
[[email protected]]makeinstall
安裝libvpx視頻編碼器(解壓與編譯過程搏旦已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarxjvflibvpx-v1.3.0.tar.bz2
[root@linuxprobesrc]cdlibvpx-v1.3.0
[[email protected]]./configure--prefix=/usr/local/libvpx--enable-shared--enable-vp9
[[email protected]]make
[[email protected]]makeinstall
安裝Tiff標簽圖像文件格式(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvftiff-4.0.3.tar.gz
[root@linuxprobesrc]cdtiff-4.0.3
[[email protected]]./configure--prefix=/usr/local/tiff--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安裝libpng圖片(png格式)函數庫(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibpng-1.6.12.tar.gz
[root@linuxprobesrc]cdlibpng-1.6.12
[[email protected]]./configure--prefix=/usr/local/libpng--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安裝freetype字體引擎(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvffreetype-2.5.3.tar.gz
[root@linuxprobesrc]cdfreetype-2.5.3
[[email protected]]./configure--prefix=/usr/local/freetype--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安裝jpeg圖片(jpeg格式)函數庫(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvfjpegsrc.v9a.tar.gz
[root@linuxprobesrc]cdjpeg-9a
[root@linuxprobejpeg-9a]./configure--prefix=/usr/local/jpeg--enable-shared
[root@linuxprobejpeg-9a]make
[root@linuxprobejpeg-9a]makeinstall
安裝libgd圖像處理程序(解壓與編譯過程已省略):
[root@linuxprobejpeg-9a]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibgd-2.1.0.tar.gz
[root@linuxprobesrc]cdlibgd-2.1.0
[[email protected]]./configure--prefix=/usr/local/libgd--enable-shared--with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng--with-freetype=/usr/local/freetype--with-fontconfig=/usr/local/freetype--with-xpm=/usr/--with-tiff=/usr/local/tiff--with-vpx=/usr/local/libvpx
[[email protected]]make
[[email protected]]makeinstall
安裝t1lib圖片生成函數庫(解壓與編譯過程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvft1lib-5.1.2.tar.gz
[root@linuxprobesrc]cdt1lib-5.1.2
[[email protected]]./configure--prefix=/usr/local/t1lib--enable-shared
[[email protected]]make
[[email protected]]makeinstall
將函數庫文件放至合適的位置:
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]ln-s/usr/lib64/libltdl.so/usr/lib/libltdl.so
[root@linuxprobesrc]cp-frp/usr/lib64/libXpm.so*/usr/lib/
安裝php服務程序(命令比較長,請一定要復制完整!!!):
[root@linuxprobesrc]tar-zvxfphp-5.5.14.tar.gz
[root@linuxprobesrc]cdphp-5.5.14
[[email protected]]exportLD_LIBRARY_PATH=/usr/local/libgd/lib
[[email protected]]./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-mysql-sock=/tmp/mysql.sock--with-pdo-mysql=/usr/local/mysql--with-gd--with-png-dir=/usr/local/libpng--with-jpeg-dir=/usr/local/jpeg--with-freetype-dir=/usr/local/freetype--with-xpm-dir=/usr/--with-vpx-dir=/usr/local/libvpx/--with-zlib-dir=/usr/local/zlib--with-t1lib=/usr/local/t1lib--with-iconv--enable-libxml--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--enable-opcache--enable-mbregex--enable-fpm--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear--with-gettext--enable-session--with-mcrypt--with-curl--enable-ctype
[[email protected]]make
[[email protected]]makeinstall
復制php服務程序的配置文件到安裝目錄:
[[email protected]]cpphp.ini-proction/usr/local/php/etc/php.ini
刪除默認的php配置文件:
[[email protected]]rm-rf/etc/php.ini
創建php配置文件的軟連接到/etc/目錄中:
[[email protected]]cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
[[email protected]]ln-s/usr/local/php/etc/php-fpm.conf/etc/php-fpm.conf
[[email protected]]ln-s/usr/local/php/etc/php.ini/etc/php.ini
編輯php服務程序的配置文件:
[[email protected]]vim/usr/local/php/etc/php-fpm.conf
//將第25行參數前面的分號去掉。
pid=run/php-fpm.pid
//修改第148和149行,將user與group修改為www。
user=www
group=www
添加php-fpm服務程序到開機啟動項:
[[email protected]]cpsapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm
[[email protected]]chmod+x/etc/rc.d/init.d/php-fpm
[[email protected]]chkconfigphp-fpmon
為了保障網站的安全性,禁用掉不安全的功能:
[[email protected]]vim/usr/local/php/etc/php.ini
//修改第305行的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
配置nginx服務程序支持php:
[[email protected]]vim/usr/local/nginx/conf/nginx.conf
//將第2行前面的號去掉並修改為userwwwwww;
//將第45行參數修改為indexindex.htmlindex.htmindex.php;
//將第65-71行前面的號去掉,修改為:
location~.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
重啟nginx與php-fpm服務程序:
[[email protected]]systemctlrestartnginx
[[email protected]]systemctlrestartphp-fpm
『肆』 在iis下怎麼運行php
IIS下運行PHP的方法:x0dx0a一、安裝PHP5.3.6x0dx0a 1) 關閉防火牆,解壓 php5.zip 到 D:\PHP\php5x0dx0ax0dx0a 2) 將php.ini文件分別拷貝到 D:\PHP\php5 和 C:\WINDOWS 目錄下x0dx0ax0dx0a 3) 給php安裝目錄(D:\PHP\php5)賦上users組讀與執行許可權x0dx0ax0dx0a 4) 在 D:\PHP\php5 文件夾下找到名為php_mysqli.dll,php_mysql.dll,libmysql.dll,libmcrypt.dll的文件,並將其復制到C:\windows\System32文件夾中 (註:IIS處理PHP和MYSQL需要該文件)。x0dx0ax0dx0a二、配置IISx0dx0a 1) 在IIS下新建網站,這里可以存放你的php網站文件。比如新建虛擬目錄jihetuan指向電腦上的E:\jihetuan目錄。x0dx0ax0dx0a 2) 在"映射"選項卡上點"添加",打開"添加/編輯應用程序擴展名映射"對話框,點擊"可執行文件"後的"瀏覽",定位到D:\PHP\php5\php5isapi.dll,在"擴展名"後的文本框內輸入".php"(註:一定要注意擴展名前的句點),點擊確定。x0dx0ax0dx0a 3) 在文檔選項卡中添加index.php做為默認文檔。也可不添加。x0dx0ax0dx0a 4) 再點"確定",退出"應用程序配置"對話框,再點"確定",退出PHP屬性對話框。x0dx0ax0dx0a 5) 重啟IIS,生效。x0dx0a三、安裝Mysqlx0dx0a完畢