您当前的位置:首页 > 电脑百科 > 站长技术 > 服务器

Centos7 搭建LTMP环境PHP、Tengine、Mysql、Supervisord、Redis

时间:2020-05-12 10:29:11  来源:  作者:

环境:

一、安装依赖包

yum udate
yum -y install gcc gcc-c++ autoconf automake
yum -y install pcre
yum -y install pcre-devel
yum -y install zlib
yum -y install zlib-devel
yum -y install openssl
yum -y install openssl-devel
yum -y install jemalloc     #内存管理工具

二、安装Tengine

1、下载安装包

wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz

2、解压

tar zxvf tengine-2.1.2.tar.gz

3、编译安装

cd tengine-2.1.2
./configure
make && make install

 

Centos7  搭建LTMP环境PHP、Tengine、Mysql、Supervisord、Redis

Tengine 安装成功

三、安装MySQL

1、运行以下命令更新YUM源。

rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.运行以下命令安装MySQL。

yum -y install mysql-community-server

3.运行以下命令查看MySQL版本号。

mysql -V
返回结果如下所示,表示MySQL安装成功。mysql Ver 14.14 Distrib 5.7.28, for linux (x86_64) using EditLine wrApper

4.运行以下命令启动MySQL。

systemctl start mysqld

5.运行以下命令设置开机启动MySQL。

systemctl enable mysqld systemctl daemon-reload

四、安装PHP

1.更新YUM源

运行以下命令添加epel源。

yum install 
https://repo.ius.io/ius-release-el7.rpm 
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

2、运行以下命令添加Webtatic源。

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

3、运行以下命令安装PHP。

yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb

4、运行以下命令查看PHP版本。

php -v

返回结果如下所示,表示安装成功。

PHP 7.0.33 (cli) (built: Dec  6 2018 22:30:44) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies    

五:配置Nginx

  1. 运行以下命令备份Nginx配置文件。

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

修改Nginx配置文件,添加Nginx对PHP的支持

运行以下命令打开Nginx配置文件。

vim /etc/nginx/nginx.conf

在server大括号内,添加下列配置信息。

        #除下面提及的需要添加的配置信息外,其他配置保持默认值即可。
        location / {
            #在location大括号内添加以下信息,配置网站被访问时的默认首页
            index index.php index.html index.htm;
        }
        #添加下列信息,配置Nginx通过fastcgi方式处理您的PHP请求
        location ~ .php$ {
            root /usr/share/nginx/html;    #将/usr/share/nginx/html替换为您的网站根目录,本教程使用/usr/share/nginx/html作为网站根目录
            fastcgi_pass 127.0.0.1:9000;   #Nginx通过本机的9000端口将PHP请求转发给PHP-FPM进行处理
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;   #Nginx调用fastcgi接口处理PHP请求
        }                
Centos7  搭建LTMP环境PHP、Tengine、Mysql、Supervisord、Redis

配置Nginx支持PHP

运行以下命令启动Nginx服务。

systemctl start nginx 

运行以下命令设置Nginx服务开机自启动。

systemctl enable nginx

六:配置MySQL

  1. 运行以下命令查看/var/log/mysqld.log文件,获取并记录root用户的初始密码。

grep 'temporary password' /var/log/mysqld.log

 

2016-12-13T14:57:47.535748Z 1 [Note] A temporary password is generated for root@localhost: p0/G28g>lsHD

运行以下命令配置MySQL的安全性。

mysql_secure_installation

安全性的配置包含以下五个方面:

  1. 重置root账号密码。

Enter password for user root: #输入上一步获取的root用户初始密码 The 'validate_password' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? (Press y|Y for Yes, any other key for No) : Y #是否更改root用户密码,输入Y New password: #输入新密码,长度为8至30个字符,必须同时包含大小写英文字母、数字和特殊符号。特殊符号可以是()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/ Re-enter new password: #再次输入新密码 Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y

  1. 输入Y删除匿名用户账号。By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y #是否删除匿名用户,输入Y Success.
  2. 输入Y禁止root账号远程登录。Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y #禁止root远程登录,输入Y Success.
  3. 输入Y删除test库以及对test库的访问权限。Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y #是否删除test库和对它的访问权限,输入Y - Dropping test database... Success.
  4. 输入Y重新加载授权表。Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y #是否重新加载授权表,输入Y Success. All done!

