Нови статии
bash scripts
CPU-frequency scalin...
Oбновявания на ОС W...
install zoneminder 1...
Installing mysql Mar...
Теми във форума
Нови теми
Малък лек и удобен д...
Клавишни комбинации ...
Инсталация на Arch L...
Защитна стена за мик...
Linux
Най-активни теми
Color console linux [4]
Клавишни комбинац... [1]
Защитна стена за ... [1]
Linux [1]
Малък лек и удобе... [0]
Приятели
Сега
Времето
Йерархия на статиите
Статии » How To » HowTo install nginx +PHP for Linux Slackware 13.X.X
HowTo install nginx +PHP for Linux Slackware 13.X.X
cd /usr/src/
wget "http://sbopkg.googlecode.com/files/sbopkg-0.35.0-noarch-1_cng.tgz"
installpkg sbopkg-0.35.0-noarch-1_cng.tgz
sbopkg


Search nginx > network/nginx http/imap/pop3 proxy > Build Build a package for nginx

nano /etc/nginx/nginx.conf

#user nobody;
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;
root /var/www/htdocs;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
# root html;
root /var/www/htdocs;
index index.php 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 html;
}

location ~ \.php$ {
root /var/www/htdocs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME script$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}



chmod +x /etc/rc.d/rc.nginx
/etc/rc.d/rc.nginx start

pico /etc/rc.d/rc.nginx


#!/bin/sh
#
# Nginx daemon control script.
# Written for Slackware Linux by Cherife Li .

BIN=/usr/sbin/nginx
CONF=/etc/nginx/nginx.conf
PID=/var/run/nginx.pid
nginx_start() {
# Sanity checks.
if [ ! -r $CONF ]; then # no config file, exit:
echo "$CONF does not appear to exist. Abort."
exit 1
fi

if [ -s $PID ]; then
echo "Nginx appears to already be running?"
exit 1
fi

echo "Starting Nginx server daemon..."
if [ -x $BIN ]; then
$BIN -c $CONF
fi
}

nginx_test_conf() {
echo "Checking configuration for correct syntax and"
echo "then trying to open files referenced in configuration..."
$BIN -t -c $CONF
}

nginx_term() {
echo "Shutdown Nginx quickly..."
kill -TERM $(cat $PID)
}

nginx_stop() {
echo "Shutdown Nginx gracefully..."
kill -QUIT $(cat $PID)
}

nginx_reload() {
echo "Reloading Nginx configuration..."
kill -HUP $(cat $PID)
}

nginx_upgrade() {
echo "Upgrading to the new Nginx binary."
echo "Make sure the Nginx binary has been replaced with new one"
echo "or Nginx server modules were added/removed."
kill -USR2 $(cat $PID)
sleep 3
kill -QUIT $(cat $PID.oldbin)
}

nginx_rotate() {
echo "Rotating Nginx logs..."
kill -USR1 $(cat $PID)
}

nginx_restart() {
nginx_stop
sleep 3
nginx_start
}

case "$1" in
check)
nginx_test_conf
;;
start)
nginx_start
;;
term)
nginx_term
;;
stop)
nginx_stop
;;
reload)
nginx_reload
;;
restart)
nginx_restart
;;
upgrade)
nginx_upgrade
;;
rotate)
nginx_rotate
;;
*)
echo "usage: `basename $0` {check|start|term|stop|reload|restart|upgrade|rotate}"
esac


cd /var/www/htdocs/
pico index.html




Welcome to Nginx





http://localhost/index.html


pico /etc/nginx/nginx.conf


location ~ \.php$ {
root /srv/httpd/htdocs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME script$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}



bash-4.1# locate php | grep php-cgi
/usr/bin/php-cgi


cd /etc/rc.d/
pico rc.php-cgi


#!/bin/sh
#
# /etc/rc.d/rc.php-cgi
#
# Start/stop/restart
#
# To make php-cgi start automatically at boot, make this
# file executable: chmod +x /etc/rc.d/rc.php-cgi
#
#created by Imron Rosdiana
case "$1" in
'start')
echo "Starting php-cgi"
/usr/bin/php-cgi -b 127.0.0.1:9000 &
;;
'stop')
echo "Shutdown php-cgi"
killall php-cgi
;;
'restart')
echo "Shutdown php-cgi....."
killall php-cgi
sleep 3
echo "Starting php-cgi..."
/usr/bin/php-cgi -b 127.0.0.1:9000 &
;;
*)
echo "Usage: $0 {start|stop|restart}"
;;
esac


chmod +x /etc/rc.d/rc.php-cgi

/etc/rc.d/rc.php-cgi start

cd /var/www/htdocs/
pico info.php

Link

Example #1 phpinfo() Example

http://localhost/info.php


pico /etc/rc.d/rc.local

# Start Nginx Web server;
if [ -x /etc/rc.d/rc.nginx ]; then
. /etc/rc.d/rc.nginx start
fi

# Start php-cgi;
if [ -x /usr/bin/php-cgi ]; then
. /etc/rc.d/rc.php-cgi start
fi

Публикувана от admin на August 15 2012
Коментари
19 #1 Linux

на September 10 2012 14:44:47
Добавете си в кронтаба този ред:
59 * * * * /etc/rc.d/rc.php-cgi restart /etc/cron.hourly 1> /dev/null

За да го добавите изпълнете командите

export VISUAL=pico
crontab -e
Напишете коментар
Трябва да сте регистриран за да напишете коментар
Оценки
Оценяването е достъпно единствено за потребителите.

Влезте в акаунта си или се регистрирайте за да можете да давате оценки.

Отличен! Отличен! 100% [1 Гласувал]
Много добър Много добър 0% [Няма гласували]
Добър Добър 0% [Няма гласували]
Среден Среден 0% [Няма гласували]
Слаб Слаб 0% [Няма гласували]
Вход
Потребител

Парола



Не сте потребител?
Натиснете тук за да се регистрирате.

Забравихте паролата си?
Поискате си нова тук.
Downloads

New Downloads

NAVIGON-Europe ...
NAVIGON Europe ...
NAVIGON Europe ...
NAVIGON Europe ...
µTorrent 3.4.1 ...
BitTorrent 7.9....
ProgDVB 7.04.2 ...
ProgDVB 7.04.2 ...
Wine 1.7.17
sakis3g
Wise Disk Clean...
DAEMON Tools Li...
opam
TurboFTP 6.30 B...
Skype 6.3.73.10...
FileZilla 3.7.0...
ChrisTV 5.75
BSPlayer Pro 2....
Rotativki
SquirrelMail + ...

Top 10 Downloads

n-Track Studio ... [8286]
Super MP3 Downl... [8095]
Registry Mechan... [8079]
Microsoft Secur... [8014]
Hiren`s v10.0.9 [7287]
Rotativki [7128]
K-Lite Mega Cod... [6823]
BitComet 1.21 F... [6735]
Slax + Hiren's ... [4797]
WinSetup From USB [4468]
Ново от Калдата