Created
November 12, 2015 12:48
-
-
Save seka/d66f926236d481ea64d5 to your computer and use it in GitHub Desktop.
setup script of nginx.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install | |
sudo touch /etc/yum.repos.d/nginx.repo | |
sudo sh -c "cat << 'EOF' > /etc/yum.repos.d/nginx.repo | |
[nginx] | |
name=nginx repo | |
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ | |
gpgcheck=0 | |
enabled=1 | |
EOF" | |
sudo yum update -y | |
sudo yum install nginx -y | |
sudo service nginx start | |
sudo chkconfig nginx on | |
# create working directory | |
sudo mkdir -p /data/www /data/images | |
sudo chmod 755 /data/ | |
# nginx config | |
sudo sh -c "cat << 'EOF' > /etc/nginx/nginx.conf | |
user nginx; | |
worker_processes auto; | |
error_log /var/log/nginx/error.log; | |
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; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
gzip on; | |
include /etc/nginx/conf.d/*.conf; | |
server { | |
listen 80; | |
server_name sekaseka; | |
access_log /var/log/nginx/host.access.log main; | |
location / { | |
root /data/www; | |
} | |
location /images/ { | |
root /data/images; | |
} | |
error_page 404 /404.html; | |
location = /40x.html { | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
} | |
} | |
} | |
EOF" | |
# restart | |
sudo service nginx restart | |
# test | |
touch /data/www/index.html | |
sudo sh -c "cat << 'EOF' > /data/www/index.html | |
<html> | |
<head> | |
<title>test.html</title> | |
</head> | |
<body> | |
<h1>test</h1> | |
</body> | |
</html> | |
EOF" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment