1. 云栖社区>
  2. PHP教程>
  3. 正文

Nginx测试环境搭建tengine2.0+php7

作者:用户 来源:互联网 时间:2017-11-30 15:29:31

php测试nginx环境搭建2.0Tengine

Nginx测试环境搭建tengine2.0+php7 - 摘要: 本文讲的是Nginx测试环境搭建tengine2.0+php7, 1、新建nginx目录: [[email protected] / ]# mkdir /usr/local/src/nginx 2、下载源码包及依赖库: [[email protected] / ]# cd /usr/local/sr

1、新建nginx目录:
[[email protected] / ]# mkdir /usr/local/src/nginx
2、下载源码包及依赖库:
[[email protected] / ]# cd /usr/local/src/nginx
[[email protected] nginx ]# wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
[[email protected] nginx ]# wget https://sourceforge.net/projects/pcre/files/pcre/8.40/pcre-8.40.tar.gz
[[email protected] nginx ]# wget http://zlib.net/zlib-1.2.11.tar.gz or http://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.gz
[[email protected] nginx ]# wget http://artfiles.org/openssl.org/source/openssl-1.1.0e.tar.gz
[[email protected] nginx ]# ll

3、解压:
[[email protected] nginx ]# tar xvf tengine-2.2.0.tar.gz
[[email protected] nginx ]# tar xvf pcre-8.40.tar.gz
[[email protected] nginx ]# tar xvf zlib-1.2.11.tar.gz
[[email protected] nginx ]# tar xvf openssl-1.1.0e.tar.gz
4、安装:
[[email protected] nginx ]# cd tengine-2.2.0
[[email protected] tengine-2.2.0 ]#./configure –prefix=/data/nginx –with-openssl=/usr/local/src/nginx/openssl-1.1.0e/ –with-zlib=/usr/local/src/nginx/zlib-1.2.11 –with-pcre=/usr/local/src/nginx/pcre-8.40
[[email protected] tengine-2.2.0 ]# make && make install
5、以上安装活动,不会报任何错误:

6、进入nginx启动目录:
[[email protected] /]# cd /data/nginx/sbin/
[[email protected] sbin]# ./nginx

7、进入nginx/conf配置目录修改nginx.conf

