Skip to content

Instantly share code, notes, and snippets.

Created Nov 12, 2015
What would you like to do?
setup script of nginx.
# Install
sudo touch /etc/yum.repos.d/nginx.repo
sudo sh -c "cat << 'EOF' > /etc/yum.repos.d/nginx.repo
name=nginx repo
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/;
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 {
# restart
sudo service nginx restart
# test
touch /data/www/index.html
sudo sh -c "cat << 'EOF' > /data/www/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment