zoukankan      html  css  js  c++  java
  • 搭建LNMP

    本次搭建实验是虚拟机(CentOS)环境,实际在云主机上搭建并无太大区别,重在体验整个lnmp搭建的流程,对于想快速建站的萌新,推荐可以用类似腾讯云上部署好的整套环境。

    环境准备:更换yum源的repo源为阿里云

    wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo #更换repo源
    yum install -y lrzsz gcc wget cmake #安装编译器等

    ##本次用的是centos7的系统,对于其他版本的centos请注意repo源的对应版本

    安装nginx-1.14.2

    cd #回到家目录
    yum -y install pcre-devel openssl-devel #环境准备
    useradd -s /sbin/nologin -M www #创建www用户
    wget http://nginx.org/download/nginx-1.14.2.tar.gz #下载nginx
    tar zxvf nginx-1.14.2.tar.gz #解压
    cd nginx-1.14.2 #进入已解压文件
    ./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/usr/local/nginx1.14.2/ #编译检查,开启ssl模块,status模块
    make && make install #执行编译并安装
    ln -s /usr/local/nginx1.14.2 /opt/nginx #创建软连接
    /opt/nginx/sbin/nginx #启动nginx并用浏览器打开检查

    ##上面的命令可以全部复制到shell里面执行

    安装mariadb-10.2.22
    cd #回到家目录
    find -H /etc/ | grep my.c #查看系统默认数据库配置文件
    rm -rf /etc/my.cnf /etc/my.cnf.d/ #删除默认数据库配置文件
    rpm -qa|grep mariadb-libs #查询系统自带mariadb-lib软件
    rpm -e `rpm -qa|grep mariadb-libs` --nodeps #删除系统自带的mariadb-libs
    yum -y install libaio libaio-devel bison bison-devel zlib-devel openssl openssl-devel ncurses ncurses-devel libcurl-devel libarchive-devel boost boost-devel lsof wget gcc gcc-c++ make cmake perl kernel-headers kernel-devel pcre-devel
    
     #安装相关依赖软件
    useradd -s /sbin/login -M -d /usr/local/mysql mysql #创建mysql用户并指定家目录
    mkdir /usr/local/mysql #创建安装目录
    mkdir -p /data/mysql #创建数据库存放目录
    chown mysql:mysql /usr/local/mysql/ #权限设置
    chown  -R mysql:mysql /data/mysql #数据库目录所属设置
    wget http://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.22/source/mariadb-10.2.22.tar.gz #下载安装包并解压
    tar zxvf mariadb-10.2.22.tar.gz && cd mariadb-10.2.22 #解压并进入
    #####执行编译######
    cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
    -DMYSQL_DATADIR=/data/mysql 
    -DSYSCONFDIR=/etc 
    -DWITHOUT_TOKUDB=1 
    -DWITH_INNOBASE_STORAGE_ENGINE=1 
    -DWITH_ARCHIVE_STPRAGE_ENGINE=1 
    -DWITH_BLACKHOLE_STORAGE_ENGINE=1 
    -DWIYH_READLINE=1 
    -DWIYH_SSL=system 
    -DVITH_ZLIB=system 
    -DWITH_LOBWRAP=0 
    -DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
    -DDEFAULT_CHARSET=utf8 
    -DDEFAULT_COLLATION=utf8_general_ci
    #######如果编译失败删除CMakeCache.txt############
    make && make install #执行安装
    ###安装完成后进行配置###
    cd /usr/local/mysql #切换目录
    ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql #执行脚本
    cp support-files/my-large.cnf /etc/my.cnf #复制MariaDB配置文件到/etc目录
    echo "export PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile #配置环境变量
    source /etc/profile #变量更新
    ./support-files/mysql.server start #启动mysql
    ./bin/mysql_secure_installation #初始化mariadb

    ##安装mariadb,时间比较慢,建议喝杯柠檬茶~~

    安装php7.3.2
    cd	#回到家目录
    yum -y install zlib-devel libxml2-devel libjpeg-devel libjepg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrpt-devel mhash bzip2-devel postgresql-devel libzip-devel #安装依赖软件
    yum -y remove libzip #删除旧版本包
    wget https://nih.at/libzip/libzip-1.2.0.tar.gz #下载安装包
    tar -zxvf libzip-1.2.0.tar.gz && cd libzip-1.2.0  #解压安装包
    ./configure #编译检查
    make && make install #编译安装
    cd #返回家目录
    cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h 
    wget http://cn2.php.net/distributions/php-7.3.2.tar.bz2	#下载php 
    tar jxvf php-7.3.2.tar.bz2 #下载并解压
    cd php-7.3.2 #进入安装文件
    ##########编译检查###################
    ####################################################
    # 添加搜索路径到配置文件
    echo '/usr/local/lib64
    /usr/local/lib
    /usr/lib
    /usr/lib64'>>/etc/ld.so.conf
    #更新配置
    ldconfig -v
    './configure' '--prefix=/usr/local/php' '--with-pdo-pgsql' '--with-zlib-dir=/usr/local/lib/libzip' '--with-freetype-dir=/usr/include/freetype2/freetype' '--enable-mbstring' '--with-libxml-dir=/usr' '--enable-soap' '--enable-calendar' '--with-curl'  '--with-gd' '--with-pgsql' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-zlib' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-pcntl' '--enable-mbregex' '--enable-exif' '--enable-bcmath' '--with-mhash' '--enable-zip' '--with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-jpeg-dir=/usr' '--with-png-dir=/usr'  '--with-openssl' '--with-fpm-user=www' '--with-fpm-group=www' '--with-libdir=/lib/x86_64-linux-gnu/' '--enable-ftp' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm' '--with-iconv' '--with-xpm-dir=/usr'
    make #编译
    make install #安装
    sed -i 's#/usr/lib64##g' /etc/ld.so.conf && sed -i 's#/usr/local/lib64##g' /etc/ld.so.conf #恢复配置
    ldconfig -v
    ##拷贝配置文件###
    cp php.ini-development /usr/local/php/etc/php.ini
    cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    cp sapi/fpm/php-fpm /usr/local/bin
    
    
    

    相关链接:nginx配置php

  • 相关阅读:
    最大子数组问题(分治策略实现)
    Solving the Detached Many-to-Many Problem with the Entity Framework
    Working With Entity Framework Detached Objects
    Attaching detached POCO to EF DbContext
    如何获取qq空间最近访问人列表
    Health Monitoring in ASP.NET 2.0
    problem with displaying the markers on Google maps
    WebMatrix Database.Open… Close() and Dispose()
    Accessing and Updating Data in ASP.NET: Retrieving XML Data with XmlDataSource Control
    Create web setup project that has crystal reports and sql script run manually on client system
  • 原文地址:https://www.cnblogs.com/lemonbk/p/10548968.html
Copyright © 2011-2022 走看看