入門一班 20181113 php5 install php7 install

11月13日任務

11.10/11.11/11.12 安裝PHP5
11.13 安裝PHP7
php中mysql,mysqli,mysqlnd,pdo到底是什麼 http://blog.csdn.net/u013785951/article/details/60876816
查看編譯參數

http://ask.apelearn.com/question/1295




將php5安裝在 aming1.

安裝順序是有一個安排的,先mysql 後php

image.png

  1. 到src目錄,下載,解壓。bz2文件的解壓命令,tar -xvf

  2. cd php目錄,然後執行configure命令來進行編譯。 ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif 。前面主要是apache的模塊安裝,接下來是php

    執行編譯的時候出現了一個錯誤。image.png

    就是openssl找不到,yum 找一下,實際上需要安裝的是 yum install openssl openssl-devel。 繼續編譯。

    接下來又出現了一個錯誤,image.png,解決辦法 yum install bzip2-devel

    接下里又出現了一個錯誤,是libpng缺失,用這個命令安裝。 yum install libjpeg-devel

    不出意外的,又出現一個錯誤。image.png,yum install freetype-devel

    新的錯誤出現,image.png。因爲這個包是屬於epel擴展庫的,所以如果需要使用必須提前安裝epel擴展庫的。然後 yum install libmcrypt-devel.

    image.png編譯成功。

  3. 接下來是make,make install 。裝的位置是/usr/local/php 

  4. 可以看到有一個.so文件,這個就是php和apache結合的文件。image.png

  5. 查看php下所加載的靜態模塊的命令。 bin/下 php -m image.png 。實際上php是httpd的一個模塊存在的。

  6. 通過/usr/local/php/bin/php -i 可以查看php信息 image.png

  7. 拷貝配置文件到/php/etc下。image.png  cp /usr/local/src/php-5.6.32/php.ini-production /usr/local/php/etc/php.ini






CentOS7 裝在aming1

image.png

注意在編譯的時候沒有 --with-mysql 

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif 


make


make install 


完成安裝。但是要知道的事情是,一個apache只能一次調用一個php,所以要指定使用的是哪個php

image.png

可以看到,加載了幾個php,5和7都加載了。

image.png


如何選擇用哪個?到配置文件裏進行修改。

vim /usr/local/apache2/conf/httpd.conf

會發現有兩個php的模塊,註釋掉不需要的。

image.png

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章