Linux搭建tengine+php测试环境

小知识,大挑战!本文正在参与“程序员必备小知识”创作活动。

1、新建nginx目录:

[root@CENTOS7-128 / ]# mkdir /usr/local/src/nginx

2、下载源码包及依赖库:
[root@CENTOS7-128 / ]# cd /usr/local/src/nginx

[root@CENTOS7-128 nginx ]# wget <http://tengine.taobao.org/download/tengine-2.2.0.tar.gz>

[root@CENTOS7-128 nginx ]# wget <https://sourceforge.net/projects/pcre/files/pcre/8.40/pcre-8.40.tar.gz>

[root@CENTOS7-128 nginx ]# wget <http://zlib.net/zlib-1.2.11.tar.gz> or http://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.gz

[root@CENTOS7-128 nginx ]# wget <http://artfiles.org/openssl.org/source/openssl-1.1.0e.tar.gz>

[root@CENTOS7-128 nginx ]# ll
复制代码

image.png

3、解压:
[root@CENTOS7-128 nginx ]# tar xvf tengine-2.2.0.tar.gz

[root@CENTOS7-128 nginx ]# tar xvf pcre-8.40.tar.gz

[root@CENTOS7-128 nginx ]# tar xvf zlib-1.2.11.tar.gz

[root@CENTOS7-128 nginx ]# tar xvf openssl-1.1.0e.tar.gz
复制代码
4、安装:
[root@CENTOS7-128 nginx ]# cd tengine-2.2.0

[root@CENTOS7-128 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

[root@CENTOS7-128 tengine-2.2.0 ]# make && make install
复制代码
5、以上安装活动,不会报任何错误:

clipboard.png

6、进入nginx启动目录:
[root@CENTOS7-128 /]# cd /data/nginx/sbin/

[root@CENTOS7-128 sbin]# ./nginx
复制代码
  • 浏览器访问nginx服务器:

image.png

7、进入nginx/conf配置目录修改nginx.conf
[root@CENTOS7-128 conf]# vi nginx.conf 
[root@CENTOS7-128 conf]# cd ../sbin/ 
[root@CENTOS7-128 sbin]# ./nginx -t 
the configuration file /data/nginx/conf/nginx.conf syntax is ok 
configuration file /data/nginx/conf/nginx.conf test is successful 
[root@CENTOS7-128 sbin]# ./nginx -s reload
复制代码
8、修改访问域名,不适用ip,默认端口:
server {

listen 80;

server_name 10.16.15.128;

server_name www.fullycms.com;

修改完成,本地hosts映射域名:10.16.15.128 www.fullycms.com
复制代码

image.png

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安装:

[root@CENTOS7-128 / ]# cd opt

[root@CENTOS7-128 opt ]# rz 把下载的php-7.1.5.tar.g包放在这个目录并解压“

[root@CENTOS7-128 opt ]# tar -zxvf php-7.1.5.tar.gz

[root@CENTOS7-128 opt ]# cd php-7.1.5

[root@CENTOS7-128 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

[root@CENTOS7-128 php-7.1.5 ]# make && make install

[root@CENTOS7-128 php-7.1.5 ]# make test

[root@CENTOS7-128 php-7.1.5 ]# cd /data/php

[root@CENTOS7-128 php ]# cp /data/php/etc/php-fpm.conf.default /data/php/etc/php-fpm.conf

[root@CENTOS7-128 php ]# cp /opt/php-7.1.5/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[root@CENTOS7-128 php ]# cp /opt/php-7.1.5/php.ini-production /data/php/lib/php.ini

[root@CENTOS7-128 php ]# vim /data/php/etc/php-fpm.conf #并没有修改什么

[root@CENTOS7-128 php ]# cd /data/php/etc/php-fpm.d

[root@CENTOS7-128 php-fpm ]# cp www.conf.default www.conf

[root@CENTOS7-128 php-fpm.d]# vi [www.conf](http://www.conf)
复制代码

image.png

[root@CENTOS7-128 php ]# chmod a+x /etc/init.d/php-fpm

[root@CENTOS7-128 php ]# chkconfig php-fpm on #设置php开机自启

[root@CENTOS7-128 php ]# chmod +x /etc/profile

[root@CENTOS7-128 php ]# vim /etc/profile.d/php.sh

PATH=$PATH:/data/php/bin

export PATH

:x 退出保存

[root@CENTOS7-128 php ]# chmod +x /etc/profile.d/php.sh

[root@CENTOS7-128 php ]# source /etc/profile

[root@CENTOS7-128 php ]# ln -s /data/php/sbin/php  /bin/php
复制代码
10、php服务重启命令

[root@CENTOS7-128 / ]# /bin/systemctl restart php-fpm.service && service php-fpm restart