Установка nginx в Debian linux
Статья устарела, смотрите на дату в урле
Скачиваем
# tar zxvf nginx-0.8.15.tar.gz # cd nginx-0.8.15.tar.gz # ./configure
Всё конфигурируется, а потом выводятся строки
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using —without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using —with-pcre=
Нужно поставить библиотеки (тут написано, какие потом ещё могут понадобиться)
# apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
Потом продолжаем установку:
# ./configure --with-md5=/usr/lib --with-http_dav_module --with-http_ssl_module # make # make install
В итоге конфигурируется с параметрами
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1 library is not used
+ using system zlib library
nginx path prefix: «/usr/local/nginx»
nginx binary file: «/usr/local/nginx/sbin/nginx»
nginx configuration prefix: «/usr/local/nginx/conf»
nginx configuration file: «/usr/local/nginx/conf/nginx.conf»
nginx pid file: «/usr/local/nginx/logs/nginx.pid»
nginx error log file: «/usr/local/nginx/logs/error.log»
nginx http access log file: «/usr/local/nginx/logs/access.log»
nginx http client request body temporary files: «client_body_temp»
nginx http proxy temporary files: «proxy_temp»
nginx http fastcgi temporary files: «fastcgi_temp»
Далее конфигурируем автозагрузку через скрипт init.d (взято отсюда).
Для этого создаём файл в /etc/init.d/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/local/nginx/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
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
и потом
chmod +x /etc/init.d/nginx /usr/sbin/update-rc.d -f nginx defaults
Первая строка добавляет права на выполнение, а вторая обновляет автозагрузку.
Теперь можно пользоваться командами
/etc/init.d/nginx start | stop | restart
Конфигурация nginx:
# user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
charset utf-8;
location / {
root html;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param script_FILENAME /usr/local/www/nginx$fastcgi_script_name;
include fastcgi_params;
}
}
}
Список использованной литературы:
LEAVE A COMMENT
Для отправки комментария вам необходимо авторизоваться.
Юзай Gentoo или *BSD
Дети такого начитаются, потом такого наадминят :)
дети, конечно вряд ли прочитают