[Linux] deepin与nginx

deepin#
Linux Deepin 是一个基于 DEB 包管理的一个独立操作系统,和那些 Ubuntu(下个大版本是基于debian开发) 的衍生版仅仅只是换主题、调整ISO预置的软件包不同。Linux Deepin 在大量吸纳 Debian/Ubuntu 仓库的软件包之外,构建了更大的 Deepin 软件仓库。Linux Deepin 的软件仓库不但包含 Debian/Ubuntu 的软件包,还包含了大量深度原创的软件以及第三方优质软件,采用apt-get/dpkg包管理方式。

deepin安装工具apt#
deepin的包管理器的搜索和安装分别是两个命令。搜索命令是 apt-cache search xxx ,安装命令是 apt-get install xxx

# 搜索软件
apt-cache search atool
# 安装软件
sudo apt-get install atool

centos中使用yum,unbantu使用

sudo apt-get install yum

deepin安裝Nginx#
安装

sudo apt install nginx

查看版本

nginx -v

打开浏览器访问localhost:80就可以看到welcome come to nginx了
nginx文件#
nginx.conf#


#运行用户,默认即是nginx,可以不进行设置
user  nginx;
#Nginx进程,一般设置为和CPU核数一样
worker_processes  1;   
#错误日志存放目录
error_log  /var/log/nginx/error.log warn;
#进程pid存放位置
pid        /var/run/nginx.pid;
events {
    worker_connections  1024; # 单个后台进程的最大并发数
}
http {
    include       /etc/nginx/mime.types;   #文件扩展名与类型映射表
    default_type  application/octet-stream;  #默认文件类型
    #设置日志模式
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;   #nginx访问日志存放位置
    sendfile        on;   #开启高效传输模式
    #tcp_nopush     on;    #减少网络报文段的数量
    keepalive_timeout  65;  #保持连接的时间,也叫超时时间
    #gzip  on;  #开启gzip压缩
    include /etc/nginx/conf.d/*.conf; #包含的子配置项位置和文件

default.conf#

server {
    listen       80;   #配置监听端口
    server_name  localhost;  //配置域名
    #charset koi8-r;     
    #access_log  /var/log/nginx/host.access.log  main;
    location / {
        root   /usr/share/nginx/html;     #服务默认启动目录
        index  index.html index.htm;    #默认访问文件
    }
    #error_page  404              /404.html;   # 配置404页面
    # 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/html;
    }
    # 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$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

nginx操作#
启动Nginx#

systemctl start nginx.service

查询Nginx服务的运行状况#

ps aux | grep nginx

停止Nginx服务的四种方法#
立即停止服务

nginx -s stop

这种方法比较强硬,无论进程是否在工作,都直接停止进程。

从容停止服务

nginx -s quit

这种方法较stop相比就比较温和一些了,需要进程完成当前工作后再停止。

杀死进程

killall nginx

这种方法也是比较野蛮的,我们直接杀死进程,但是在上面使用没有效果时,我们用这种方法还是比较好的。

systemctl stop nginx.service

systemctl 停止

重启Nginx服务#

systemctl restart nginx.service

重新载入Nginx配置文件#
在重新编写或者修改Nginx的配置文件后,都需要作一下重新载入,这时候可以用Nginx给的命令。

nginx -s reload

查看端口号#
Nginx启动后会监听80端口,从而提供HTTP访问。如果80端口已经被占用则会启动失败。我么可以使用netstat -tlnp命令查看端口号的占用情况

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值