Linux搭建tengine2.0<Nginx>+php7环境

本文涉及的产品
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
简介: 本文介绍了在Linux系统上搭建Tengine 2.0(一个Nginx的增强版本)和PHP 7环境的详细步骤,包括创建安装目录、下载源码包及依赖库、编译安装Nginx、配置Nginx、安装PHP及其依赖、设置PHP-FPM、配置环境变量、安装Git和Composer,以及服务管理和日志查看等。
Linux部署Nginx+Php环境
1、先创建nginx安装目录:
[root@CENTOS7-128 / ]#  mkdir -p /usr/local/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
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、安装:先configure再make编译
[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、截止以上安装活动,不会报任何错误
6、进入nginx安装目录启动服务:
[root@CENTOS7-128 /]# cd /data/nginx/sbin/
[root@CENTOS7-128 sbin]# ./nginx
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  101.116.115.128;
        server_name  www.fullysss.com;
# tips:修改完成,本地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安装:
[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 --disable-fileinfo
[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

[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


# 公钥生成:
[root@CENTOS7-128  /]# cd ~/.ssh/
[root@CENTOS7-128  .ssh ]# ssh-keygen -t rsa

[root@CENTOS7-128  .ssh ]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfpDfhJI+6RQfy2xsyDIk3xMcgOKsHa1dZEhmw1xch7b6qeEP3ZnC5Vovg3qAb41JHeXJ04+tUc/Fv1js1v2kcc7t/HVj7zOhiGyET353xJKirmpXRjHlz8Gppdf4NjpVweD5JXIuBmWZBQx/H67K9rYZos9aYvyvT6Hw8DR6wu1rGOTPjnW2f3W2rNV1zmkwWK8yFSORe8ucjFfvAYDiQlDfmTbcuGBHk3k82VFBTH5g8JdQ6UVXO3FBvK9zY4b6H/58e1YZi2/WrLSRuw1rmJiucIbIbYSivttdBVSJwVlC0l73iSKUoMafirptqD+LX2Xw1j5zn7UuslcA6+yL9 root@CENTOS7-128
10、安装git命令:
[root@CENTOS7-128  / ]# yum install git
# 安装中国镜像composer:
[root@CENTOS7-128  / ]#cd opt
[root@CENTOS7-128  opt ]# wget https://getcomposer.org/download/1.4.2/composer.phar
[root@CENTOS7-128  opt ]# mv composer.phar /usr/local/bin/composer
# 上面两个步骤要么缓慢要么错误:  卸载命令: yum -y remove composer
[root@CENTOS7-128  opt ]# yum install composer       
[root@CENTOS7-128  opt ]# composer -V
# composer 从网址下载composer.phar 直接使用, 移动到 
[root@CENTOS7-128  opt ]#  mv composer.phar /user/local/bin/composer
[root@CENTOS7-128  opt ]#  chown +x test:test /user/local/bin/composer
# 执行以下命令时,需要切换到普通用户:useradd test,passwd test设置用户名密码命令。
[test@CENTOS7-128  opt ]# composer config -g repo.packagist composer https://packagist.phpcomposer.com
[test@CENTOS7-128  opt ]# composer install
11、php服务重启命令:
[root@CENTOS7-128 / ]#   /bin/systemctl restart  php-fpm.service      && service php-fpm restart
12、nginx修改配置文件后,需要-t 测试及 -s reload 重载生效。
[root@CENTOS7-128 nginx]# vi conf/nginx.conf
[root@CENTOS7-128 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
[root@CENTOS7-128 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
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
3月前
|
存储 Linux 开发工具
Linux环境下使用Buildroot配置软件包
使用Buildroot可以大大简化嵌入式Linux系统的开发和维护工作,但它需要对Linux系统和交叉编译有深入的理解。通过上述步骤,可以有效地配置和定制软件包,为特定的嵌入式应用构建高效、稳定的系统。
366 11
|
5月前
|
存储 监控 Linux
Linux环境锁定关键文件防止误删操作流程。
总结以上内容,在Linux环境下锁定重要文档避免误删涉及到多种技术手段与策略组合运作, 包括但不限于利用chatter指挥官固化文档状态至只读模式、运作ACL精准调整访问权利列表、编排自动化流程简
192 20
|
5月前
|
Linux
Linux环境下的UDEV机制及其与守护进程的关联
实际使用时管理员需要熟悉编写合适udev rules去满足特殊需求;同时也需要注意避免编写过度复杂导致无法预料结果rules.UDEVD虽然稳健但错误配置可能导致无法预料问题因此需谨慎处理相关配置工作.
196 16
|
5月前
|
存储 Linux
Linux环境下删除大文件后磁盘空间未释放问题诊断流程。
以上诊断流程涉及Linux底层机制与高级管理技能结合之处,并需要管理员根据实际环境灵活调整诊断策略与解决方案。
339 8
|
4月前
|
Linux 应用服务中间件 Shell
二、Linux文本处理与文件操作核心命令
熟悉了Linux的基本“行走”后,就该拿起真正的“工具”干活了。用grep这个“放大镜”在文件里搜索内容,用find这个“探测器”在系统中寻找文件,再用tar把东西打包带走。最关键的是要学会使用管道符|,它像一条流水线,能把这些命令串联起来,让简单工具组合出强大的功能,比如 ps -ef | grep 'nginx' 就能快速找出nginx进程。
492 1
二、Linux文本处理与文件操作核心命令
|
4月前
|
Linux
linux命令—stat
`stat` 是 Linux 系统中用于查看文件或文件系统详细状态信息的命令。相比 `ls -l`,它提供更全面的信息,包括文件大小、权限、所有者、时间戳(最后访问、修改、状态变更时间)、inode 号、设备信息等。其常用选项包括 `-f` 查看文件系统状态、`-t` 以简洁格式输出、`-L` 跟踪符号链接,以及 `-c` 或 `--format` 自定义输出格式。通过这些选项,用户可以灵活获取所需信息,适用于系统调试、权限检查、磁盘管理等场景。
336 137
|
4月前
|
安全 Ubuntu Unix
一、初识 Linux 与基本命令
玩转Linux命令行,就像探索一座新城市。首先要熟悉它的“地图”,也就是/根目录下/etc(放配置)、/home(住家)这些核心区域。然后掌握几个“生存口令”:用ls看周围,cd去别处,mkdir建新房,cp/mv搬东西,再用cat或tail看文件内容。最后,别忘了随时按Tab键,它能帮你自动补全命令和路径,是提高效率的第一神器。
780 57
|
3月前
|
存储 安全 Linux
Linux卡在emergency mode怎么办?xfs_repair 命令轻松解决
Linux虚拟机遇紧急模式?别慌!多因磁盘挂载失败。本文教你通过日志定位问题,用`xfs_repair`等工具修复文件系统,三步快速恢复。掌握查日志、修磁盘、验重启,轻松应对紧急模式,保障系统稳定运行。
596 2
|
4月前
|
缓存 监控 Linux
Linux内存问题排查命令详解
Linux服务器卡顿?可能是内存问题。掌握free、vmstat、sar三大命令,快速排查内存使用情况。free查看实时内存,vmstat诊断系统整体性能瓶颈,sar实现长期监控,三者结合,高效定位并解决内存问题。
366 0
Linux内存问题排查命令详解