其他分享
首页 > 其他分享> > Ubutu20.04 安装LNMP 环境教程

Ubutu20.04 安装LNMP 环境教程

作者:互联网

一、更换源

cat > /etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
EOF

apt-get update -y  #更新源

二、安装基本工具

1、apt-get install -y wget vim net-tools bash* build-essential cmake bison libncurses5-dev libssl-dev pkg-config libxml2-dev zlib1g-dev libbz2-dev libcurl4-gnutls-dev libjpeg-dev libpng-dev libgmp-dev libgmp3-dev libmcrypt-dev mcrypt libedit-dev libreadline-dev libxslt1-dev libpcre3 libpcre3-dev libfreetype6-dev

source /usr/share/bash-completion/bash_completion

 

2、wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
cd ../
tar xf boost_1_59_0.tar.gz -C /usr/local/
cd /usr/local/
mv boost_1_59_0/ boost
cd boost
ls -l

 

三、Mysql

     1、下载  wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.35.tar.gz

     2、解压  tar -zxvf mysql-boost-5.7.35.tar.gz;cd mysql-5.7.35/

     3、编译安装

          cmake . \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.35 \
-DSYSCONFDIR=/usr/local/mysql-5.7.35/ \
-DMYSQL_DATADIR=/usr/local/mysql-5.7.35/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.7.35/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_SSL=system \
-DWITH_BOOST=/usr/local/boost

   4、安装   make && make install

 

四、后续配置

      1、cd /usr/local/mysql-5.7.35/;mkdir mysql-files;chmod 750 mysql-files/

      2、vim my.cnf 

[mysqld]

port=3306
basedir=/usr/local/mysql-5.7.35
datadir=/usr/local/mysql-5.7.35/data
socket=/usr/local/mysql-5.7.35/mysql.sock
log-error=/usr/local/mysql-5.7.35/mysqld.log

 

   3、创建普通用户

       1、useradd -r -s /sbin/nologin mysql

      2、chown -R mysql:mysql /usr/local/mysql-5.7.35

  4、初始化设置

     1、bin/mysqld --defaults-file=/usr/local/mysql-5.7.35/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql-5.7.35

     2、bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql-5.7.35/data

     3、创建启动脚本

        cp support-files/mysql.server /etc/init.d/mysql 

    4、开机自启

           update-rc.d mysql defaults

四、启动mysql

        1、service mysql start && service mysql status

        2、获取初始密码

            grep -r root@localhost: mysqld.log

     3、登录MySql

            1、bin/mysql -u root -p

             2、修改密码

                 set password for root@localhost = password('123456Aa.');

                 grant all privileges on *.* to 'root'@'%' identified by '123456Aa.';

                  flush privileges;

 

  

 

标签:教程,5.7,LNMP,dev,35,usr,mysql,Ubutu20.04,local
来源: https://www.cnblogs.com/zols/p/16481842.html