欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

centos7安裝nginx的兩種方法介紹

 更新時間:2017年03月09日 14:08:03   作者:沒有傘的孩子  
本篇文章主要介紹了centos7安裝nginx的兩種方法介紹,主要是通過兩種方式進行安裝,有興趣的可以了解一下。

centos7安裝nginx

第一種方式:通過yum安裝

直接通過 yum install nginx 肯定是不行的,因為yum沒有nginx,所以首先把 nginx 的源加入 yum 中。

運行下面的命令:

1.將nginx放到y(tǒng)um repro庫中

復制代碼 代碼如下:

2.查看nginx信息

[root@localhost ~]# yum info nginx

3.使用yum安裝ngnix

[root@localhost ~]# yum install nginx

效果如下:

[root@localhost ~]# yum install nginx

已加載插件:fastestmirror, langpacks

Loading mirror speeds from cached hostfile

 * base: mirrors.usc.edu

 * extras: mirror.raystedman.net

 * updates: mirror.metrocast.net

正在解決依賴關系

--> 正在檢查事務

---> 軟件包 nginx.x86_64.1.1.10.1-1.el7.ngx 將被 安裝
      ······
      ······

正在安裝    : 1:nginx-1.10.1-1.el7.ngx.x86_64       

Thanks for using nginx!
Please find the official documentation for nginx here:

* http://nginx.org/en/docs/

Commercial subscriptions for nginx are available on:

* http://nginx.com/products/

----------------------------------------------------------------------

  驗證中      : 1:nginx-1.10.1-1.el7.ngx.x86_64                                                                                 1/1

已安裝:

nginx.x86_64 1:1.10.1-1.el7.ngx                                                                                    

完畢!

4.啟動nginx

[root@localhost ~]# service nginx start

5.查看nginx版本

[root@localhost ~]# nginx -v

6.訪問nginx,現(xiàn)在你可以通過公網(wǎng)ip (本地可以通過 localhost /或 127.0.0.1 ) 查看nginx 服務返回的信息。

[root@localhost ~]# curl -i localhost

效果如下:

      ······
Welcome to nginx!。
      ······

7.nginx配置文件位置在/etc/nginx/

[root@localhost /]# ll /etc/nginx/
總用量 32
drwxr-xr-x. 2 root root  25 10月 12 13:11 conf.d
-rw-r--r--. 1 root root 1007 5月 31 22:09 fastcgi_params
-rw-r--r--. 1 root root 2837 5月 31 22:09 koi-utf
-rw-r--r--. 1 root root 2223 5月 31 22:09 koi-win
-rw-r--r--. 1 root root 3957 5月 31 22:09 mime.types
lrwxrwxrwx. 1 root root  29 10月 12 13:11 modules -> ../../usr/lib64/nginx/modules
-rw-r--r--. 1 root root 643 5月 31 22:08 nginx.conf
-rw-r--r--. 1 root root 636 5月 31 22:09 scgi_params
-rw-r--r--. 1 root root 664 5月 31 22:09 uwsgi_params
-rw-r--r--. 1 root root 3610 5月 31 22:09 win-utf

8.實踐:

目的:修改服務名,接著從外部訪問這個服務

操作:

a.修改nginx配置文件

[root@localhost nginx]# vim /etc/nginx/conf.d/default.conf

修改server_name部分:server_name  yytest.com;

b.重載服務

[root@localhost nginx]# /usr/sbin/nginx -s reload 

c.從外部訪問nginx服務(192.168.10.11)

如在客戶機(192.168.10.10)的瀏覽器訪問:http://yytest.com

d.你發(fā)現(xiàn)訪問不了,原因1,你沒有在hosts文件做映射;原因2,及時你在hosts文件中了映射,由于nginx服務器的80端口堵塞或防火墻沒關

e.解決辦法:

步驟一:修改客戶機(192.168.10.10)的hosts文件,使用SwitchHosts工具添加 192.168.10.11     yytest.com

步驟二:關閉防火墻,具體下文有說明

9.nginx常用操作

啟動:

復制代碼 代碼如下:

$ /usr/sbin/nginx或任意路徑下運行service nginx start(centos7是systemctl start nginx.service )

重啟:

$ /usr/sbin/nginx –s reload

停止:

$ /usr/sbin/nginx –s stop

測試配置文件是否正常:

$ /usr/sbin/nginx –t

可能遇到的問題:

具體情況如下  1。本機能ping通虛擬機  2。虛擬機也能ping通本機  3。虛擬機能訪問自己的web  4。本機無法訪問虛擬己的web  這個問題的原因是服務器的80端口沒有打開或防火墻沒有關閉
解決辦法

如果是centos6:

