ubuntu最详细安装nginx_ubuntu centos debian

ubuntu最详细安装nginx_ubuntu centos debian1、创建nginx账号root@ubuntu:/usr#useradd-mnginx

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

1、创建nginx账号

root@ubuntu:/usr# useradd -m nginx
root@ubuntu:/usr# passwd nginx
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@ubuntu:/usr# su nginx
# 为nginx添加bash权限,默认为sh
vi /etc/passwd

# 修改如下/bin/bash
nginx:x:1001:1001::/home/nginx:/bin/bash

2、创建nginx工作目录

nginx@ubuntu:/$ cd /usr/local/
nginx@ubuntu:/$ sudo mkdir nginx
nginx@ubuntu:/$ sudo chown nginx:nginx nginx/
nginx@ubuntu:/$ cd nginx
nginx@ubuntu:/usr/local/nginx$ wget http://nginx.org/download/nginx-1.21.0.tar.gz
--2021-06-07 01:18:15--  http://nginx.org/download/nginx-1.21.0.tar.gz
Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5704::6, ...
Connecting to nginx.org (nginx.org)|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1063682 (1.0M) [application/octet-stream]
Saving to: ‘nginx-1.21.0.tar.gz’

nginx-1.21.0.tar.gz                        100%[======================================================================================>]   1.01M   188KB/s    in 5.5s    

2021-06-07 01:18:22 (188 KB/s) - ‘nginx-1.21.0.tar.gz’ saved [1063682/1063682]

nginx@ubuntu:/usr/local/nginx$ tar -zxf nginx-1.21.0.tar.gz 

nginx@ubuntu:/usr/local/nginx$ cd nginx-1.21.0/

3、准备nginx 环境

#解决依赖包openssl安装
sudo apt-get install openssl libssl-dev

#解决依赖包pcre安装
sudo apt-get install libpcre3 libpcre3-dev

#解决依赖包zlib安装
sudo apt-get install zlib1g-dev

 4、编译nginx 

nginx@ubuntu:/usr/local/nginx/nginx-1.21.0$ ./configure 
nginx@ubuntu:/usr/local/nginx/nginx-1.21.0$ make
nginx@ubuntu:/usr/local/nginx/nginx-1.21.0$ make install

5、启动nginx

#需使用root账号启动,否则报  Permission denied
nginx@ubuntu:/usr/local/nginx/$ sudo ./sbin/nginx -c /usr/local/nginx/conf/nginx.conf

6、检查状态

nginx@ubuntu:/usr/local/nginx/sbin$ ps -aux | grep nginx

root      19782  0.0  0.0  25212   412 ?        Ss   01:45   0:00 nginx: master process ./nginx -c /usr/local/nginx/conf/nginx.conf
nobody    19783  0.0  0.0  30040  2960 ?        S    01:45   0:00 nginx: worker process
nginx     19801  0.0  0.0  46780  3520 pts/0    R+   01:47   0:00 ps -aux
nginx     19802  0.0  0.0  21544  1012 pts/0    S+   01:47   0:00 grep --color=auto nginx

7、测试访问

curl http://localhost

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

8、使用nginx 命令

# 提示命令不存在
root@ubuntu:/usr/local/nginx# nginx -t

Command 'nginx' not found, but can be installed with:


# 添加环境变量
root@ubuntu:/usr/local/nginx# vim /etc/profile

# 在最后追加
NGINX_HOME=/usr/local/nginx/sbin
export PATH=$NGINX_HOME:$PATH

# source /etc/profile  使配置文件立即生效
root@ubuntu:/usr/local/nginx# source /etc/profile 

# 成功
root@ubuntu:/usr/local/nginx# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/191818.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 五个最佳FTP客户端工具「建议收藏」

    五个最佳FTP客户端工具「建议收藏」概述无论你是做网站工作,还是运行一个家庭FTP服务器,或者你只是喜欢高速下载,一个稳定且功能齐全的FTP客户端工具都可以节省你大量时间和生命,现在有大量的免费或者收费的FTP客户端软件供大家选择,这里总结了五个流行的FTP客户端软件。FileZilla(所有平台)FileZillaFileZilla是一个免费开源的适合Windows、Mac和Linux的FTP客户端软件,因为其实免费跨平台和易用性,因此它是很多FTP用户的最初选择,FileZilla下载速度非常快,功能齐全,如果你是Wind

    2022年8月30日
    2
  • Bilateral Filters(双边滤波算法)原理及实现

    Bilateral Filters(双边滤波算法)原理及实现双边滤波算法原理:双边滤波算法实现:双边滤波算法实例:参考:http://people.csail.mit.edu/sparis/bf/http://blog.csdn.net/fightingforcv/article/details/52723376http://blog.csdn.net/mumu

    2022年5月2日
    30
  • 7-16 三天打鱼两天晒网 (15分) 中国有句俗语叫“三天打鱼两天晒网”。假设某人从某天起,开始“三天打鱼两天晒网”,问这个人在以后的第N天中是“打鱼”还是“晒网”?「建议收藏」

    7-16 三天打鱼两天晒网 (15分) 中国有句俗语叫“三天打鱼两天晒网”。假设某人从某天起,开始“三天打鱼两天晒网”,问这个人在以后的第N天中是“打鱼”还是“晒网”?「建议收藏」7-16 三天打鱼两天晒网 (15分)中国有句俗语叫“三天打鱼两天晒网”。假设某人从某天起,开始“三天打鱼两天晒网”,问这个人在以后的第N天中是“打鱼”还是“晒网”?输入格式: 输入在一行中给出一个不超过1000的正整数N。输出格式: 在一行中输出此人在第N天中是“Fishing”(即“打鱼”)还是“Drying”(即“晒网”),并且输出“in day N”。 输入样例1: 103…

    2022年8月18日
    19
  • AMD CPU安装Intel HAXM

    AMD CPU安装Intel HAXM1.2.找到安装目录(我的安装目录:F:\Android\SDK\extras\google\Android_Emulator_Hypervisor_Driver)下的这个文件:silent_install,右击该文件选择“以管理员运行”,即可。…

    2022年6月28日
    83
  • 一个游戏是如何被设计和开发出来的[通俗易懂]

    一个游戏是如何被设计和开发出来的[通俗易懂]我在知乎回答“想要自己做一款游戏,需要学习哪些知识”下面简单列举了四个能力,分别是:程序、设计、美术、音乐。但是碍于篇幅限制,我并没有详细展开来说明每一项能力具体是如何发挥作用,以及发挥作用的形式和功效。如果在学习之前,我们对即将学习的东西一无所知的话,会导致学习中产生不小的迷茫感:不知道为何而学,不知道学了有什么作用,不知道该学习到什么程度。带着这样的迷茫去学习,会导致学习效率低下,容易受挫,甚…

    2022年5月27日
    35
  • linux抓包命令tcpdump 文本,Linux下抓包命令tcpdump的使用

    linux抓包命令tcpdump 文本,Linux下抓包命令tcpdump的使用在linux下,可以使用tcpdump命令来抓取数据包。主要用法如下:过滤网卡tcpdump-ieth0#抓取所有经过网卡eth0数据包tcpdump-ilo#抓取环回口的数据包过滤主机/IPtcpdumphost192.168.10.10#抓取所有IP为192.168.10.10的数据包tcpdumpsrchost192.168.10…

    2022年6月26日
    31

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号