安装Nginx

Posted 一路向北√

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装Nginx相关的知识,希望对你有一定的参考价值。

Mac OS系统安装nginx

技术图片

安装工具:

homebrew(还没用过的小伙伴可以点链接进行了解)

技术图片

1、打开终端, 查看是否已经安装了Homebrew, 直接终端输入命令

 localhost:~ xxx$ man brew

如果Mac已经安装了, 会显示一些命令的帮助信息. 此时输入Q退出即可

BREW(1)
NAME
brew - The missing package manager for macOS
SYNOPSIS
brew --version
brew command [--verbose|-v] [options] [formula] ...
DESCRIPTION
Homebrew is the easiest and most flexible way to install the UNIX tools
Apple didn‘t include with macOS.
ESSENTIAL COMMANDS
For the full command list, see the COMMANDS section.
With --verbose or -v, many commands print extra debugging information.
Note that these flags should only appear after a command.
install formula
Install formula.
uninstall formula
:

2、查看当前电脑所安装的brew版本

localhost:~ xxx$ brew --version

3、更新brew版本*

localhost:~ xxx$ brew --update

技术图片

Error: The following directories are not writable by your user:
/usr/local/share/man/man8
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/man/man8
And make sure that your user has write permission.
chmod u+w /usr/local/share/man/man8

输入
sudo chown -R whoami:admin /usr/local/bin
接着系统会提醒你输入密码,输入密码回车之后接着输入:
sudo chown -R whoami:admin /usr/local/share
之后就能在终端继续下一步

 localhost:~ xxx$ sudo chown -R `whoami`:admin /usr/local/bin
 Password:
 localhost:~ xxx$ sudo chown -R `whoami`:admin /usr/local/share

4、查询要安装的软件nginx是否存在

 localhost:~ xxx$ brew search nginx

5、安装nginx*

localhost:~ xxx$ brew install nginx

技术图片

==> nginx
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx now and restart at login:
brew services start nginx
Or, if you don‘t want/need a background service you can just run:
nginx

查看nginx配置文件目录   
open /usr/local/etc/nginx/

查看ginx被安装到的目录 
open /usr/local/Cellar/nginx  

6、启动nginx*

localhost:~ xxx$ nginx

测试是否成功
打开浏览器访问:localhost:8080

出现下图 表示成功

 

 
技术图片
Snip20190509_2.png

7 关闭nginx*

localhost:~ xxx$ nginx -s stop





Windows 系统安装Nginx

 

以上是关于安装Nginx的主要内容,如果未能解决你的问题,请参考以下文章

nginx.conf 忽略了 nginx-ingress 配置映射片段

将 nginx rtmp 片段发送到 WebRTC

text 有用的nginx命令和片段

在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途

linux学习:Nginx--常见功能配置片段与优化-06

PHP代码-psysh调试代码片段工具