LAMP--4.php 編譯安裝

來源:互聯網
上載者:User

標籤:php   安裝   編譯   

(安裝順序在最後)

         把 php 放到最後安裝是因為在編譯 php 時,需要指定 mysql 和 apache 的路徑,如果不先安裝好 mysql 和 apache 就沒有辦法安裝 php 。而 apache 和 mysql 的安裝順序就無所謂了。

         PHP 官網:http://www.php.net/downloads.php 。搜狐鏡像:http://mirrors.sohu.com/php/php-5.6.10.tar.gz  。

         下載 php:

[[email protected] ~]# cd /usr/local/src[[email protected] src]# wget http://mirrors.sohu.com/php/php-5.6.10.tar.gz

         解壓源碼包:

[[email protected] src]# tar zxf php-5.6.10.tar.gz

         配置編譯參數:

[[email protected] src]# cd php-5.6.10[[email protected] php-5.6.10]#  ./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-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 --disable-ipv6

         遇到錯誤:

 error: xml2-config not found. Please check your libxml2 installation.# yum install -y libxml2-devel
error: Cannot find OpenSSL‘s <evp.h># yum install -y openssl openssl-devel
error: Please reinstall the BZip2 distribution# yum install -y bzip2 bzip2-devel
error: png.h not found.# yum install -y libpng libpng-devel
error: freetype.h not found.# yum install -y freetype freetype-devel
error: freetype-config not found.# yum install -y freetype-devel
error: mcrypt.h not found. Please reinstall libmcrypt.# yum install -y libmcrypt-devel

      編譯

   #make

[[email protected] php-5.6.10]# makecrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt  -o sapi/cgi/php-cgiGenerating phar.phpGenerating phar.pharPEAR package PHP_Archive not installed: generated phar will require PHP‘s phar extension be enabled.pharcommand.incdirectorytreeiterator.incclicommand.incdirectorygraphiterator.incinvertedregexiterator.incphar.incBuild complete.Don‘t forget to run ‘make test‘.[[email protected] php-5.6.10]# echo $?0

        安裝

      # make install

[[email protected] php-5.6.10]# make installInstalling PEAR environment:      /usr/local/php/lib/php/[PEAR] Archive_Tar    - installed: 1.3.12[PEAR] Console_Getopt - installed: 1.3.1[PEAR] Structures_Graph- installed: 1.0.4[PEAR] XML_Util       - installed: 1.2.3[PEAR] PEAR           - installed: 1.9.5Wrote PEAR system config file at: /usr/local/php/etc/pear.confYou may want to add: /usr/local/php/lib/php to your php.ini include_path/usr/local/src/php-5.6.10/build/shtool install -c ext/phar/phar.phar /usr/local/php/binln -s -f phar.phar /usr/local/php/bin/pharInstalling PDO headers:          /usr/local/php/include/php/ext/pdo/[[email protected] php-5.6.10]# echo $?0

         拷貝 php 設定檔

[[email protected] php-5.6.10]# cp php.ini-production /usr/local/php/etc/php.ini

         修改 apache 設定檔

[[email protected]ost php-5.6.10]# vim /usr/local/apache2/conf/httpd.conf

        找到:

<Directory />    Options FollowSymLinks    AllowOverride None    Order deny,allow    Deny from all</Directory>        改為:<Directory />    Options FollowSymLinks    AllowOverride None    Order deny,allow    Allow from all</Directory>

         說明:如果不修改這個地方,我們訪問網站會禁止訪問,顯示403。

         然後找到:

    AddType application/x-gzip .gz .tgz

         在該行下面添加:

    AddType application/x-gzip .gz .tgz    AddType application/x-httpd-php .php

         說明:要想支援 php 指令碼解析,必須要加上對應的類型。

         再找到:

<IfModule dir_module>    DirectoryIndex index.html</IfModule>

         改為:

<IfModule dir_module>    DirectoryIndex index.html index.htm index.php</IfModule>

         說明:增加對 php 的索引,如果一個網站預設頁為 index.php,那麼就得加上這個 index.php 的支援。

         再找到:

#ServerName www.example.com:80

         修改為:

ServerName localhost:80

         如果不去掉#,則啟動 apache 時,會有警告資訊“httpd:Could not reliably determine the server‘s fully qualified domain name,using localhost.localdomain for ServerName”,看起來像是錯誤,其實沒有影響。

  

         查看設定檔是否有問題:

[[email protected] php-5.6.10]# /usr/local/apache2/bin/apachectl -tSyntax OK

         啟動服務:

[[email protected] php-5.6.10]# /usr/local/apache2/bin/apachectl start

         檢查是否正常啟動:

[[email protected] php-5.6.10]# ps aux|grep httpdroot      7998  0.0  0.7 196260  7284 ?        Ss   23:45   0:00 /usr/local/apache2/bin/httpd -k startdaemon    7999  0.0  0.4 196396  4920 ?        S    23:45   0:00 /usr/local/apache2/bin/httpd -k startdaemon    8000  0.0  0.4 196396  4920 ?        S    23:45   0:00 /usr/local/apache2/bin/httpd -k startdaemon    8001  0.0  0.4 196396  4920 ?        S    23:45   0:00 /usr/local/apache2/bin/httpd -k startdaemon    8002  0.0  0.4 196396  4920 ?        S    23:45   0:00 /usr/local/apache2/bin/httpd -k startdaemon    8003  0.0  0.4 196396  4920 ?        S    23:45   0:00 /usr/local/apache2/bin/httpd -k startroot      8005  0.0  0.0 103316   900 pts/1    S+   23:45   0:00 grep httpd



本文出自 “散宜生的學習筆記” 部落格,請務必保留此出處http://sanyisheng.blog.51cto.com/11154168/1795794

LAMP--4.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.