nginx 단순 사이트 배치(centos 7)

1889 단어 project
[root@client1 ~]# cd /etc/yum.repos.d/

[root@client1 yum.repos.d]# vim nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

[root@client1 yum.repos.d]# yum -y install nginx

[root@client1 yum.repos.d]# cd /etc/nginx/conf.d/

[root@client1 conf.d]# vim a.org.conf
	server {
	server_name www.a.org  a.org;
	error_log  /usr/local/nginx/logs/a.org/error.org error; 
	access_log  /usr/local/nginx/logs/a.org/access.log main;
location / {
	root /a.org;
	index index.html;
}
}

[root@client1 ~]# mkdir -p /usr/local/nginx/logs/a.org

[root@client1 ~]# mkdir -p /a.org

[root@client1 ~]# echo welcome to nginx > /a.org/index.html

[root@client1 ~]# cd /etc/nginx/conf.d/

[root@client1 conf.d]# nginx -t 
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

[root@client1 conf.d]# systemctl start nginx

[root@client1 ~]# ss -antp |grep 80
LISTEN     0      128          *:80                       *:*                   users:(("nginx",pid=1244,fd=8),("nginx",pid=1243,fd=8))

[root@client1 conf.d]# curl 192.168.122.137
welcome to nginx

[root@client1 conf.d]# curl www.a.org

301 Moved Permanently

301 Moved Permanently


nginx
[root@client1 conf.d]# cp a.org.conf b.org.conf [root@client1 conf.d]# vim b.org.conf server { server_name www.b.org b.org; error_log /usr/local/nginx/logs/b.org/error.org error; access_log /usr/local/nginx/logs/b.org/access.log main; location / { root /b.org; index index.html; } } [root@client1 conf.d]# mkdir /b.org [root@client1 conf.d]# mkdir /usr/local/nginx/logs/b.org [root@client1 conf.d]# vim /b.org/index.html [root@client1 conf.d]# systemctl stop nginx [root@client1 conf.d]# systemctl start nginx

좋은 웹페이지 즐겨찾기