欢迎访问 生活随笔!

凯发k8官方网

当前位置: 凯发k8官方网 > 编程语言 > php >内容正文

php

vagrant box php开发环境配置-凯发k8官方网

发布时间:2025/1/21 php 43 豆豆
凯发k8官方网 收集整理的这篇文章主要介绍了 vagrant box php开发环境配置--centos 7 安装 php7 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

2019独角兽企业重金招聘python工程师标准>>>

centos7.3 系统 安装php7.1.2,我选择编译安装

下载源文件

用vagrant账户登录,先安装wget,再下载源码

# release后面的版本号可能需要调整,依赖libmcrypt-devel需要该源 sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm sudo yum install -y wget vim wget -o php-7.1.2.tar.gz http://cn2.php.net/get/php-7.1.2.tar.gz/from/this/mirror tar -xvf php-7.1.2.tar.gz

编译安装

centos7 box默认是用minimal安装的,所以有些依赖需要安装

sudo yum install -y libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel libmcrypt-devel readline-devel libxslt-devel

configure

cd php-7.1.2 ./configure --prefix=/usr/local/php --with-config-file-path=/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 sudo make sudo make install

配置文件

sudo cp php.ini-development /etc/php.ini

把php的bin目录加到path中

sudo vim /etc/profile.d/path.sh

在末尾加上

path=$path:/usr/local/php/bin export path source /etc/profile # 查看安装成功与否 php -v

显示

php 7.1.2 (cli) (built: mar 26 2017 09:29:22) ( nts ) 凯发k8官方网 copyright (c) 1997-2017 the php group zend engine v3.1.0, 凯发k8官方网 copyright (c) 1998-2017 zend technologies 就安装成功了

php-fpm

sudo cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf sudo cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf sudo cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm sudo chmod x /etc/init.d/php-fpm

增加到开机启动

sudo chkconfig --add php-fpm chkconfig --list sudo service php-fpm start

应该启动失败,报错

cannot get uid for user 'nginx' 修改 /usr/local/php/etc/php-fpm.d/www.conf中的

; unix user/group of processes ; note: the user is mandatory. if the group is not set, the default user's group ; will be used. user = nginx group = nginx

xdebug

参考 https://xdebug.org/docs/install

cd ~ wget https://xdebug.org/files/xdebug-2.5.1.tgz tar xvzf xdebug-2.5.1.tgz cd xdebug-2.5.1 sudo yum install autoconf phpize ./configure --enable-xdebug make sudo make install

输出

installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/

sudo vim /etc/php.ini

末尾添加

zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so xdebug.remote_enable=1 xdebug.remote_host= 10.0.2.2 xdebug.remote_port=9000 xdebug.max_nesting_level=200 xdebug.idekey="phpstorm" xdebug.remote_autostart = 1

转载于:https://my.oschina.net/u/2558702/blog/867919

总结

以上是凯发k8官方网为你收集整理的vagrant box php开发环境配置--centos 7 安装 php7的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得凯发k8官方网网站内容还不错,欢迎将凯发k8官方网推荐给好友。

网站地图