在 CentOS7 上安装 OpenResty PHP7.1 MariaDB10.2
本文最后更新于 2780 天前,其中的信息可能已经有所发展或是发生改变。

系统准备

一、卸载不必须的组件

yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client" "File and Print Server"

二、安装 EPEL

rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm

三、防火墙设置

systemctl start firewalld.service #开启防火墙

#开放 http 80 和 https 443 和 SSH 22 端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --zone=public --add-port=22/tcp --permanent

#生效规则
firewall-cmd --reload

四、设置 DNS 服务器(可选)

如果服务器无法访问 Github 的话,需要修改一下公共 DNS

修改 /etc/resolv.conf,添加

nameserver 223.5.5.5
nameserver 223.6.6.6

五、添加用户

useradd www

MariaDB

一、安装 MariaDB 10.2

wget https://gist.githubusercontent.com/ivmm/6e2f08a5ca21cfd3417e0339ac7c79fa/raw/8e25aff87e89c72fe2405e45389366114b8c69c8/MariaDB.repo

yum install MariaDB-server MariaDB-client -y

二、开启并设置开机启动

systemctl start mariadb.service #启动MariaDB 
systemctl enable mariadb.service #设置开机启动

三、安全设置并设置密码,SSH 中输入:

mysql_secure_installation

过程介绍: 基本上一路 y 即可

Enter current password for root (enter for none):
解释:输入当前 root 用户密码,默认为空,直接回车。
Set root password? [Y/n]  y
解释:要设置 root 密码吗?输入 y 表示愿意。
Remove anonymous users? [Y/n]  y
解释:要移除掉匿名用户吗?输入 y 表示愿意。
Disallow root login remotely? [Y/n]  y
解释:不想让 root 远程登陆吗?输入 y 表示愿意。
Remove test database and access to it? [Y/n]  y
解释:要去掉 test 数据库吗?输入 y 表示愿意。
Reload privilege tables now? [Y/n]  y
解释:想要重新加载权限吗?输入 y 表示愿意。

PHP

一、安装 REMI 源

rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm

二、确认 REMI-PHP 7.1

sed -i "/php71\/mirror/{n;s/enabled=0/enabled=1/g}" /etc/yum.repos.d/remi-php71.repo

三、安装 PHP

yum install php php-bcmath php-fpm php-gd php-json php-mbstring php-mcrypt php-mysqlnd php-opcache php-pdo php-pdo_dblib php-recode php-snmp php-soap php-xml php-pecl-zip -y

四、开启 PHP

systemctl start php-fpm.service #启动 PHP-FPM
systemctl enable php-fpm.service #设置开机启动

OpenResty

一、安装 OpenResty

cd /etc/yum.repos.d
wget https://gist.githubusercontent.com/ivmm/06b18486bfdb908c45616580fecad2c6/raw/4cf71647d2824d2077c1bae9429e0f29d62d3f64/OpenResty.repo

yum install openresty -y

二、开启 OpenResty

systemctl start openresty.service #启动 OpenResty
systemctl enable openresty.service #设置开机启动

三、创建相关目录

mkdir /usr/local/openresty/nginx/conf/vhost -p
mkdir /home/wwwroot/default -p

四、修改 nginx.conf

cd /usr/local/openresty/nginx/conf/
mv nginx.conf nginx_bk.conf
wget https://gist.githubusercontent.com/ivmm/9bc7e0c3f2ee34a29dd347a21ce126b2/raw/59b0c56216eda617f9755bf5947fa9df638f2cf7/nginx.conf

五、修改 php-fpm.conf

cd /etc
mv php-fpm.conf php-fpm_bk.conf
wget https://gist.github.com/ivmm/f58683ee553bea14884acbbfaafcbd5a/raw/0f3f15f52f9b235ce884eaa20538c6dfcf5ae70d/php-fpm.conf

六、下载探针一枚

cd /home/wwwroot/default
wget https://gist.github.com/ivmm/b014ad75c834036a44838553ec00b4b7/raw/ba41a0f29847d8d2230aca9ee795a6d02d27a617/tanzhen.php
mv tanzhen.php index.php

七、重启 php 和 Openresty

service php-fpm restart
service openresty restart

八、访问 http://你的公网ip/ 是不是已经是探针了!

评论

  1. 8年前
    2016-9-20 22:24:15

  2. 8年前
    2016-9-25 0:17:37

    我想知道 这个是不是会很强大?! 没试过 不敢折腾呢1~

    • 博主
      Yephy
      8年前
      2016-9-25 12:26:55

      你是指 Openresty 么

  3. 8年前
    2016-9-30 23:35:31

    认真学习一下

  4. fly
    8年前
    2016-10-04 15:43:37

    收到好材料.感谢 灰灰

本文评论已关闭
上一篇
下一篇