zoukankan      html  css  js  c++  java
  • centos7.4下搭建LNMP

    版本:nginx-1.13.7、mysql-5.6.14-linux-glibc2.5-x86_64、php-7.1.7

    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo(搭建公网)

    安装nginx

    yum install -y pcre-devel openssl-devel(安装依赖包)

    wget http://nginx.org/download/nginx-1.13.7.tar.gz (nginx下载网址)

    useradd -s /sbin/nologin -M www  (程序用户)

    tar xf nginx-1.13.7.tar.gz -C /usr/src/ (解包)

    cd /usr/src/nginx-1.13.7/ 

    ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module (预配置)

    make && make install(编译安装)

    ln -s /usr/local/nginx/sbin/* /usr/local/sbin/  (软链接)

    /usr/local/nginx/sbin/nginx (启动nignx)

    安装mysql5.6二进制包

    groupadd mysql (创建mysql用户组)

    useradd -s /sbin/nologin -g mysql -M mysql (创建mysql程序用户并指定组)

    tar xf mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz -C /usr/local/ (解压二进制包)

    cd /usr/local/

    mv mysql-5.6.14-linux-glibc2.5-x86_64 mysql-5.6.14(改名)

    ln -s mysql-5.6.14 mysql

    cd /usr/local/mysql/

    /bin/cp support-files/my-default.cnf /etc/my.cnf  (my.cnf 是mysql的配置文件)

    mkdir -p /usr/local/mysql/data   (建立MySQL数据文件目录)

    chown -R mysql.mysql /usr/local/mysql  (授权mysql用户管理mysql的安装目录)

    yum -y install libaio

    yum -y install cpan

    yum -y install perl* (三个依赖包)

    /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql (初始化MySQL数据库文件)

    cp support-files/mysql.server /etc/init.d/mysqld (拷贝mysql启动脚本到mysql的命令路径)

    chmod +x /etc/init.d/mysqld (授执行权限)

    /etc/init.d/mysqld start (启动mysql)

    netstat -antup | grep mysql (查看mysql进程)

    设置开机自启动:

    chkconfig --add mysqld

    chkconfig mysqld on

    chkconfig --list mysqld

    ln -s /usr/local/mysql/bin/* /usr/local/bin/ (配置mysql命令的全局使用路径)

    mysqladmin -u root password '123123'   (设置msyql登录密码)

    mysql -uroot -p123123 (登录)

    安装php7.1

    yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel  

    yum -y install freetype-devel libpng-devel gd libcurl-devel libxslt-devel

    rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel

    rpm -qa freetype-devel libpng-devel gd libcurl-devel libxslt-devel

    tar xf libiconv-1.15.tar.gz -C /usr/src/  (源码安装libiconv包,php依赖包)

    cd /usr/src/libiconv-1.15/

    ./configure --prefix=/usr/local/libiconv && make && make install

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo    安装libmcrypt库

    yum -y install libmcrypt-devel

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo      安装mhash加密扩展库

    yum -y install mhash

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo      安装mcrvpt加密扩展库

    yum -y install mcrypt

    tar xf php-7.1.7.tar.gz -C /usr/src/

    cd /usr/src/php-7.1.7/

    ./configure --prefix=/usr/local/php --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-simplexml --enable-xml --disable-rpath --enable-bcmath --enable-soap --enable-zip --with-curl --enable-fpm --with-fpm-user=nobody --with-fpm-group=nobody --enable-mbstring --enable-sockets --with-gd --with-openssl --with-mhash --enable-opcache --disable-fileinfo  (php7不能调取mysql函数,所以预配置一定带以上两个参数)

    ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

    touch ext/phar/phar.phar

    make (进行编译,如果结果为'make test'则继续往下,如里报错为

    则重新预配置,并在最后加上--with-iconv=/usr/local/libiconv ,预配置完成后,再make编译即可成功

    make install (安装)

    cp php.ini-production /usr/local/php/lib/php.ini (拷贝PHP配置文件到PHP默认目录,并更改文件名称为php.ini)

    cd /usr/local/php/etc/

    cp php-fpm.conf.default php-fpm.conf  ( 配置PHP(FastCGI方式)的配置文件php-fpm.conf)

    /usr/local/php/sbin/php-fpm  (启动PHP服务php-fpm)

    ps -ef | grep php-fpm     lsof -i:9000    检查PHP服务php-fpm的进程及启动端口的情况

    配置nginx支持PHP程序请求访问

     cd /usr/local/nginx/conf/

     cp nginx.conf nginx.conf.02

    cat nginx.conf.02 | egrep -v "^$|#" > nginx.conf

    vim /usr/local/nginx/conf/nginx.conf

    cd /usr/local/nginx/conf/extra/

     

    vim /usr/local/nginx/html/mailcom/test_info.php

    <?php

    phpinfo();

    ?>

    记得一定要重启nignx,时刻重启

    小可爱lnmp环境搭建完了

  • 相关阅读:
    并行计算的技术路径
    Qt 中文编码问题记录
    rest_rpc 编译安装和测试 ubuntu18.04
    Qt QPorcess 启动外部程序失败的原因之一
    ubuntu 下 cesium的环境搭建
    Qt 渐变色笔记
    Qt编写的自定义控件为什么在QtDesigner中可见,在QtCreator中不可见
    Qt 编译及自动部署 库 工具集(自动复制生成的库及头文件到指定的安装路径)
    Windows10 OSG 编译安装及集成至Qt
    百度图像识别SDK简单使用
  • 原文地址:https://www.cnblogs.com/jiayannvwang/p/9493676.html
Copyright © 2011-2022 走看看