美文网首页
centos7编译安装lnmp

centos7编译安装lnmp

作者: Drunken罂粟 | 来源:发表于2019-11-13 16:28 被阅读0次

    环境包括:nginx php mysql

    yum源更新:yum -y update

    yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gcc gcc++ autoconf

    icu libicu libicu-devel openldap openldap-develgcc-c++

    nginx安装流程

    下载安装包:wget https://nginx.org/download/nginx-1.16.0.tar.gz

    解压:tar zxvf nginx-1.16.0.tar.gz

    添加nginx组,用户:

    [root@n1 nginx-1.14.2]# groupadd nginx

    [root@n1 nginx-1.14.2]# useradd nginx -g nginx -s /sbin/nologin -M

    对nginx进行配置: ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/config/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --pid-path=/usr/local/nginx/logs/nginx.pid --http-log-path=/usr/local/nginx/logs/access.log --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module 【https://www.cnblogs.com/flashfish/p/11025961.html(有关编译的说明)】

    原文链接:https://blog.csdn.net/weixin_41114593/article/details/82285604

    编译安装:make && make install

    其他用法:

    1.nginx -t 【检查配置文件语法是否正确】

    2.nginx -v【查看nginx版本号】

    安装后配置

    $ vim /etc/profile.d/nginx.sh

    export PATH=/usr/local/nginx/sbin:$PATH

    $ source /etc/profile.d/nginx.sh

    启动/停止/重载/

    启动:nginx

    停止:nginx -s stop

    重载:nginx -s reload

    php7安装流程

    下载安装包:wget https://www.php.net/distributions/php-7.3.10.tar.gz

    解压:tar zxvf php-7.3.10.tar.gz

    创建用户和组

    1.[root@cloudhost ~]# groupadd www-data

    2.[root@cloudhost ~]# useradd -g www-data www-data

    对php进行配置:./configure --prefix=/export/lnmp/php7 \

    --with-config-file-path=/export/lnmp/php7/etc \

    --with-fpm-user=www-data \

    --with-fpm-group=www-data \

    --with-mysqli=mysqlnd \

    --with-pdo-mysql=mysqlnd \

    --with-iconv-dir \

    --with-freetype-dir \

    --with-jpeg-dir \

    --with-png-dir \

    --with-zlib \

    --with-sqlite3 \

    --with-libxml-dir \

    --with-ldap=shared \

    --with-gdbm \

    --with-pear \

    --with-gettext \

    --with-curl \

    --with-xmlrpc \

    --with-openssl \

    --with-mhash \

    --with-gd \

    --with-pcre-regex \

    --enable-fpm \

    --enable-mysqlnd \

    --enable-mysqlnd-compression-support \

    --enable-xml \

    --enable-rpath \

    --enable-bcmath \

    --enable-shmop \

    --enable-sysvsem \

    --enable-inline-optimization \

    --disable-debug \

    --enable-mbregex \

    --enable-mbstring \

    --enable-intl \

    --enable-ftp \

    --enable-gd-jis-conv \

    --enable-pcntl \

    --enable-sockets \

    --enable-zip \

    --enable-soap \

    --with-bz2 \

    --enable-fileinfo \

    --enable-opcache \

    --with-iconv \

    --with-cdb \

    --enable-calendar \

    --enable-maintainer-zts \

    --enable-dom \

    --enable-exif \

    --enable-filter \

    --with-gmp \

    --enable-json \

    --enable-mbregex-backtrack \

    --with-onig \

    --with-readline \

    --enable-session \

    --enable-simplexml \

    --enable-sysvmsg \

    --enable-sysvshm \

    --enable-wddx \

    --with-xsl \

    --with-pear

    【https://blog.csdn.net/ZHANG_TIMI/article/details/99410608】

    编译安装:make && make install

    配置php.ini文件

    具体的路径,大家可自行修改。cd

    1.cp php.ini-development /data/nmp/php/etc/php.ini

    2.cp /data/nmp/php/etc/php-fpm.conf.default /data/nmp/php/etc/php-fpm.conf

    3.cp /data/nmp/php/etc/php-fpm.d/www.conf.default /data/nmp/php/etc/php-fpm.d/www.conf

    4.cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

    配置php.ini文件

    max_execution_time = 120

    max_input_time = 120

    memory_limit = 1024M

    post_max_size = 128M

    date.timezone = PRC

    extension_dir = "/data/nmp/php/lib/php/extensions/no-debug-zts-20180731"

    问题1:configure: error: DBA: Could not find necessary header file(s).

    解决办法:yum install gdbm-devel

    问题2:configure: error: Cannot find ldap libraries in /usr/lib

    解决办法:cp -frp /usr/lib64/libldap* /usr/lib/

    问题2:configure: error: Cannot find ldap libraries in /usr/lib

    解决办法:

    1.wget https://libzip.org/download/libzip-1.5.2.tar.gz【https://libzip.org/download/ 下载源码】

    2.tar zxvf libzip-1.5.2.tar.gz

    3.cd libzip-1.5.2

    4.mkdir build && cd build && cmake .. && make && make install

    问题3:CMake 3.0.2 or higher is required. You are running version 2.8.12.2

    解决办法:

    1.先删除原有cmake  yum remove cmake 【yum install gcc-c++】

    2.wget https://github.com/Kitware/CMake/releases/download/v3.16.0-rc2/cmake-3.16.0-rc2.tar.gz【https://cmake.org/download/ 下载源码】

    3.tar zxvf cmake-3.16.0-rc2.tar.gz

    4.cd cmake-3.16.0-rc2

    5../bootstrap && make && make install

    6.ln -s /usr/local/bin/cmake /usr/bin/cmake{具体看是不是这个目录}执行目录【/usr/local/bin】

    问题4:error: off_t undefined; check your library configuration

    解决办法:

    # 添加搜索路径到配置文件

    echo '/usr/local/lib64

    /usr/local/lib

    /usr/lib

    /usr/lib64'>>/etc/ld.so.conf

    # 更新配置

    ldconfig -v

    一些常见的php问题解决方法 -  包含上面的问题【https://www.cnblogs.com/jkko123/p/10790427.html

    mysql8安装流程

    下载安装包:wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.16.tar.gz

    解压:tar zxvf php-7.3.10.tar.gz

    【升级Gcc-(https://www.cnblogs.com/NanZhiHan/p/11010130.html)】

    1、下载源码包

    wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-9.2.0/gcc-9.2.0.tar.gz

    wget http://mirrors.nju.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz

    ftp://gcc.gnu.org/pub/gcc/infrastructure/

    2、进入gcc目录,安装gcc依赖库

    cd gcc

    ./contrib/download_prerequisites

    执行命令后它会自动下载mpfr、gmp、mpc isl这4个库

    问题1:如果执行报错:tar (child): lbzip2: no exec: no file or directory

    解决方法:安装解压软件即可

    yum -y install bzip2

    3、在新目录中配置、编译、安装

    mkdir build

    cd build

    ../configure --prefix=/usr/local/gcc --enable-languages=c,c++ --disable-multilib

    make

    make install

    mv /usr/bin/gcc /usr/bin/gcc_old

    ln -s /usr/local/gcc/bin/gcc /usr/bin/gcc

    mv /usr/bin/g++ /usr/bin/g++_old

    ln -s /usr/local/gcc/bin/g++ /usr/bin/g++

    gcc --verson

    g++ --version

    https://www.jianshu.com/p/df8e82ade760--version `CXXABI_1.3.9' not found

    编译程序

    mkdir bld

    cd bld

    cmake ../ -DCMAKE_INSTALL_PREFIX=/export/lnmp/mysql \

    -DDEFAULT_CHARSET=utf8 \

    -DDEFAULT_COLLATION=utf8_general_ci \

    -DSYSCONFDIR=/etc \

    -DWITH_EXTRA_CHARSETS=all \

    -DMYSQL_DATADIR=/export/lnmp/mysql/data \

    -DWITH_BOOST=/export/installp/mysql-8.0.16/boost \

    -DFORCE_INSOURCE_BUILD=1 \

    -DCMAKE_CXX_COMPILER=/usr/local/gcc/bin/g++ \

    -DDEFAULT_CHARSET=utf8

    make

    make install

    创建数据库用户

    useradd -s /sbin/nologin mysql

    创建数据存放目录并修改权限

    mkdir /usr/local/mysql/data

    chown -R mysql:mysql /usr/local/mysql

    修改配置文件(根据自己的情况来配置)

    [mysqld]

    port=3306

    server-id=1

    basedir=/usr/local/mysql

    datadir=/usr/local/mysql/data

    socket=/usr/local/mysql/mysql.sock

    [client]

    socket=/usr/local/mysql/mysql.sock

    初始化数据库并安装ssl

    /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/database/  --log-error=/usr/local/mysql/log/mysqld.log

    # /usr/local/mysql/bin/mysql_install_db    //安装命令

    --initialize                                                  //生成默认密码 

    --user=mysql                                            //指定mysql用户

    --basedir=/usr/local/mysql/                      //安装目录

    --datadir=/usr/local/mysql/database/                // 数据库目录

    --log-error=/usr/local/mysql/log/mysqld.log    // 指定日志文件,安装过程中数据库生成的初

    /usr/local/mysql/bin/mysql_ssl_rsa_setup

    复制启动脚本、启动

    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

    /etc/init.d/mysqld  start

    修改mysql密码(忘记密码)

    9.1在配置文件中的[mysqld]下加入skip-grant-tables

    vim /etc/my.cnf

          [mysqld]

          skip-grant-tables

    9.2重启mysql

    /etc/init.d/mysqld restart

    9.3登录数据库后,修改密码为空。

    mysql

        mysql >use mysql;

        mysql >update user set authentication_string="" where user='root';

        mysql >flush privileges;

        mysql > exit;

    9.4在配置文件中删除skip-grant-tables并重启mysql

    /etc/init.d/mysqld restart

    9.5登录mysql,修改密码

    mysql -uroot -p

        mysql>ALTER user 'root'@'localhost' IDENTIFIED BY 'tengxun@123';密码要复杂点}

        mysql>flush provoleges;

        mysql>exit;

    更改加密方式和更新用户密码

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密规则

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';  #更新一下用户的密码

    相关文章

      网友评论

          本文标题:centos7编译安装lnmp

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