php源碼安裝、簡單配置、測試及串連資料庫

來源:互聯網
上載者:User

標籤:主機   local   串連資料庫   服務端   php源碼安裝   

主機環境 redhat6.5 64位

實驗環境 服務端 ip172.25.29.1  php

安裝包   php-5.6.20.tar.bz2

        re2c-0.13.5-1.el6.x86_64.rpm

        libmcrypt-2.5.8-9.el6.x86_64.rpm

        libmcrypt-devel-2.5.8-9.el6.x86_64.rpm

        Discuz_X3.2_SC_UTF8.zip

1.  安裝php

1.解壓

[[email protected] mnt# tar jxf php-5.6.20.tar.bz2    #解壓

[[email protected] php-5.6.20]# rpm -vih libmcrypt-*   #安裝libmcrypt庫

[[email protected] php-5.6.20]# yum installre2c-0.13.5-1.el6.x86_64.rpm –y   #安裝re2c

 

2.軟體配置

[[email protected] php-5.6.20]# ./configure --prefix=/usr/local/lnmp/php--with-config-file-path=/usr/local/lnmp/php/etc --with-openssl --with-snmp--with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir--with-jpeg-dir --with-freetype-dir --with-gettext --without-pear --with-gmp--enable-inline-optimization --enable-soap --enable-ftp --enable-sockets--enable-mbstring --with-mysqli --with-mysql --with-pdo-mysql --enable-fpm--with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash

 

如果出現如下錯誤

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M00/87/BF/wKioL1fg3BKhcQISAAAXa_t5IDE930.png" style="float:none;" title="1.png" alt="wKioL1fg3BKhcQISAAAXa_t5IDE930.png" />

[[email protected] php-5.6.20]# yum install libxml2-devel -y

 

重新設定

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

 

如果出現如下錯誤

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M01/87/BF/wKioL1fg3BLRRAslAAAkT7CE3-Q302.png" title="2.png" style="float:none;" alt="wKioL1fg3BLRRAslAAAkT7CE3-Q302.png" />

[[email protected] php-5.6.20]# yum provides */easy.h

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M00/87/C3/wKiom1fg3BOw1uxUAADeoGw6Pes727.png" title="3.png" style="float:none;" alt="wKiom1fg3BOw1uxUAADeoGw6Pes727.png" />

[[email protected] php-5.6.20]# yum install -ylibcurl-devel-7.19.7-37.el6_4.x86_64

 

重新設定

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

 

如果出現如下錯誤

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M02/87/BF/wKioL1fg3BPx1-OOAAAkdoMrA-w527.png" title="4.png" style="float:none;" alt="wKioL1fg3BPx1-OOAAAkdoMrA-w527.png" />

[[email protected] php-5.6.20]# yum provides */jpeglib.h

[[email protected] php-5.6.20]# yum install -ylibjpeg-turbo-devel-1.2.1-1.el6.x86_64

 

重新設定

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

 

如果出現如下錯誤

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M01/87/C3/wKiom1fg3BPCD2SvAAAc6x3PeUc224.png" title="5.png" style="float:none;" alt="wKiom1fg3BPCD2SvAAAc6x3PeUc224.png" />

[[email protected] php-5.6.20]# yum provides */png.h

[[email protected] php-5.6.20]# yum install -ylibpng-devel-1.2.49-1.el6_2.x86_64

 

重新設定

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

 

如果出現如下錯誤

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M01/87/C3/wKiom1fg3BTRFxwVAAAjiP-8FRU627.png" title="6.png" style="float:none;" alt="wKiom1fg3BTRFxwVAAAjiP-8FRU627.png" />

[[email protected] php-5.6.20]# yum install -y freetype-devel

 

重新設定

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

 

如果出現如下錯誤

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M00/87/BF/wKioL1fg3BTAV8ucAAAeb870Br0310.png" title="7.png" style="float:none;" alt="wKioL1fg3BTAV8ucAAAeb870Br0310.png" />

[[email protected] php-5.6.20]# yum provides */gmp.h

[[email protected] php-5.6.20]# yum install -y gmp-devel-4.3.1-7.el6_2.2.x86_64

 

重新設定

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-openssl--with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir--with-jpeg-dir --with-freetype-dir --with-gettext --without-pear --with-gmp--enable-inline-optimization --enable-soap --enable-ftp --enable-sockets--enable-mbstring --with-mysqli --with-mysql --with-pdo-mysql --enable-fpm--with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash

 

如果出現如下錯誤

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M01/87/BF/wKioL1fg3BTg6_lXAAAfPqitHAA979.png" title="8.png" style="float:none;" alt="wKioL1fg3BTg6_lXAAAfPqitHAA979.png" />

[[email protected] php-5.6.20]# yum install -y net-snmp-devel

 

重新設定

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

 

3.編譯、連結、安裝

[[email protected] php-5.6.20]# make #編譯

[[email protected] php-5.6.20]# make install   #安裝

 

2.php的簡單配置

[[email protected] php-5.6.20]# cd /usr/local/lnmp/php/etc/

[[email protected] etc]# ls

php-fpm.conf.default

[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf   #備份php的檔案

[[email protected] etc]# ls

php-fpm.conf php-fpm.conf.default

[[email protected] etc]# cp /mnt/php-5.6.20/php.ini-production php.ini   #php的設定檔

[[email protected] etc]# ls

php-fpm.conf php-fpm.conf.default  php.ini


如果要串連資料庫,就做以下修改

[[email protected] etc]# vim php.ini

925 date.timezone = Asia/Shanghai          #修改時區

1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock   #指定串連資料庫的sock檔案的路徑

1150 mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock   #同上

1209 mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock   #同上

[[email protected] etc]# vim php-fpm.conf

25 pid = run/php-fpm.pid          #將pid的標記去掉

 

[[email protected] etc]# cd /mnt/php-5.6.20/sapi/fpm/

[[email protected] fpm]# cp init.d.php-fpm /etc/init.d/php-fpm   #添加啟動命令

[[email protected] fpm]# chmod +x /etc/init.d/php-fpm       #添加可執行許可權

[[email protected] fpm]# ll /etc/init.d/php-fpm

-rwxr-xr-x 1 root root 2359 Sep 18 00:18 /etc/init.d/php-fpm

[[email protected] fpm]# /etc/init.d/php-fpm start        #開啟php服務

Starting php-fpm  done

 

[[email protected] fpm]# cd /usr/local/lnmp/nginx/conf/

[[email protected] conf]# vim nginx.conf         

 51             root   html;

 52             index  index.php index.html index.htm;     #在nginx裡添加預設訪問目錄為php優先

 50         location / {

 

 53         }

 

 75         location ~ \.php$ {

 76             root           html;

 77             fastcgi_pass   127.0.0.1:9000;

 78             fastcgi_index  index.php;

 79             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

 80             include        fastcgi.conf;         #設定成已存在的檔案

 81         }

 

[[email protected] conf]# nginx –t       #檢測

[[email protected] conf]# nginx           #開啟

[[email protected] conf]# cd ..

[[email protected] nginx]# cd html

[[email protected] html]# vim index.php       #寫一個簡單的測試檔案

<?php

phpinfo()

?>

[[email protected] html]# /etc/init.d/httpd start      #開啟httpd

Starting httpd:                                           [  OK  ]

 

3.測試  172.25.29.1

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/87/C3/wKiom1fg3BXTZUJ0AAEBrG0SO5Y178.png" title="9.png" style="float:none;" alt="wKiom1fg3BXTZUJ0AAEBrG0SO5Y178.png" />

 


本文出自 “不忘初心,方得始終” 部落格,請務必保留此出處http://12087746.blog.51cto.com/12077746/1854495

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.