1.Edit repo and install nginx1.9+ by yum
yum -y install nginx
2.vi /etc/nginx/nginx.conf
user root;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
server {
client_max_body_size 4G;
listen 80;
server_name localhost;
root /data/www; #file path
location / {
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}
}
}
3.start or stop nginx service
nginx -s stop
nginx -c /etc/nginx/nginx.conf
You can input nginx server's ip on broswer to look your nginx file system.
4.You can also deploy nginx by docker
a.First step you should download docker image:
docker pull nginx:1.9
b.And then,you should start a docker container by image nginx:1.9
docker run -d -p 12322:80 -v /data/www:/data/www/ --name nginxfile nginx:1.9
c.edit nginx configuration file like step 2 and restart container
You can input nginx container's ip:12322 on broswer to look your nginx file system.