• LNMP编译安装


    目录

    一、关闭防火墙

    二、安装依赖包

    ​三、nginx

    1.创建用户

    2.编译安装 

    3.优化路径

    4.添加服务 

    ​四、mysql

    1.安装依赖包

    ​2.创建用户

    3.编译安装 

    4.修改mysql配置文件 

    5.更改属主属组 

    6.设置路径环境变量 

    ​7.初始化数据库

    8.添加mysql系统服务 

    ​9.修改mysql密码 

    ​10.授权远程登录

     五、PHP

    1.安装环境依赖包

     2.编译安装

    3.路径优化 

    4.调整PHP配置文件 

    5.启动php-fpm 

    ​6.配置nginx支持php解析

    ​7.验证php测试页 

    ​8.验证数据库工作是否正常

    六、论坛部署 


    一、关闭防火墙

    1. systemctl stop firewalld
    2. systemctl disable firewalld
    3. setenforce 0

    二、安装依赖包

    yum install -y pcre-devel zlib-devel gcc gcc-c++ make

    三、nginx

    1.创建用户

    useradd -M -s /sbin/nologin nginx

    2.编译安装 

    1. cd /opt
    2. tar zxvf nginx-1.15.9.tar.gz
    3. cd nginx-1.15.9/
    4. ./configure \
    5. > --prefix=/usr/local/nginx \
    6. > --user=nginx \
    7. > --group=nginx \
    8. > --with-http_stub_status_module

     

      

    make && make install

    3.优化路径

    ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin

    4.添加服务 

    1. vim /lib/systemd/system/nginx.service
    2. [Unit]
    3. Description=nginx
    4. After=network.target
    5. [Service]
    6. Type=forking
    7. PIDFile=/usr/local/nginx/logs/nginx.pid
    8. ExecStart=/usr/local/nginx/sbin/nginx
    9. ExecReload=/bin/kill -s HUP $MAINPID
    10. ExecStop=/bin/kill -s QUIT $MAINPID
    11. PrivateTmp=true
    12. [Install]
    13. WantedBy=multi-user.target
    14. chmod 754 /lib/systemd/system/nginx.service
    15. systemctl start nginx.service
    16. systemctl enable nginx.service
    17. systemctl status nginx.service

     

    四、mysql

     1.安装依赖包

    1. yum install -y \
    2. ncurses \
    3. ncurses-devel \
    4. bison \
    5. cmake

     

    2.创建用户

    1. useradd -s /sbin/nologin mysql
    2. tail -2 /etc/passwd

     

    3.编译安装 

    1. cd /opt
    2. tar zxvf mysql-boost-5.7.20.tar.gz
    3. cd mysql-5.7.20/
    4. cmake \
    5. > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    6. > -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
    7. > -DSYSCONFDIR=/etc \
    8. > -DSYSTEMD_PID_DIR=/usr/local/mysql \
    9. > -DDEFAULT_CHARSET=utf8 \
    10. > -DDEFAULT_COLLATION=utf8_general_ci \
    11. > -DWITH_EXTRA_CHARSETS=all \
    12. > -DWITH_INNOBASE_STORAGE_ENGINE=1 \
    13. > -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
    14. > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
    15. > -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
    16. > -DMYSQL_DATADIR=/usr/local/mysql/data \
    17. > -DWITH_BOOST=boost \
    18. > -DWITH_SYSTEMD=1
    19. make && make install

    4.修改mysql配置文件 

    1. vim /etc/my.cnf
    2. [client]
    3. port = 3306
    4. socket=/usr/local/mysql/mysql.sock
    5. [mysqld]
    6. user = mysql
    7. basedir=/usr/local/mysql
    8. datadir=/usr/local/mysql/data
    9. port = 3306
    10. character-set-server=utf8
    11. pid-file = /usr/local/mysql/mysqld.pid
    12. socket=/usr/local/mysql/mysql.sock
    13. bind-address = 0.0.0.0
    14. skip-name-resolve
    15. max_connections=2048
    16. default-storage-engine=INNODB
    17. max_allowed_packet=16M
    18. server-id = 1
    19. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,
    20. NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,
    21. NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

    5.更改属主属组 

    1. chown -R mysql:mysql /usr/local/mysql
    2. chown mysql:mysql /etc/my.cnf
    3. ll /etc/my.cnf
    4. ll /usr/local/mysql

    6.设置路径环境变量 

    1. echo 'export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
    2. source /etc/profile

    7.初始化数据库

    1. cd /usr/local/mysql/bin/
    2. ./mysqld \
    3. > --initialize-insecure \
    4. > --user=mysql \
    5. > --basedir=/usr/local/mysql \
    6. > --datadir=/usr/local/mysql/data

    8.添加mysql系统服务 

    1. cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
    2. systemctl daemon-reload
    3. systemctl start mysqld.service
    4. systemctl enable mysqld
    5. netstat -natp |grep 3306

    9.修改mysql密码 

    mysqladmin -u root -p password "123456"

    10.授权远程登录

    mysql -u root -p 

     

     五、PHP

    1.安装环境依赖包

    1. yum install -y gd \
    2. > libjpeg libjpeg-devel \
    3. > libpng libpng-devel \
    4. > freetype freetype-devel \
    5. > libxml2 libxml2-devel \
    6. > zlib zlib-devel \
    7. > curl curl-devel \
    8. > openssl openssl-devel

     2.编译安装

    1. cd /opt
    2. tar xjvf php-7.1.10.tar.bz2
    3. cd php-7.1.10/
    4. ./configure \
    5. --prefix=/usr/local/php \
    6. --with-mysql-sock=/usr/local/mysql/mysql.sock \
    7. --with-mysqli \
    8. --with-zlib \
    9. --with-curl \
    10. --with-gd \
    11. --with-jpeg-dir \
    12. --with-png-dir \
    13. --with-freetype-dir \
    14. --with-openssl \
    15. --enable-fpm \
    16. --enable-mbstring \
    17. --enable-xml \
    18. --enable-session \
    19. --enable-ftp \
    20. --enable-pdo \
    21. --enable-tokenizer \
    22. --enable-zip
    23. make && make install

    3.路径优化 

    1. ln -s /usr/local/php/bin/* /usr/local/bin/
    2. ln -s /usr/local/php/sbin/* /usr/local/sbin/

    4.调整PHP配置文件 

    1. php有三个配置文件:
    2. php.ini 主配置文件
    3. php-fpm.conf 进程服务配置文件
    4. www.conf 扩展配置文件
    5. 调整主配置文件:
    6. cp /opt/php-7.1.10/php.ini-development /usr/local/php/lib/php.ini
    7. vim /usr/local/php/lib/php.ini

    php -m

    1. 调整进程服务配置文件:
    2. cd /usr/local/php/etc/
    3. cp php-fpm.conf.default php-fpm.conf
    4. vim php-fpm.conf

    1. 调整扩展配置文件:
    2. cd /usr/local/php/etc/php-fpm.d/
    3. cp www.conf.default www.conf
    4. ls

    5.启动php-fpm 

    1. /usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
    2. netstat -anpt | grep 9000

    1. cd /opt/php-7.1.10/sapi/fpm
    2. cp php-fpm.service /usr/lib/systemd/system/php-fpm.service
    3. systemctl restart php-fpm.service
    4. systemctl status php-fpm.service

    6.配置nginx支持php解析

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

    1. systemctl restart nginx.service
    2. netstat -natp |grep nginx

    7.验证php测试页 

    vim /usr/local/nginx/html/index.php

    8.验证数据库工作是否正常

    mysql -u root -p

    vim /usr/local/nginx/html/index.php

    六、论坛部署 

    1. cd /opt
    2. unzip Discuz_X3.4_SC_UTF8.zip -d /tmp

    1. cd /tmp/dir_SC_UTF8/
    2. cp -r upload/ /usr/local/nginx/html/bbs/
    3. cd /usr/local/nginx/html/bbs/
    4. chmod -R 777 ./config/
    5. chmod -R 777 ./data/
    6. chmod -R 777 ./uc_client/
    7. chmod -R 777 ./uc_server/
    8. 或者
    9. chown -R root:nginx ./config/
    10. chown -R root:nginx ./data/
    11. chown -R root:nginx ./uc_client/
    12. chown -R root:nginx ./uc_server/

     

  • 相关阅读:
    LeetCode 算法:K 个一组翻转链表 c++
    VB.Net读写NFC Ntag标签源码
    clone()方法使用时遇到的问题解决方法(JAVA)
    金仓数据库KingbaseES客户端编程接口指南-JDBC(2. 概述)
    python:bisect查找和排序
    【C#】async和await
    Pr:添加字幕轨道
    闲人闲谈PS之三十四——项目成本费用控制阈值
    MySQL学习(八)——锁
    【opencv】Opencv中数据类型CV_8U, CV_16U, CV_16S, CV_32F、CV_64F
  • 原文地址:https://blog.csdn.net/Drw_Dcm/article/details/126494662