NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
``` 下载到本地上传,http://cn2.php.net/get/php-7.1.16.tar.gz/from/this/mirror ``` 或者wget ``` wget http://cn2.php.net/get/php-7.1.16.tar.gz/from/this/mirror mv mirror php.tar.gz ``` 解压PHP包 ``` tar xf php.tar.gz ``` 打开PHP解压好的目录 ``` cd php-7.1.16 / ``` yum安装所需要的插件 ``` yum install libxml2-devel curl-devel libjpeg-devel libpng-devel openssl-devel freetype-devel libxslt-devel -y yum install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y yum install libmcrypt-devel -y ``` ## 安装PHP模块 ``` ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-mcrypt --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-opcache --with-xsl ``` 查看下有没有错误语法 ``` echo $? ``` ## 执行安装: ``` make && make install ``` # PHP配置 安装目录下 拷贝文件到安装好的目录下 ``` cp php.ini-development /usr/local/php/etc/php.ini cd /usr/local/php/etc cp php-fpm.conf.default php-fpm.conf cd php-fpm.d cp www.conf.default www.conf ``` ## 启动PHP ``` usr/local/php/sbin ./php-fpm ``` # 配置nginx启动PHP ``` cd usr/local/nginx/conf ``` ## 删除nginx.conf ``` rm -f nginx.conf ``` 然后 ## 复制nginx.conf.default 改名为nginx.conf ``` cp nginx.conf.default nginx.conf ``` ``` vim nginx.conf 删除注释打开这段代码,修改include 为fastcgi.conf ``` ``` location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi.conf; } ``` ## 修改下面这段代码添加 index.php ``` location / { root html; index index.php index.html index.htm; } ``` ## 重置nginx ``` cd usr/local/nginx/sbin ./nginx -s reload ``` ## 启动nginx ``` ./nginx ``` 进入到 nginx 里的html目录下 写一个index.php文件 试试输出就可以