whcoding whcoding
首页
归档
关于
GitHub (opens new window)
首页
归档
关于
GitHub (opens new window)
  • PHP

  • Composer

  • 环境

    • Ubuntu 系统apt安装 lnmp环境
    • Ubuntu源码编译安装lnmp环境
    • 其他

    • 技术
    • 环境
    whcoding
    2021-04-18
    目录

    Ubuntu源码编译安装lnmp环境

    ubuntu源码编译安装lnmp环境

    # 安装步骤

    1. 安装所需依赖环境
    2. 配置编译参数
    3. 编译与安装

    # 安装 nginx

    # 下载nginx源码包

    • 源码地址 (opens new window)
    wget http://nginx.org/download/nginx-1.19.10.tar.gz
    
    1

    # 解压

    tar -xzvf nginx-1.19.10.tar.gz
    
    1

    # 配置编译参数

    可以通过./configure --help 命令来看需要配置那些或者参考 nginx官方文档 (opens new window)

    ./configure --prefix=/usr/local/nginx  --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf  --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.44 --with-zlib=../zlib-1.2.11
    
    1

    # 编译安装

    参数配置完成之后源码目录会多出一个Makefile文件, 我们就可以编译安装了

    make && make install
    
    1
    # nginx 常用命令
    ./nginx
    ./nginx -s stop
    ./nginx -s quit
    ./nginx -s reload
    
    1
    2
    3
    4
    # 可能会遇到的错误

    每个人的环境不同和需要编译的模块不同, 出现的错误也不相同的, 但是基本都是缺少相关的依赖, 根据error提示安装上就可以了.

    ./configure: error: C compiler cc is not found
    
    1

    # 安装PHP

    整体和nginx源码安装是一致的

    # 下载PHP源码包

    • 源码地址 (opens new window)
    • 官方安装文档 (opens new window)
    wget https://www.php.net/distributions/php-8.0.3.tar.gz
    
    1

    # 配置编译参数

    ./configure --enable-fpm --with-mysql
    
    1

    # 编译安装

    make && make install
    
    1

    # 复制配置文件

    cp php.ini-development /usr/local/php/php.ini
    cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf
    cp sapi/fpm/php-fpm /usr/local/bin
    
    1
    2
    3

    # 修改 php-fpm 模块使用 www-data 用户和 www-data 用户组的身份运行

    vim /usr/local/etc/php-fpm.d/www.conf
    
    1
    ; Unix user/group of processes
    ; Note: The user is mandatory. If the group is not set, the default user's group
    ;       will be used.
    user = www-data
    group = www-data
    
    1
    2
    3
    4
    5
    # 启动
    /usr/local/bin/php-fpm
    
    1

    # 将 php-fpm 添加到系统服务

    在php源码目录执行 这样做的好处就是可以使用 service 命令来管理php-fpm

    cp /home/php-8.0.3/sapi/fpm/init.d.php-fpm /etc/init.d/php8-fpm 
    
    chmod +x /etc/init.d/php8-fpm
    
    1
    2
    3

    # 安装Mysql

    todo...

    #lnmp
    上次更新: 2022/08/30, 23:31:20
    Ubuntu 系统apt安装 lnmp环境
    操作系统学习

    ← Ubuntu 系统apt安装 lnmp环境 操作系统学习→

    Theme by Vdoing | Copyright © 2018-2023
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式