ubunut11.0安装nginx基本目录结构介绍和配置使用方法
2011-11-29 12:38
1316 查看
安装,注意是nginx不是ngnix。否则会安装失败。
nginx的目录存放位置:
配置文件目录 /etc/nginx
网站资源文件存放位置/usr/share/nginx
nginx修改端口
默认的是80,修改成7888
ubuntu的配置文件分成三部分:
/etc/nginx根目录存放公共的配置
在sites_available和sites_enabled配置站点相关的信息例如域名端口等等。所以修改默认的sites_available/default文件如下
这样默认的端口就修改成7888了
nginx的服务器启动,重启,停止
查看端口情况
root@coder-671T-M:/soft_my# apt-get install nginx 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 将会安装下列额外的软件包: nginx-common nginx-full 下列【新】软件包将被安装: nginx nginx-common nginx-full 升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 184 个软件包未被升级。 需要下载 379 kB 的软件包。 解压缩后会消耗掉 1,180 kB 的额外空间。 您希望继续执行吗?[Y/n]Y 获取:1 http://cn.archive.ubuntu.com/ubuntu/ oneiric/universe nginx-common all 1.0.5-1 [14.6 kB] 获取:2 http://cn.archive.ubuntu.com/ubuntu/ oneiric/universe nginx-full i386 1.0.5-1 [359 kB] 获取:3 http://cn.archive.ubuntu.com/ubuntu/ oneiric/universe nginx all 1.0.5-1 [5,616 B] 下载 379 kB,耗时 6秒 (61.9 kB/s) 选中了曾被取消选择的软件包 nginx-common。 (正在读取数据库 ... 系统当前共安装有 244027 个文件和目录。) 正在解压缩 nginx-common (从 .../nginx-common_1.0.5-1_all.deb) ... 选中了曾被取消选择的软件包 nginx-full。 正在解压缩 nginx-full (从 .../nginx-full_1.0.5-1_i386.deb) ... 选中了曾被取消选择的软件包 nginx。 正在解压缩 nginx (从 .../archives/nginx_1.0.5-1_all.deb) ... 正在处理用于 ufw 的触发器... 正在处理用于 ureadahead 的触发器... ureadahead will be reprofiled on next reboot 正在处理用于 man-db 的触发器... 正在设置 nginx-common (1.0.5-1) ... 正在设置 nginx-full (1.0.5-1) ... 正在设置 nginx (1.0.5-1) ...
nginx的目录存放位置:
配置文件目录 /etc/nginx
网站资源文件存放位置/usr/share/nginx
root@coder-671T-M:~# cd /etc/nginx/ root@coder-671T-M:/etc/nginx# ll 总用量 64 drwxr-xr-x 5 root root 4096 2011-11-29 11:41 ./ drwxr-xr-x 172 root root 12288 2011-11-29 11:41 ../ drwxr-xr-x 2 root root 4096 2011-07-27 23:37 conf.d/ -rw-r--r-- 1 root root 867 2011-03-23 12:20 fastcgi_params -rw-r--r-- 1 root root 2258 2010-12-02 14:19 koi-utf -rw-r--r-- 1 root root 1805 2010-12-02 14:19 koi-win -rw-r--r-- 1 root root 2059 2011-02-22 15:49 mime.types -rw-r--r-- 1 root root 1340 2010-12-02 14:19 nginx.conf -rw-r--r-- 1 root root 131 2011-05-02 13:25 proxy_params -rw-r--r-- 1 root root 465 2010-12-02 14:19 scgi_params drwxr-xr-x 2 root root 4096 2011-11-29 11:41 sites-available/ drwxr-xr-x 2 root root 4096 2011-11-29 11:41 sites-enabled/ -rw-r--r-- 1 root root 497 2010-12-02 14:19 uwsgi_params -rw-r--r-- 1 root root 3071 2010-12-02 14:19 win-utf root@coder-671T-M:/etc/nginx# tree . ├── conf.d ├── fastcgi_params ├── koi-utf ├── koi-win ├── mime.types ├── nginx.conf ├── proxy_params ├── scgi_params ├── sites-available │ └── default ├── sites-enabled │ └── default -> /etc/nginx/sites-available/default ├── uwsgi_params └── win-utf 3 directories, 11 files
root@coder-671T-M:/usr/share/nginx# tree . └── www ├── 50x.html └── index.html 1 directory, 2 files root@coder-671T-M:/usr/share/nginx#
nginx修改端口
默认的是80,修改成7888
ubuntu的配置文件分成三部分:
/etc/nginx根目录存放公共的配置
在sites_available和sites_enabled配置站点相关的信息例如域名端口等等。所以修改默认的sites_available/default文件如下
# You may add here your # server { # ... # } # statements for each of your virtual hosts to this file ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { listen 7888; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /usr/share/nginx/www; index index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } location /images { root /usr/share; autoindex off; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # #error_page 500 502 503 504 /50x.html; #location = /50x.html { # root /usr/share/nginx/www; #} # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # root html; # index index.html index.htm; # # location / { # try_files $uri $uri/ /index.html; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # # root html; # index index.html index.htm; # # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # # ssl_session_timeout 5m; # # ssl_protocols SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP; # ssl_prefer_server_ciphers on; # # location / { # try_files $uri $uri/ /index.html; # } #}
这样默认的端口就修改成7888了
nginx的服务器启动,重启,停止
root@coder-671T-M:/etc/nginx/sites-available# /etc/init.d/nginx start Starting nginx: nginx. root@coder-671T-M:/etc/nginx/sites-available# /etc/init.d/nginx start Starting nginx: nginx. root@coder-671T-M:/etc/nginx/sites-available# /etc/init.d/nginx stop Stopping nginx: nginx. root@coder-671T-M:/etc/nginx/sites-available# /etc/init.d/nginx restart Restarting nginx: nginx.
查看端口情况
root@coder-671T-M:/etc/nginx/sites-available# lsof -i:7888 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 6029 root 6u IPv4 89046 0t0 TCP *:7888 (LISTEN) nginx 6030 www-data 6u IPv4 89046 0t0 TCP *:7888 (LISTEN) nginx 6031 www-data 6u IPv4 89046 0t0 TCP *:7888 (LISTEN) nginx 6032 www-data 6u IPv4 89046 0t0 TCP *:7888 (LISTEN) nginx 6033 www-data 6u IPv4 89046 0t0 TCP *:7888 (LISTEN) root@coder-671T-M:/etc/nginx/sites-available# netstat -anpl | grep 7888 tcp 0 0 0.0.0.0:7888 0.0.0.0:* LISTEN 6029/nginx root@coder-671T-M:/etc/nginx/sites-available#
相关文章推荐
- ubunut 安装nginx基本目录结构介绍和配置使用方法
- ubuntu11.10安装tomcat7以及基本的目录结构和使用方法
- Windows系统下Nginx服务器的基本安装和配置方法介绍
- Nutch1.9安装配置与基本使用介绍
- 全面介绍Github for Windows安装 配置使用方法
- Linux第一篇【介绍、安装Ubuntu、基本目录结构】
- Django 介绍、安装配置、基本使用、Django 用户注冊样例
- Ubuntu 12.04下安装vim, 简单配置与基本使用介绍
- 全面介绍Github for Windows安装 配置使用方法
- nginx的yum安装,基本参数使用,编译参数说明和Nginx基本配置,模块安装
- postgresql(V-9.1) debian7.x(wheezy)安装过程+配置详解+数据库的基本使用方法
- Nginx安装,目录结构与配置文件详解
- Django介绍、安装配置、基本使用、Django用户注册例子
- Docker安装及基本使用方法详细介绍
- Django介绍、安装配置、基本使用、Django用户注册例子
- 网站升级HTTPS,免费SSL证书Let’s Encrypt安装使用教程:Apache和Nginx配置方法
- nginx服务器的安装和配置的方法介绍
- Nutch1.9安装配置与基本使用介绍