解決方法如下:

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 

然后保存:

/etc/rc.d/init.d/iptables save 

重啟防火墻

/etc/init.d/iptables restart 

CentOS防火墻的關閉,關閉其服務即可:

查看CentOS防火墻信息:/etc/init.d/iptables status

關閉CentOS防火墻服務:/etc/init.d/iptables stop

永久關閉防火墻: chkconfig –level 35 iptables off

如果是centos7

[root@rhel7 ~]# systemctl status firewalld.service

[root@rhel7 ~]# systemctl stop firewalld.service

[root@rhel7 ~]# systemctl disable firewalld.service

[root@rhel7 ~]# systemctl status firewalld.service

擴展知識:

啟動一個服務:systemctl start firewalld.service

關閉一個服務:systemctl stop firewalld.service

重啟一個服務:systemctl restart firewalld.service

顯示一個服務的狀態(tài):systemctl status firewalld.service

在開機時啟用一個服務:systemctl enable firewalld.service

在開機時禁用一個服務:systemctl disable firewalld.service

查看服務是否開機啟動:systemctl is-enabled firewalld.service;echo $?

查看已啟動的服務列表:systemctl list-unit-files|grep enabled

第二種方式:通過手動下載安裝包解壓安裝

1.下載nginx包。

[root@localhost ~]# wget http://nginx.org/download/nginx-1.10.1.tar.gz

2.復制包到你的安裝目錄

[root@localhost ~]# cp nginx-1.10.1.tar.gz /usr/local/

3.解壓

[root@localhost ~]# tar -zxvf nginx-1.10.1.tar.gz
[root@localhost ~]# cd nginx-1.10.1

4.啟動nginx

[root@localhost ~]# /usr/local/nginx/sbin/nginx

5.查看版本s

[root@localhost ~]# nginx -v

6.url訪問nginx localhost或127.0.0.1

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • Apache控制是否顯示站點目錄(推薦)

    Apache控制是否顯示站點目錄(推薦)

    這篇文章主要介紹了Apache控制是否顯示站點目錄(推薦)的相關資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-11-11
  • Centos7.2安裝Nginx實現(xiàn)負載平衡的方法

    Centos7.2安裝Nginx實現(xiàn)負載平衡的方法

    這篇文章主要介紹了Centos7.2安裝Nginx實現(xiàn)負載平衡的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-01-01
  • linux利用read命令獲取變量中的值

    linux利用read命令獲取變量中的值

    對于寫bash腳本的朋友,read命令是不可或缺的,需要實踐一下就可以了解,下面這篇文章主要給大家介紹了關于linux如何利用read命令來獲取變量中值的相關資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-08-08
  • Linux服務器上安裝Python3的兩種方式

    Linux服務器上安裝Python3的兩種方式

    這篇文章主要介紹了Linux服務器上安裝Python3,本文通過兩種方式給大家詳解,需要的朋友可以參考下
    2019-11-11
  • HP服務器用戶安裝REDHAT 5.5手冊在線圖文教程

    HP服務器用戶安裝REDHAT 5.5手冊在線圖文教程

    這篇文章主要介紹了hp服務器下安裝REDHAT 5.5的全過程,如果是centos也是可以差不多的界面,需要的朋友可以參考下
    2013-08-08
  • linux?服務器安裝gcc8的問題記錄

    linux?服務器安裝gcc8的問題記錄

    我原本安裝了gcc13.0版本,但是版本太高了,導致我安裝cuda報錯gcc版本太高,所以就安裝低版本的gcc,下面通過本文給大家分享linux?服務器安裝gcc8的問題記錄,感興趣的朋友一起看看吧
    2024-07-07
  • Linux與Windows文件互傳(VMWare)

    Linux與Windows文件互傳(VMWare)

    這篇文章主要介紹了Linux與Windows文件互傳的相關資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • Linux下的fdisk命令用法詳解

    Linux下的fdisk命令用法詳解

    這篇文章主要介紹了Linux下的fdisk用法,大家都知道fdisk功能真的很強大,用它可以劃分出最復雜的分區(qū),本文重點給大家介紹Linux下的fdisk命令用法,感興趣的朋友一起看看吧
    2018-05-05
  • Linux中grep和egrep命令詳解

    Linux中grep和egrep命令詳解

    在本篇文章里小編給大家整理的是關于Linux之grep和egrep命令總結內容,有需要的朋友們參考學習下。
    2019-10-10
  • 解決阿里云ssh遠程連接短時間就會斷掉的問題

    解決阿里云ssh遠程連接短時間就會斷掉的問題

    這篇文章主要介紹了阿里云ssh遠程連接短時間就會斷掉的解決方案,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-07-07

最新評論