[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命令查看端口號的占用情況

Docs

deepin-linux常用命令大全----每天一個linux命令
一個前端必會的 Nginx免費教程


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM