次の記事は、コンパイルとインストールの方法に関するものです。 Nginxとして知られる非常に高速なHTTPサーバー。
では、Nginxとは正確には何ですか?
軽量で無料のオープンソースで高性能なHTTPサーバーであり、他のほとんどのHTTPサーバーとは異なり、リクエストのスレッド処理に依存せず、代わりに、はるかにスケーラブルで堅牢なイベント駆動型(非同期)アーキテクチャを使用します。
これは、高負荷時に非常に少量で予測可能な量のメモリを使用します。
とにかく、Debian 6(Squeeze)でNginx、PHP-FPM、MySQL(LNMP Stack)をセットアップしてインストールする方法についての説明をお探しの場合は、LEMP(Nginx、MySQL、 PHP)Debian 6(スクイーズ)VPS上のサーバー
このチュートリアルでは、Debian仮想サーバーの1つを使用しています。さて、最初にすべきことは、Debian 7(Wheezy)システムが最新であることを確認することです:
# apt-get update # apt-get upgrade # apt-get dist-upgrade
次に、必要なパッケージをいくつかインストールして、Nginxをビルドできるようにします:
# apt-get install build-essential # apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
http://nginx.org/en/download.html
からNginxソースのダウンロードと抽出を続行します# mkdir ~/sources # cd ~/sources/ # wget http://nginx.org/download/nginx-1.4.0.tar.gz # tar zxf nginx-1.4.0.tar.gz # cd nginx-1.4.0
「configure」スクリプトを実行してソースを構成します。使用できるものの詳細については、 `./configure –help`を参照してください。
# ./configure \
--prefix=/usr \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--user=www-data \
--group=www-data \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module Nginxのコンパイルとインストールに進みます:
# make # make install
インストールが完了したら、次のinitスクリプトを /etc/init.d/nginxに追加します nginxのインストールを管理できるように:
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi
set -e
. /lib/lsb/init-functions
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS || true
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON || true
sleep 1
start-stop-daemon --start --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
status)
status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
exit 1
;;
esac
exit 0 initスクリプトを実行可能にし、システムのスタートアップアプリケーションにNginxを追加します。
# chmod +x /etc/init.d/nginx # update-rc.d -f nginx defaults
Nginxのセットアップ:
# mkdir /etc/nginx/{sites-available,sites-enabled} /etc/nginx/nginx.confに以下を追加します:
user www-data;
worker_processes 2;
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;
include /etc/nginx/sites-enabled/*;
} /etc/nginx/sites-available/example.comにサーバーブロックを追加します(example.comの出現箇所を目的のドメインに変更してください)。
server {
listen 80;
server_name example.com;
location / {
root /var/www/example.com;
index index.html index.htm;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
} 追加したサーバーブロックを有効にします:
# cd /etc/nginx/sites-enabled/ # ln -s /etc/nginx/sites-available/example.com
次を使用してNginxを再起動します:
# service nginx restart
サンプルページを追加し、サーバーブロックで使用したドメインを開いてNginxをテストします。
# mkdir -p /var/www/example.com # echo -e "<html>\n<head><title>NGINX</title></head>\n \ <body>\t<h1>Powered by RoseHosting.com</h1>\n</body>\n</html>" \ > /var/www/example.com/index.html
もちろん、Linux VPSホスティングサービスのいずれかを使用している場合は、これを行う必要はありません。その場合は、専門のLinux管理者にインストールを依頼するだけです。 24時間年中無休でご利用いただけます。リクエストはすぐに処理されます。
PS。 この投稿が気に入った場合は、左側のボタンを使用してソーシャルネットワーク上の友達と共有するか、下に返信を残してください。ありがとう。