1、簡介nginx
Nginx("engine x")是一款是由俄羅斯的程序設計師Igor Sysoev所開發高性能的 Web和 反向代理 服務器,也是一個 IMAP/POP3/SMTP 代理服務器。c++
2、安裝ubuntu
一、安裝編譯Nginx的依賴包centos
yum -y install gcc gcc-c++ autoconf automake libtool make openssl openssl-devel pcre pcre-devel
# ubuntu18使用
apt install -y build-essential libtool libpcre3 libpcre3-dev install zlib1g-dev openssl
二、下載Nginx瀏覽器
# 切換到下載目錄 cd /usr/local/src/ # 下載nginx安裝包 wget http://nginx.org/download/nginx-1.8.1.tar.gz
三、若是提示沒有wget命令,可使用yum安裝服務器
yum -y install wget
四、解壓,切換到解壓目錄性能
sudo tar -zxvf nginx-1.6.3.tar.gz
cd nginx-1.6.3
五、執行編譯命令(可按照須要編譯指定模塊),經過prefix把編譯後的nginx生成到/usr/local/nginx目錄下 (也能夠只安裝默認模塊: ./configure --prefix=/usr/local/nginx)測試
./configure \ --prefix=/usr/local/nginx \--with-http_ssl_module \ --with-http_flv_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \--with-pcre
六、安裝ui
make && make install
七、測試,啓動過程當中,若是提示文件目錄不存在,新建對應的目錄便可spa
# 進入生成目錄 cd /usr/local/nginx # 測試 /usr/local/nginx/sbin/nginx -t
# 查看編譯模塊信息
/usr/local/nginx/sbin/nginx -V # 啓動 /usr/local/nginx/sbin/nginx # 從新載入配置文件 /usr/local/nginx/sbin/nginx -s reload # 重啓 /usr/local/nginx/sbin/nginx -s reopen # 中止 /usr/local/nginx/sbin/nginx -s stop
八、打開瀏覽器訪問ip地址,便可,我的安裝的centos min版,查看ip地址信息
ip add
九、若是測試沒有問題,但別的計算機訪問不了,關閉防火牆,centos關閉防火牆
# centos從7開始默認用的是firewalld ,關閉防火牆 sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service
十、若是想將防火牆換成iptables,能夠安裝啓動
sudo yum -y install iptables-services sudo systemctl enable iptables && sudo systemctl enable ip6tables sudo systemctl start iptables && sudo systemctl start ip6tables
yexiangyang
moyyexy@gmail.com