发布于 

Nginx安装与配置

Nginx安装

1
apt-get install nginx

开启服务自启动

1
systemctl enable nginx

查看服务状态

1
2
systemctl status nginx
ps -ef | grep nginx

重载配置

1
systemctl reload nginx

Nginx的默认配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
‘–conf-path=/etc/nginx/nginx.conf’, #配置文件路径,默认是conf/nginx
‘–error-log-path=/var/log/nginx/error.log’, #错误日志路径,默认是/logs/error.log
‘–http-client-body-temp-path=/var/lib/nginx/body’, #指定http客户端请求缓存文件存放目录的路径
‘–http-fastcgi-temp-path=/var/lib/nginx/fastcgi’, #指定http FastCGI缓存文件存放目录的路径
‘–http-log-path=/var/log/nginx/access.log’, #指定http默认访问日志的路径
‘–http-proxy-temp-path=/var/lib/nginx/proxy’, #指定http反向代理缓存文件存放目录
‘–http-scgi-temp-path=/var/lib/nginx/scgi’, #指定http sigi缓存文件存放目录的路径
‘–http-uwsgi-temp-path=/var/lib/nginx/uwsgi’, #指定http uwsgi缓存文件存放目录的路径
‘–lock-path=/var/lock/nginx.lock’, # 指定nginx.lock文件的路径
‘–pid-path=/var/run/nginx.pid’, # 指定nginx.pid文件的路径,默认是/logs/nginx.pid
‘–with-debug’, #启用调试日志
‘–with-http_addition_module’, #启用http_addition_module
‘–with-http_dav_module’, #启用http_dav_module
‘–with-http_geoip_module’,
‘–with-http_gzip_static_module’,
‘–with-http_image_filter_module’,
‘–with-http_realip_module’,
‘–with-http_stub_status_module’,
‘–with-http_ssl_module’,
‘–with-http_sub_module’,
‘–with-http_xslt_module’,
‘–with-ipv6’,
‘–with-sha1=/usr/include/openssl’,
‘–with-md5=/usr/include/openssl’,
‘–with-mail’,
‘–with-mail_ssl_module’,
‘–add-module=/build/buildd/nginx-0.8.54/debian/modules/nginx-upstream-fair’

安装完成后Nginx所使用的目录如下
/usr/sbin/nginx
/usr/share/nginx
/usr/share/doc/nginx
/etc/nginx
/etc/init.d/nginx
/etc/default/nginx
/etc/logrotate.d/nginx
/etc/ufw/applications.d/nginx
/var/lib/nginx
/var/lib/update-rc.d/nginx
/var/log/nginx

网站文件可以放就在 /usr/share/nginx/www下.具体情况需要查看响应的配置文件