[原创]# 玩转nginx系列
首先先上如何彻底删除nginx
看到这个标题的小伙伴都惊呆了,还不知道怎么搞,却叫我怎么卸载。为什么我要这样,其实,Reset也是一种解决问题的方式嘛。
首先执行下卸载命令
sudo apt-get --purge remove nginx
sudo apt-get autoremove
dpkg --get-selections | grep nginx
sudo apt-get --purge remove nginx-common
这样呢,就卸载了nginx包括配置文件了
在看看进程,执行
root@localhost:~# ps -ef | grep nginx
root 3729 1 0 04:40 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 3731 3729 0 04:40 ? 00:00:00 nginx: worker process
root 4090 4041 0 05:40 pts/0 00:00:00 grep --color=auto nginx
干掉进程:
sudo kill nginx
查看残余文件
sudo find / -name nginx*
root@localhost:~# sudo find / -name nginx*
/sys/fs/cgroup/systemd/system.slice/nginx.service
/usr/sbin/nginx
/usr/share/doc/nginx-core
/usr/share/doc/nginx-common
/usr/share/doc/nginx
/usr/share/nginx
/usr/share/vim/addons/indent/nginx.vim
/usr/share/vim/addons/syntax/nginx.vim
手动删除文件
sudo rm -r /usr/.....
好了,现在干净了
安装 nginx
sudo apt-get install nginx
查看 nginx 版本
nginx -v #查看详细 nginx -V
启动nginx
sudo /etc/init.d/nginx start
接下来访问:http://localhost 就可以看到nginx的欢迎页面了
Nginx 配置
nginx配置文件位置是 /etc/nginx/nginx.conf默认是下面这样的:
root@localhost:~# vi /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
重点是这个 include /etc/nginx/conf.d/.conf;include /etc/nginx/sites-enabled/;
这样呢,就可以在conf.d文件夹下建立我们自己的配置了,下面是个栗子!
root@localhost:~# cd /etc/nginx/conf.d/
root@localhost:/etc/nginx/conf.d# ls
blog.voidoop.com.conf www.voidoop.com.conf
我这里配置了两个域名的转发规则,以首页www.voidoop.com为例:
server
{
listen 80;
server_name www.voidoop.com;
location /
{
proxy_set_header Host $http_host;
proxy_set_header X-Forward-For $remote_addr;
proxy_pass http://www.voidoop.com:3000;
}
location ~ .*\.(gif|jpg|js|css|html)$
{
root /var/www/hello/public/;
expires 30d;
}
}
因为 express的默认端口是3000,所以,不想去改变他,就用nginx转发。
修改配置之后,重启nginx
/etc/init.d/nginx restart
最后叨叨location的匹配规则
(1)= 前缀的指令严格匹配这个查询。如果找到,停止搜索。
(2)剩下的常规字符串,最长的匹配优先使用。如果这个匹配使用 ^~ 前缀,搜索停止。
(3)正则表达式,按配置文件里的顺序,第一个匹配的被使用。
(4)如果第三步产生匹配,则使用这个结果。否则使用第二步的匹配结果。
在location中可以使用常规字符串和正则表达式。
如果使用正则表达式,你必须使用以下规则:
(1)~* 前缀选择不区分大小写的匹配
(2)~ 选择区分大小写的匹配
一切不注明转载源都是耍流氓: http://zhutty.cnblogs.com
[原创]# 玩转nginx系列的更多相关文章
- [Linux] PHP程序员玩转Linux系列-nginx初学者引导
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...
- [Linux] PHP程序员玩转Linux系列-Linux和Windows安装nginx
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...
- [Linux] PHP程序员玩转Linux系列-Nginx中的HTTPS
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...
- [Linux] PHP程序员玩转Linux系列-lnmp环境的搭建
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 在平常的工作中,我作为PHP程序员经常要搭建一下环境,这个环境就是Linux系统下安装nginx,php,mysql这三个软件,对软件进行 ...
- [Linux] PHP程序员玩转Linux系列-使用supervisor实现守护进程
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...
- [Linux] PHP程序员玩转Linux系列-telnet轻松使用邮箱
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...
- [Linux] PHP程序员玩转Linux系列-升级PHP到PHP7
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...
- [Linux] PHP程序员玩转Linux系列-腾讯云硬盘扩容挂载
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...
- [Linux] PHP程序员玩转Linux系列-Ubuntu配置SVN服务器并搭配域名
在线上部署网站的时候,大部分人是使用ftp,这样的方式很不方便,现在我要在线上安装上SVN的服务器,直接使用svn部署网站.因为搜盘子的服务器是ubuntu,因此下面的步骤是基于ubuntu的. 安装 ...
随机推荐
- java09数组的使用
/** * 数组:存储相同数据类型的一组数据! * 声明一个数组就是在内存中开辟了一连串的连续空间! * * 数组和String 都是 引用数据类型 * 数组的使用 */ @Test public v ...
- css的clip裁剪
clip 属性是用来设置元素的形状.用来剪裁绝对定位元素(absolute or fixed). clip有三种取值:auto |inherit|rect.inherit是继承,ie不支持这个属性, ...
- css控制背景图片在浏览器中居中,下拉浏览器的时候背景图一直不变
如 http://www.gm.com/ css样式如下 ;;} #con{ position:absolute; ; ; height:100%; width:100%; background-im ...
- zookeeper笔记
zookeeper用于分布式配置管理,读写锁等等..后续补充.
- [php基础]Mysql日期函数:日期时间格式转换函数详解
在PHP网站开发中,Mysql数据库设计中日期时间字段必不可少,由于Mysql日期函数输出的日期格式与PHP日期函数之间的日期格式兼容性不够,这就需要根据网站实际情况使用Mysql或PHP日期转换函数 ...
- 还是把一个课程设计作为第一篇文章吧——学生学籍管理系统(C语言)
#include <stdio.h> #include<stdlib.h> #include<string.h> typedef struct student { ...
- 关于oracle dbms_job 定时执行的内容。
一.设置初始化参数 job_queue_processessql> alter system set job_queue_processes=n;(n>0)job_queue_proces ...
- JS时间的计算,当前日期加一天或者几天的计算
//alert();//debugger;var newriqi="";var jjd=defaultForm.getCellById(sjyxjid).getText();var ...
- Windows7电脑上不去网,ipconfig查询时默认网关会出现0.0.0.0问题的解决
用ipconfig查看网络配置,发现其他都正确,唯独默认网关上多了一条0.0.0.0的记录,.禁用网络连接再启用也不能恢复.网上找了一下有说改注册表的,打开注册表找到 HKEY_LOCAL_MACHI ...
- iOS 网络与多线程--7.Performselector消息处理方法
创建一个IOSApp类 IOSApp.h文件 #import <Foundation/Foundation.h> @interface IOSApp : NSObject // 1.添加一 ...