卸載
# 刪除除了配置文件以外的所有文件。
sudo apt-get remove nginx nginx-common
# 刪除所有與nginx有關(guān)的東西,包括配置文件。
sudo apt-get purge nginx nginx-common
# 在上面命令結(jié)束后執(zhí)行,主要是刪除與Nginx有關(guān)的且不再被使用的依賴包。
sudo apt-get autoremove
# 刪除兩個(gè)主要的包。
sudo apt-get remove nginx-full nginx-common
下載
nginx官網(wǎng):http://nginx.org/en/download.html
選擇穩(wěn)定的nginx版本下載。
安裝
# 安裝依賴
sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev gcc
# 配置
sudo ./configure
#編譯
sudo make
#安裝
sudo make instal
常用命令
# 啟動nginx的命令為:
/usr/local/nginx/sbin/nginx
停止nginx的命令為 :
# /usr/local/nginx/sbin/nginx -s stop
重啟nginx的命令為:
# /usr/local/nginx/sbin/nginx -s reload
配置文件服務(wù)器
# 1. 新建共享目錄
mkdir -p /home/${user}/nginx/data
# 2.修改配置文件
sudo vim /usr/local/nginx/conf/nginx.conf
# 3,配置
http {
...
#顯示目錄
autoindex on;
# 顯示文件大小
autoindex_exact_size on;
# 顯示文件時(shí)間
autoindex_localtime on;
# 防止中文亂碼
charset utf-8;
server {
listen 81;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /download{
alias /home/majin/share;
allow all;
autoindex on;
}
}