FreeBSD に nginx をインストールする
メモリが少なく、一般に公開するサーバーではないので、Apache ではなく nginx をインストールしてみる。
nginx をインストールする
% whereis nginx nginx: /usr/ports/www/nginx % cd /usr/ports/www/nginx % sudo make install clean ===> SECURITY REPORT: This port has installed the following files which may act as network servers and may therefore pose a remote security risk to the system. /usr/local/sbin/nginx This port has installed the following startup scripts which may cause these network services to be started at boot time. /usr/local/etc/rc.d/nginx If there are vulnerabilities in these programs there may be a security risk to the system. FreeBSD makes no guarantee about the security of ports included in the Ports Collection. Please type 'make deinstall' to deinstall the port if this is a concern. For more information, and contact details about the security status of this software, see the following webpage: http://sysoev.ru/nginx/ ===> Cleaning for nginx-0.8.5 % ls -l /usr/local/sbin/nginx -r-xr-xr-x 1 root wheel 487536 Nov 8 16:06 /usr/local/sbin/nginx
nginx を起動する。
すぐに nginx を起動できる。
% sudo /usr/local/etc/rc.d/nginx start Cannot 'start' nginx. Set nginx_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'.
すると、上記の警告が出る。
デーモンとして起動するようにしたいならば、まずは rc.conf を編集して、起動対象にする。もしくは、「start」の代わりに「onestart」を使うように表示される。
テストで起動する
% sudo /usr/local/etc/rc.d/nginx onestart the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok configuration file /usr/local/etc/nginx/nginx.conf test is successful Starting nginx.
常時起動しておきたい場合
% sudo vi /etc/rc.conf
nginx_enable="YES"
を追記してから
% sudo /usr/local/etc/rc.d/nginx start the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok configuration file /usr/local/etc/nginx/nginx.conf test is successful Starting nginx.
とコマンドを実行すると、nginx が起動する。
停止する場合
% sudo /usr/local/etc/rc.d/nginx stop
再起動したい場合
% sudo /usr/local/etc/rc.d/nginx restart