首页 > 后端开发 > php教程 > linux centOS5 搭建lamp环境

linux centOS5 搭建lamp环境

不言
发布: 2023-03-23 21:04:01
原创
1577 人浏览过


(参考文档)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 freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-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中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板