CentOS 6.5 配置YUM安裝Nginx

1、在/etc/yum.repos.d/目錄下創建一個源配置文件nginx.repo:

cd /etc/yum.repos.d/
vim nginx.repo

2、填寫如下內容:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

3、保存退出

4、下面直接執行如下指令即可自動安裝好Nginx:

yum install nginx -y

5、安裝完成,下面直接就可以啓動Nginx了:

/etc/init.d/nginx start

現在Nginx已經啓動了,直接訪問服務器就能看到Nginx歡迎頁面了
在這裏插入圖片描述
6、Nginx的命令以及配置文件位置:

/etc/init.d/nginx start # 啓動Nginx服務
/etc/init.d/nginx stop # 停止Nginx服務
/etc/nginx/nginx.conf # Nginx配置文件位置

至此,Nginx已經全部配置安裝完成。

7、Nginx服務器中的default.conf的配置文件設置,正常情況,nginx.conf 一般設置分流請求的時候纔會配置對應的信息

user nginx;
worker_processes  1;

error_log /var/log/nginx/error.log warn;
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;

 sendfile on;
    #tcp_nopush     on;

keepalive_timeout 65;

#gzip on;

 include /etc/nginx/conf.d/*.conf;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章