關于Nginx一款高性能,輕量級web服務軟件
穩定性高
單臺物理服務器可支持30000~50000個并發請求
系統資源消耗低
對HTTP并發連接的處理能力高
環境
一臺Linux服務器(192.168.13.128) 一臺win10測試機一,在Windows上將LAMP所需壓縮軟件包共享出來(此處如有問題請看之前的博客相關文章)
二,在Linux上使用遠程共享獲取文件并掛載到mnt目錄下
[root@localhost ~]# smbclient -L //192.168.100.3/ ##遠程共享訪問Enter SAMBA/root's password: Sharename Type Comment --------- ---- ------- LAMP-C7 Disk [root@localhost ~]# mount.cifs //192.168.100.3/LAMP-C7 /mnt ##掛載到/mnt目錄下
三,編譯安裝Nginx
1,解壓源碼包到/opt下,并查看
[root@localhost ~]# cd /mnt ##切換到掛載點目錄[root@localhost mnt]# lsapr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip LAMP-php5.6.txtapr-util-1.6.0.tar.gz error.png mysql-5.6.26.tar.gzawstats-7.6.tar.gz httpd-2.4.29.tar.bz2 nginx-1.12.0.tar.gzcronolog-1.6.2-14.el7.x86_64.rpm kali.jpg php-5.6.11.tar.bz2[root@localhost mnt]# tar zxvf nginx-1.12.0.tar.gz -C /opt ##解壓Nginx源碼包到/opt下[root@localhost mnt]# cd /opt/ ##切換到解壓的目錄下[root@localhost opt]# lsnginx-1.12.0 rh
2,安裝編譯需要的環境組件包
[root@localhost opt]# yum -y install /gcc / //c語言gcc-c++ / //c++語言pcre-devel / //pcre語言工具zlib-devel //數據壓縮用的函式庫
3,創建程序用戶nginx并編譯Nginx
[root@localhost opt]# useradd -M -s /sbin/nologin nginx ##創建程序用戶,安全不可登陸狀態[root@localhost opt]# id nginxuid=1001(nginx) gid=1001(nginx) 組=1001(nginx)[root@localhost opt]# cd nginx-1.12.0/ ##切換到nginx目錄下[root@localhost nginx-1.12.0]# ./configure / ##配置nginx> --prefix=/usr/local/nginx / ##安裝路徑> --user=nginx / ##用戶名> --group=nginx / ##用戶組> --with-http_stub_status_module ##狀態統計模塊
4,編譯和安裝
[root@localhost nginx-1.12.0]# make ##編譯...[root@localhost nginx-1.12.0]# make install ##安裝...
5,優化nginx啟動腳本,以便于系統識別
[root@localhost nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ##創建軟連接讓系統識別nginx啟動腳本[root@localhost nginx]# nginx -t ##檢查配置文件的語法問題nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[root@localhost nginx]# nginx ##開啟ngnix[root@localhost nginx]# netstat -ntap | grep 80 ##查看端口,nginx已經開啟tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 39620/nginx: master [root@localhost nginx]# systemctl stop firewalld.service ##關閉防火墻[root@localhost nginx]# setenforce 0
6,安裝elinks網頁測試工具,并進行測試
[root@localhost nginx]# yum install elinks -y ##安裝elinks軟件[root@localhost nginx]# elinks http://localhost ##測試nginx網頁
新聞熱點
疑難解答