美文网首页
linux centos 7.2 lnmp+redis搭建

linux centos 7.2 lnmp+redis搭建

作者: henryspace | 来源:发表于2017-11-20 16:42 被阅读0次

一、配置防火墙,开启80端口、3306端口

CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。

1、关闭firewall:

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、安装iptables防火墙

yum install iptables-services #安装

vi /etc/sysconfig/iptables #编辑防火墙配置文件

# Firewall configuration written by system-config-firewall

# Manual customization of this file is not recommended.

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

:wq! #保存退出

systemctl restart iptables.service #最后重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

二、关闭SELINUX

vi /etc/selinux/config

#SELINUX=enforcing #注释掉

#SELINUXTYPE=targeted #注释掉

SELINUX=disabled #增加

:wq! #保存退出

setenforce 0 #使配置立即生效

Lnmp安装

1.安装nginx

yum install yum-priorities -y
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx

2.启动nginx

systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止
systemctl restart nginx.service #重启
systemctl enable nginx.service #设置开机启动
server 配置

server {
    listen 80;
    server_name api.xxx.com;

    root /www/projectname/public;

    location /api {
        index index.php index.html index.htm;

        if (!-e $request_filename) {
            rewrite . /index.php last;
        }
    }

    location ~ \.php$ {
        root /www/projectname/public;
        
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /www/projectname/public$fastcgi_script_name;
        
        include fastcgi_params;
    }
}

3.安装mariadb(MySQL)

yum install mariadb mariadb-server #询问是否要安装,输入Y即可自动安装,直到安装完成
systemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动

4.安装php
CentOS/RHEL 7.x:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

如果是centos6,那么执行以下代码:
CentOS/RHEL 6.x:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

yum -y install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel

5,安装redis
yum install -y redis

[root@localhost bin]# whereis redis-cli
redis-cli: /usr/bin/redis-cli

[root@localhost bin]# whereis redis-server
redis-server: /usr/bin/redis-server

redis-server &

https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/

相关文章

  • linux centos 7.2 lnmp+redis搭建

    一、配置防火墙,开启80端口、3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为i...

  • Linux搭建lamp(Apache+PHP+Mysql环境)c

    Linux搭建lamp(Apache+PHP+Mysql环境)centos7.2版详细教程 我们更多的网站服务器是...

  • CentOS7.2配置LNMP环境记录

    记录:CentOS7.2配置LNMP环境记录 CentOS7.2配置LNMP环境记录 LNMP是Linux、Ngi...

  • Linux安装RabbitMQ

    本文介绍Linux安装RabbitMQ简单步骤。 本文环境是在腾讯云服务器CentOS7.2搭建的,RabbitM...

  • Linux安装Elasticsearch

    本文介绍Linux环境如何安装Elasticsearch. 本文环境是在腾讯云服务器CentOS7.2搭建的,JD...

  • ElasticSearch集群搭建

    单台机器搭建3节点ES集群,本文采用elasticsearch7.2做为安装版本,linux 为centos 。理...

  • Linux安装Logstash

    本文介绍Linux环境如何安装Logstash 本文环境是在腾讯云服务器CentOS7.2搭建的,JDK1.8,L...

  • Linux安装Kibana

    本文介绍Linux环境如何安装Kibana. 本文环境是在腾讯云服务器CentOS7.2搭建的,JDK1.8,ki...

  • 使用systemd 管理elasticsearch

    本文使用的Linux 是CentOS 7.2,elasticsearch 是 7.2 一、注意事项: 使用syst...

  • TinyProxy 代理

    系统:centos7.2 linux ip:192.168.11.212 window ip:192.168.11...

网友评论

      本文标题:linux centos 7.2 lnmp+redis搭建

      本文链接:https://www.haomeiwen.com/subject/mugvvxtx.html