(參考文件)https://help.aliyun.com/document_detail/50774.html
#編譯安裝PHP
1.下載php7
#cd /usr/local/src/
wget -O php7.tar.gz http://cn2.php.net/get/php-7.1.1.tar.gz/from/this/mirror
2.解壓縮PHP7
tar -xvf php7.tar.gz
3.進入PHP原始檔目錄
cd php-7.0.4
4.安裝依賴套件
#yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freevel-develipmp gmp-devel
##5.編譯設定./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/--enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-libxml -dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv - -with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable- ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with- libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable- session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl -- enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache--with-apxs2=/usr/local/apache/bin/apxs
#注意:--with-apxs2=/usr/local/apache/bin/apxs 一定要否則apache辨識不到PHP
6.編譯安裝#make && make install7.設定環境變數vi /etc/profile在結尾追加PATH=$PATH:/usr/local/php /binexport PATH執行指令立即生效source /etc/profile定位到DirectoryIndex 添加index.php
重启Apache
注意:启动报
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
#vim /web/apache/conf/httpd.conf (在这里/web/apahce是我安装apache的目录,你默认安装的话应该是/usr/local/apache2/icons)
找到#ServerName www.example.com:80 把#去掉,再重启apache即可没事了。
现象:
bogon:~/webserver/httpd-2.0.59 # /usr/local/apache2/bin/apachectl start
httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
httpd (pid 20183) already running
這個問題應該是沒有在 /etc/httpd/conf/httpd.conf 中設定 ServerName
vi /usr/local/apache2/conf/httpd.conf
最简单的,修改httpd.conf文件,增加:
ServerName www.example.com:80
我的改为:
ServerName localhost:80
再次启动就正常了!
以上是linux centOS5 搭建lamp環境的詳細內容。更多資訊請關注PHP中文網其他相關文章!