[[email protected] conf]# vi nginx.conf
[[email protected] conf]# cd ../sbin/
[[email protected] sbin]# ./nginx -t
the configuration file /data/nginx/conf/nginx.conf syntax is ok
configuration file /data/nginx/conf/nginx.conf test is successful
[[email protected] sbin]# ./nginx -s reload
8、修改访问域名,不适用ip,默认端口:
server {
listen 80;
server_name 10.16.15.128;
server_name www.fullysss.com;
修改完成,本地hosts映射域名:101.116.115.128 www.fullysss.com

9、安装php:
安装所需要的依赖库:yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel file
下载php安装:
[[email protected] / ]# cd opt
[[email protected] opt ]# rz 把下载的php-7.1.5.tar.g包放在这个目录并解压“
[[email protected] opt ]# tar -zxvf php-7.1.5.tar.gz
[[email protected] opt ]# cd php-7.1.5
[[email protected] php-7.1.5 ]# ./configure –prefix=/data/php –with-mysql –with-mysql-sock –with-mysqli –enable-fpm –enable-soap –with-libxml-dir –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 –disable-mbregex –disable-mbregex-backtrack –with-libmbfl –with-onig –enable-pdo –with-pdo-mysql –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 –disable-fileinfo
[[email protected] php-7.1.5 ]# make && make install
[[email protected] php-7.1.5 ]# make test
[[email protected] php-7.1.5 ]# cd /data/php
[[email protected] php ]# cp /data/php/etc/php-fpm.conf.default /data/php/etc/php-fpm.conf
[[email protected] php ]# cp /opt/php-7.1.5/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] php ]# cp /opt/php-7.1.5/php.ini-production /data/php/lib/php.ini
[[email protected] php ]# vim /data/php/etc/php-fpm.conf #并没有修改什么
[[email protected] php ]# cd /data/php/etc/php-fpm.d
[[email protected] php-fpm ]# cp www.conf.default www.conf
[[email protected] php-fpm.d]# vi www.conf

[[email protected] php ]# chmod a+x /etc/init.d/php-fpm
[[email protected] php ]# chkconfig php-fpm on #设置php开机自启
[[email protected] php ]# chmod +x /etc/profile
[[email protected] php ]# vim /etc/profile.d/php.sh
PATH=$PATH:/data/php/bin
export PATH
:x 退出保存
[[email protected] php ]# chmod +x /etc/profile.d/php.sh
[[email protected] php ]# source /etc/profile
[[email protected] php ]# ln -s /data/php/sbin/php /bin/php

公钥生成:
[[email protected] /]# cd ~/.ssh/
[[email protected] .ssh ]# ssh-keygen -t rsa

[[email protected] .ssh ]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfpDfhJI+6RQfy2xsyDIk3xMcgOKsHa1dZEhmw1xch7b6qeEP3ZnC5Vovg3qAb41JHeXJ04+tUc/Fv1js1v2kcc7t/HVj7zOhiGyET353xJKirmpXRjHlz8Gppdf4NjpVweD5JXIuBmWZBQx/H67K9rYZos9aYvyvT6Hw8DR6wu1rGOTPjnW2f3W2rNV1zmkwWK8yFSORe8ucjFfvAYDiQlDfmTbcuGBHk3k82VFBTH5g8JdQ6UVXO3FBvK9zY4b6H/58e1YZi2/WrLSRuw1rmJiucIbIbYSivttdBVSJwVlC0l73iSKUoMafirptqD+LX2Xw1j5zn7UuslcA6+yL9 [email protected]

10、安装git命令:[[email protected] / ]# yum install git
安装中国镜像composer:
[[email protected] / ]#cd opt
[[email protected] opt ]# wget https://getcomposer.org/download/1.4.2/composer.phar
[[email protected] opt ]# mv composer.phar /usr/local/bin/composer
# 上面两个步骤要么缓慢要么错误: 卸载命令: yum -y remove composer
[[email protected] opt ]# yum install composer
[[email protected] opt ]# composer -V
composer 从网址下载composer.phar 直接使用, 移动到
[[email protected] opt ]# mv composer.phar /user/local/bin/composer
[[email protected] opt ]# chown +x test:test /user/local/bin/composer

执行以下命令时,需要切换到普通用户:useradd test,passwd test设置用户名密码命令。

[[email protected] opt ]# composer config -g repo.packagist composer https://packagist.phpcomposer.com
[[email protected] opt ]# composer install

11、php服务重启命令:[[email protected] / ]# /bin/systemctl restart php-fpm.service && service php-fpm restart
12、nginx修改配置文件后,需要-t 测试及 -s reload 重载生效。
[[email protected] nginx]# vi conf/nginx.conf
[[email protected] nginx]# ./sbin/nginx -t
the configuration file /data/nginx/conf/nginx.conf syntax is ok
configuration file /data/nginx/conf/nginx.conf test is successful
[[email protected] nginx]# ./sbin/nginx -s reload
13、查看php服务:ps -ef |grep php ps -ef | grep nginx

redis下载路径:http://download.redis.io/redis-stable.tar.gz
PHP的配置文件为:/usr/local/lib/php.ini
php-fpm的配置文件为:/usr/local/etc/php-fpm.conf
php-fpm的错误日志为:/usr/local/var/log/php-fpm.log
php-fpm.conf文件的在线说明文档:http://php.net/manual/en/install.fpm.configuration.php

th7cn

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索php , 测试 , nginx , 环境 , 搭建 , 2.0 Tengine ,以便于您获取更多的相关知识。