八:测试访问LNMP平台

在地址栏输入http://<ECS实例公网IP地址>/phpinfo.php。

Centos7  搭建LTMP环境PHP、Tengine、Mysql、Supervisord、Redis

 



Tags:Centos7 LTMP   点击:()  评论:()
声明:本站部分内容及图片来自互联网,转载是出于传递更多信息之目的,内容观点仅代表作者本人,如有任何标注错误或版权侵犯请与我们联系(Email:2595517585@qq.com),我们将及时更正、删除,谢谢。
▌相关推荐
环境: 1、系统:Centos 7 2、Tengine 2.1.2 3、PHP 7.0 4、Mysql 5.7 5、supervisord 6、redis一、安装依赖包yum udateyum -y install gcc gcc-c++ autoconf automakeyum -y i...【详细内容】
2020-05-12  Tags: Centos7  LTMP  点击:(113)  评论:(0)  加入收藏
▌简易百科推荐
阿里云镜像源地址及安装网站地址https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b111kK44P更新源之前把之前的国外的镜像先备份一下 切换到yumcd...【详细内容】
2021-12-27  干程序那些事    Tags:CentOS7镜像   点击:(1)  评论:(0)  加入收藏
前言在实现TCP长连接功能中,客户端断线重连是一个很常见的问题,当我们使用netty实现断线重连时,是否考虑过如下几个问题: 如何监听到客户端和服务端连接断开 ? 如何实现断线后重...【详细内容】
2021-12-24  程序猿阿嘴  CSDN  Tags:Netty   点击:(12)  评论:(0)  加入收藏
一. 配置yum源在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repovim /etc/yum.repos.d/google-chrome.repo按i进入编辑模式写入如下内容:[google-chrome]name=googl...【详细内容】
2021-12-23  有云转晴    Tags:chrome   点击:(7)  评论:(0)  加入收藏
一. HTTP gzip压缩,概述 request header中声明Accept-Encoding : gzip,告知服务器客户端接受gzip的数据 response body,同时加入以下header:Content-Encoding: gzip:表明bo...【详细内容】
2021-12-22  java乐园    Tags:gzip压缩   点击:(9)  评论:(0)  加入收藏
yum -y install gcc automake autoconf libtool makeadduser testpasswd testmkdir /tmp/exploitln -s /usr/bin/ping /tmp/exploit/targetexec 3< /tmp/exploit/targetls -...【详细内容】
2021-12-22  SofM    Tags:Centos7   点击:(7)  评论:(0)  加入收藏
Windows操作系统和Linux操作系统有何区别?Windows操作系统:需支付版权费用,(华为云已购买正版版权,在华为云购买云服务器的用户安装系统时无需额外付费),界面化的操作系统对用户使...【详细内容】
2021-12-21  卷毛琴姨    Tags:云服务器   点击:(6)  评论:(0)  加入收藏
参考资料:Hive3.1.2安装指南_厦大数据库实验室博客Hive学习(一) 安装 环境:CentOS 7 + Hadoop3.2 + Hive3.1 - 一个人、一座城 - 博客园1.安装hive1.1下载地址hive镜像路径 ht...【详细内容】
2021-12-20  zebra-08    Tags:Hive   点击:(9)  评论:(0)  加入收藏
以下是服务器安全加固的步骤,本文以腾讯云的CentOS7.7版本为例来介绍,如果你使用的是秘钥登录服务器1-5步骤可以跳过。1、设置复杂密码服务器设置大写、小写、特殊字符、数字...【详细内容】
2021-12-20  网安人    Tags:服务器   点击:(7)  评论:(0)  加入收藏
项目中,遇到了一个问题,就是PDF等文档不能够在线预览,预览时会报错。错误描述浏览器的console中,显示如下错误:nginx代理服务报Mixed Content: The page at ******** was loaded...【详细内容】
2021-12-17  mdong    Tags:Nginx   点击:(7)  评论:(0)  加入收藏
转自: https://kermsite.com/p/wt-ssh/由于格式问题,部分链接、表格可能会失效,若失效请访问原文密码登录 以及 通过密钥实现免密码登录Dec 15, 2021阅读时长: 6 分钟简介Windo...【详细内容】
2021-12-17  LaLiLi    Tags:SSH连接   点击:(16)  评论:(0)  加入收藏
最新更新
栏目热门
栏目头条