首頁  >  文章  >  後端開發  >  linux centOS5 搭建lamp環境

linux centOS5 搭建lamp環境

不言
不言原創
2018-04-14 16:21:511540瀏覽


(參考文件)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 install

7.設定環境變數

vi /etc/profile

在結尾追加

PATH=$PATH:/usr/local/php /bin

export PATH

執行指令立即生效

source /etc/profile


修改Apache設定(讓Apache可以編譯PHP檔)

在設定檔httpd.conf追加以下程式碼

AddType application/x-httpd-php  .php

#AddType application/x-httpd -php-source  .phps

定位到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中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn