linux安装php7
2022-07-28 15:20:24
125
{{single.collect_count}}

1、下载php
官网下载:#wget http://cn2.php.net/distributions/php-7.1.2.tar.gz

2、解压php压缩包

 #tar -zxvf php-7.1.2.tar.gz

3、编译安装

#cd php-7.1.2
 #./configure --prefix=/usr/local/php7 \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip

如果有配置错误,需要安装模块,yum安装就好了。

# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel openssl openssl-devel curl-devel libxslt-devel

然后再就是

#make
#make install

4、配置Apache服务器上的php
安装过程中,自动会拷贝一个 /usr/local/httpd/modules/libphp7.so
贴心的安装程序还会自动修改我们的apache配置文件加入了这一行LoadModule php7_module modules/libphp7.so,然后在 AddType application/x-gzip .gz .tgz 后面加上 AddType application/x-httpd-php .php(.前面有空格)

最后到php的解压目录复制一下php的配置文件。

 #cp php.ini-development /usr/local/php/lib/php.ini 

重启Apache服务,然后写一个简单的检测文件吧。

<?phpphpinfo();?>

5、把PHP加入环境变量

#vim /etc/profile

在文件末尾加上如下两行代码
PATH=$PATH:/usr/local/php7/bin
export PATH

然后执行命令 #source /etc/profile 或执行点命令 #./profile 使其修改生效,执行完可通过 #echo $PATH命令查看是否添加成功

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}