zoukankan      html  css  js  c++  java
  • CentOS7.x搭建LNMP

    一.nginx安装

    1.安装先决条件

     yum install yum-utils

    2.设置yum存储库和创建/etc/yum.repos.d/nginx.repo 使用以下内容命名的文件 :
    稳定版

    [nginx-stable]

    name=nginx stable repo

    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/

    gpgcheck=1

    enabled=1

    gpgkey=https://nginx.org/keys/nginx_signing.key

    3.默认情况用稳定版本的,使用主线nginx包,请运行以下命令:
    yum -config-manager --enable nginx-mainline

    4.安装nginx
    yum install nginx -y

    5.启动nginx和开机自启nginx设置
    systemctl  start nginx
    systemctl enable  nginx

    6.查看安装的nginx  版本

    nginx  -v
     
    二数据库mariadb数据库安装

     yum  install mariadb mariadb-server mariadb-libs mariadb-devel 

        

    启动 mysql:          systemctl  start mariadb      

    设置 mysql开机自启动:    systemctl  enable   mariadb            

    检查mysql状态:     systemctl  status  mariadb 

    mysql数据库安全设置:

        mysql_secure_installation

        

        

        

    登录测试mysql数据库:

        mysql -uroot   -p  密码(上图安全设置的密码)

        show  databases;显示mysql数据库现有的库

        use  mysql;

        

    三安装php
    2个需要更新的rpm包地址下载
    https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    rpm –ivh   2个rpm包安装
     
    yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt
    php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd
    php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb
    (php 、php-mysql、php-fpm这三个必须安装)
     
    启动php-fpm

    systemctl enable  php-fpm

    systemctl start  php-fpm

    四.修改nginx配置文件(nginx有2个配置文件,nginx.conf文件是引用default.conf)

    vim /etc/nginx/conf.d/default.conf

     

    五测试

    ①添加info.php测试网页

    Vim /usr/share/nginx/html/info.php

     

    ②重启nginx和php-fpm

    systemctl restart nginx && systemctl restart php-fpm

    ③浏览器输入地址登录

     

     完结

  • 相关阅读:
    162 基于UDP协议的socket套接字编程
    161 解决粘包问题
    160 粘包问题
    159 模拟ssh远程执行命令
    158 Socket抽象层
    157 基于TCP协议的socket套接字编程
    C++:查找字符串字串并替换
    C++:查找字符串字串并替换
    请问c++中的#include "stdafx.h"是什么意思?
    请问c++中的#include "stdafx.h"是什么意思?
  • 原文地址:https://www.cnblogs.com/wzhc/p/12395507.html
Copyright © 2011-2022 走看看