LNMP架构Nginx源码包安装

本文详细介绍了如何从源码编译安装Nginx1.14.0版本,并进行基本配置,包括软件依赖安装、模块选择、编译参数设置、配置文件修改及启动命令说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 获取安装包,解压
    在这里插入图片描述

     tar zxf nginx-1.14.0.tar.gz
    
  2. 安装软件依赖

      yum install -y pcre-devel 
      vim /root/nginx-1.14.0/src/core/nginx.h
      再此文件中
      #define nginx_version      1014000
      #define NGINX_VERSION      "1.14.0"
      #define NGINX_VER          "nginx/"   /后面后面是nginx版本号,为了安全将其隐藏
    
  3. 关闭debug日志

     vim /root/nginx-1.14.0/src/core/nginx.h
    

在这里插入图片描述

  1. 安装对应的模块

       ./configure --prefix=/usr/local/lnmp/nginx \
        --with-threads --with-file-aio  \
        --with-http_ssl_module \
         --with-http_stub_status_module  \
         --user=nginx  \
         --group=nginx \
    
  2. 编译安装

     make && make install
    

在这里插入图片描述

  1. 修改相关配置

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

作三处修改
在这里插入图片描述
让其默认先打开php页面
在这里插入图片描述
在这里插入图片描述

[root@server1 sbin]# ./nginx -t  ##检测文件语法的正确性
nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful

[root@server1 sbin]# ./nginx -v     ##查看nginx的版本
nginx version: nginx/						
[root@server1 sbin]# ./nginx -V	## 查看安装nginx时添加了那些配置
nginx version: nginx/
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/lnmp/nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx

制作软连接,便于启动

 ln -s /usr/local/lnmp/nginx/sbin/nginx /usr/local/sbin/
 ### 编写默认发布页,启动nginx
vim  /usr/local/lnmp/nginx/html/index.php 
[root@server1 html]# cat index.php 
<?php
phpinfo()
?>
 /etc/init.d/php-fpm start
nginx    ##启动nginx,由于制作了软连接

测试

如果没有写php页面,访问html页面
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值