2013年1月11日金曜日

An installation of a nginx on Arch Linux , Raspberry Pi

I installed a nginx web server on Arch Linux, Raspberry PI.

(1) Installation
[root@rcmp-sv01 ~]# pacman -S nginx
resolving dependencies...
looking for inter-conflicts...
Targets (3): geoip-1.4.8-2  geoip-database-20121207-1  nginx-1.2.6-1
Total Download Size:    1.11 MiB
Total Installed Size:   3.80 MiB
Proceed with installation? [Y/n] y
:: Retrieving packages from extra...
 geoip-database-2012...   715.0 KiB  13.4K/s 00:54 [######################] 100%
 geoip-1.4.8-2-armv6h     115.5 KiB  2.42K/s 00:48 [######################] 100%
:: Retrieving packages from community...
 nginx-1.2.6-1-armv6h     309.0 KiB  9.40K/s 00:33 [######################] 100%
(3/3) checking package integrity                   [######################] 100%
(3/3) loading package files                        [######################] 100%
(3/3) checking for file conflicts                  [######################] 100%
(3/3) checking available disk space                [######################] 100%
(1/3) installing geoip-database                    [######################] 100%
(2/3) installing geoip                             [######################] 100%
(3/3) installing nginx                             [######################] 100%

(2) Create a unit file of nginx
[root@rcmp-sv01 ~]# vi /etc/systemd/system/nginx.service
[root@rcmp-sv01 ~]# cat /etc/systemd/system/nginx.service
[[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

(3) RUN
[root@rcmp-sv01 ~]# systemctl enable /etc/systemd/system/nginx.service
ln -s '/etc/systemd/system/nginx.service' '/etc/systemd/system/multi-user.target.wants/nginx.service'
[root@rcmp-sv01 ~]# systemctl start /etc/systemd/system/nginx.service

(4) configuration
[root@rcmp-sv01 ~]# cat /etc/nginx/nginx.conf
#user html;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       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  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
}

peace!

0 件のコメント:

コメントを投稿