cd nginx-1.11.5
./configure
....
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
安装报错误的话比如:“C compiler cc is not found”,这个就是缺少编译环境,安装一下就可以了 yum -y install gcc make gcc-c++ openssl-devel
如果没有error信息,就可以执行下边的安装了:
make
make install
nginx测试
运行下面命令会出现两个结果,一般情况nginx会安装在/usr/local/nginx目录中
cd /usr/local/nginx/sbin/
./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
brew install nginx
# Updating Homebrew...
# ==> Auto-updated Homebrew!
# Updated 2 taps (homebrew/core, homebrew/cask).
# ==> Updated Formulae
# ==> Installing dependencies for nginx: openssl, pcre
# ==> Installing nginx dependency: openssl
# ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.high_sierra.bottle.tar.gz
# ######################################################################## 100.0%
# ==> Pouring openssl-1.0.2o_1.high_sierra.bottle.tar.gz
# ==> Caveats
# A CA file has been bootstrapped using certificates from the SystemRoots
# keychain. To add additional certificates (e.g. the certificates added in
# the System keychain), place .pem files in
# /usr/local/etc/openssl/certs
#
# and run
# /usr/local/opt/openssl/bin/c_rehash
#
# This formula is keg-only, which means it was not symlinked into /usr/local,
# because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
#
# If you need to have this software first in your PATH run:
# echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
#
# For compilers to find this software you may need to set:
# LDFLAGS: -L/usr/local/opt/openssl/lib
# CPPFLAGS: -I/usr/local/opt/openssl/include
# For pkg-config to find this software you may need to set:
# PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
#
# ==> Summary
# 🍺 /usr/local/Cellar/openssl/1.0.2o_1: 1,791 files, 12.3MB
# ==> Installing nginx dependency: pcre
# ==> Downloading https://homebrew.bintray.com/bottles/pcre-8.42.high_sierra.bottle.tar.gz
# ######################################################################## 100.0%
# ==> Pouring pcre-8.42.high_sierra.bottle.tar.gz
# 🍺 /usr/local/Cellar/pcre/8.42: 204 files, 5.3MB
# ==> Installing nginx
# ==> Downloading https://homebrew.bintray.com/bottles/nginx-1.13.12.high_sierra.bottle.tar.gz
# ######################################################################## 100.0%
# ==> Pouring nginx-1.13.12.high_sierra.bottle.tar.gz
# ==> Caveats
# 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 wacd /usr/local/Cellar/nginx/1.13.12/n just run:
# cd /usr/local/Cellar/nginx/1.13.12/
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
重启服务即可:
service iptables restart
# 命令进行查看目前nat
iptables -t nat -L
重启服务防火墙报错解决
service iptables restart
# Redirecting to /bin/systemctl restart iptables.service
# Failed to restart iptables.service: Unit iptables.service failed to load: No such file or directory.
Whether or not to enable the poll module. This module is enabled by, default if a more suitable method such as kqueue, epoll, rtsig or /dev/poll is not discovered by configure.
--with-http_ssl_module
Enable ngx_http_ssl_module. Enables SSL support and the ability to handle HTTPS requests. Requires OpenSSL. On Debian, this is libssl-dev. 开启HTTP SSL模块,使NGINX可以支持HTTPS请求。这个模块需要已经安装了OPENSSL,在DEBIAN上是libssl
--with-http_realip_module
启用 ngx_http_realip_module
--with-http_addition_module
启用 ngx_http_addition_module
--with-http_sub_module
启用 ngx_http_sub_module
--with-http_dav_module
启用 ngx_http_dav_module
--with-http_flv_module
启用 ngx_http_flv_module
--with-http_stub_status_module
启用 "server status" 页
--without-http_charset_module
禁用 ngx_http_charset_module
--without-http_gzip_module
禁用 ngx_http_gzip_module. 如果启用,需要 zlib 。
--without-http_ssi_module
禁用 ngx_http_ssi_module
--without-http_userid_module
禁用 ngx_http_userid_module
--without-http_access_module
禁用 ngx_http_access_module
--without-http_auth_basic_module
禁用 ngx_http_auth_basic_module
--without-http_autoindex_module
禁用 ngx_http_autoindex_module
--without-http_geo_module
禁用 ngx_http_geo_module
--without-http_map_module
禁用 ngx_http_map_module
--without-http_referer_module
禁用 ngx_http_referer_module
--without-http_rewrite_module
禁用 ngx_http_rewrite_module. 如果启用需要 PCRE 。
--without-http_proxy_module
禁用 ngx_http_proxy_module
--without-http_fastcgi_module
禁用 ngx_http_fastcgi_module
--without-http_memcached_module
禁用 ngx_http_memcached_module
--without-http_limit_zone_module
禁用 ngx_http_limit_zone_module
--without-http_empty_gif_module
禁用 ngx_http_empty_gif_module
--without-http_browser_module
禁用 ngx_http_browser_module
--without-http_upstream_ip_hash_module
禁用 ngx_http_upstream_ip_hash_module
--with-http_perl_module
启用 ngx_http_perl_module
--with-perl_modules_path=PATH
指定 perl 模块的路径
--with-perl=PATH
指定 perl 执行文件的路径
--http-log-path=PATH
Set path to the http access log
--http-client-body-temp-path=PATH
Set path to the http client request body temporary files
--http-proxy-temp-path=PATH
Set path to the http proxy temporary files
--http-fastcgi-temp-path=PATH
Set path to the http fastcgi temporary files
--without-http
禁用 HTTP server
--with-mail
启用 IMAP4/POP3/SMTP 代理模块
--with-mail_ssl_module
启用 ngx_mail_ssl_module
--with-cc=PATH
指定 C 编译器的路径
--with-cpp=PATH
指定 C 预处理器的路径
--with-cc-opt=OPTIONS
Additional parameters which will be added to the variable CFLAGS. With the use of the system library PCRE in FreeBSD, it is necessary to indicate --with-cc-opt="-I /usr/local/include". If we are using select() and it is necessary to increase the number of file descriptors, then this also can be assigned here: --with-cc-opt="-D FD_SETSIZE=2048".
--with-ld-opt=OPTIONS
Additional parameters passed to the linker. With the use of the system library PCRE in - FreeBSD, it is necessary to indicate --with-ld-opt="-L /usr/local/lib".
超文本传输安全协议(缩写:HTTPS,英语:Hypertext Transfer Protocol Secure)是超文本传输协议和SSL/TLS的组合,用以提供加密通讯及对网络服务器身份的鉴定。HTTPS连接经常被用于万维网上的交易支付和企业信息系统中敏感信息的传输。HTTPS不应与在RFC 2660中定义的安全超文本传输协议(S-HTTP)相混。HTTPS 目前已经是所有注重隐私和安全的网站的首选,随着技术的不断发展,HTTPS 网站已不再是大型网站的专利,所有普通的个人站长和博客均可以自己动手搭建一个安全的加密的网站。
创建SSL证书,如果你购买的证书,就可以直接下载
sudo mkdir /etc/nginx/ssl
# 创建了有效期100年,加密强度为RSA2048的SSL密钥key和X509证书文件。
sudo openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
# 上面命令,会有下面需要填写内容
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:New York City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Bouncy Castles, Inc.
Organizational Unit Name (eg, section) []:Ministry of Water Slides
Common Name (e.g. server FQDN or YOUR name) []:your_domain.com
Email Address []:admin@your_domain.com