php入门到就业线上直播课:进入学习Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用


【资料图】

本教程操作环境:Windows10系统、centos6.8&&php7.1.5版、Dell G3电脑。

centos6.8怎么编译安装php?

centOS6.8,centOS7编译安装PHP:

我在centOS上安装了7次PHP,总结出来的centOS6.8,ccentOS7都能用的编译安装PHP的方法。久病成良医的感觉,刚开始安不上不要着急,多安几次就有经验了

安装依赖:

yum -y install gd-devel zlib-devel libjpeg-devel libpng-devel libiconv-devel freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt

无法自动安装的网上搜手动安装的教程,其实基本不会出错

进入本地目录:cd /usr/local

下载PHP7.1.5:wget http://am1.php.net/distributions/php-7.1.5.tar.gz

解压缩:tar zxvf php-7.1.5.tar.gz

进入解压目录:cd php-7.1.5

编译:./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-mysql --enable-mysqlnd-compression-support --with-pear --enable-maintainer-zts --enable-session --with-gettext

安装目录是/usr/local/php

编译完成后会看到:Thank you for using PHP.

之后执行安装命令:

makemake install

之后拷贝配置文件(当前还在php7.1.5文件夹下,不要用mv命令,这些配置文件以后还可以用不要删):

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp php.ini-development /usr/local/php/lib/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.confcp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm(这个很重要)

添加环境变量:

echo "export PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH">> /etc/profile

加载环境变量:source /etc/profile (我的习惯是虚拟机开机后先执行这个命令,会避免很多麻烦)

执行到这里,运行php -v就能看到安装的PHP的版本了

添加自启动:

chkconfig --add php-fpmchkconfig php-fpm onchkconfig --list php-fpm

加权限:chmod 755 /etc/init.d/php-fpm

启动PHP:/etc/init.d/php-fpm start

查看PHP服务状态:/etc/init.d/php-fpm status

停止PHP服务:/etc/init.d/php-fpm stop

重启php服务:/etc/init.d/php-fpm restart

php的配置文件是/usr/local/php/lib/php.ini 以后安装扩展了可以在这里引用。

推荐学习:《PHP视频教程》

以上就是centos6.8怎么编译安装php的详细内容,更多请关注php中文网其它相关文章!

推荐内容