Created
March 15, 2012 17:02
-
-
Save zeitan/2045298 to your computer and use it in GitHub Desktop.
Como instalar rvm+nginx+passenger+php en debian squeeze
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instalar RVM como root | |
# echo 'export rvm_prefix="$HOME"' > /root/.rvmrc | |
# echo 'export rvm_path="$HOME/.rvm"' >> /root/.rvmrc | |
# bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) | |
# type rvm | head -1 | |
# rvm requirements | |
Instalamos lo que haga falta | |
# rvm pkg install readline | |
# rvm pkg install openssl | |
echo passenger >> /usr/local/rvm/gemsets/global.gems | |
# rvm install ree | |
# rvm use --default ree | |
1.- Forma fácil (el script te compila el nginx) | |
# passenger-install-nginx-module | |
2.- Compilando nosotros mismos el nginx | |
PASSENGER_NGINX_DIR=$(passenger-config --root)/ext/nginx | |
cd $PASSENGER_NGINX_DIR | |
# rake nginx RELEASE=yes | |
cd ~ | |
Nginx | |
aptitude install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev build-essential | |
wget http://nginx.org/download/nginx-1.1.9.tar.gz | |
tar -xvzf nginx-1.1.9.tar.gz | |
cd nginx-1.1.9 | |
./configure --pid-path=/var/run/nginx.pid --sbin-path=/usr/local/sbin --with-http_ssl_module --add-module=$PASSENGER_NGINX_DIR | |
make | |
make install | |
cd .. | |
wget http://nginx-init-ubuntu.googlecode.com/files/nginx-init-ubuntu_v2.0.0-RC2.tar.bz2 | |
tar -xvf nginx-init-ubuntu_v2.0.0-RC2.tar.bz2 | |
mv nginx /etc/init.d/ | |
update-rc.d nginx defaults | |
aptitude install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-json php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl | |
open /etc/php5/cgi/php.ini and add the line cgi.fix_pathinfo = 0 | |
/usr/local/nginx/conf/nginx.conf | |
========================================== | |
turpial:/home/satanas# cat /usr/local/nginx/conf/nginx.conf | |
user www-data www-data; | |
worker_processes 2; | |
#error_log /var/log/nginx/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 /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
sendfile on; | |
keepalive_timeout 65; | |
gzip on; | |
passenger_root passenger_root /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.11; | |
passenger_ruby /usr/bin/ruby; | |
passenger_max_pool_size 10; | |
# 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; | |
# } | |
#} | |
include /usr/local/nginx/sites-enabled/dev.turpial.org.ve; | |
include /usr/local/nginx/sites-enabled/turpial.org.ve; | |
} | |
========================================== | |
/etc/init.d/php-fastcgi | |
========================================== | |
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: php-fastcgi | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start and stop php-cgi in external FASTCGI mode | |
# Description: Start and stop php-cgi in external FASTCGI mode | |
### END INIT INFO | |
# Author: Kurt Zankl <[email protected]> | |
# Do NOT "set -e" | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
DESC="php-cgi in external FASTCGI mode" | |
NAME=php-fastcgi | |
DAEMON=/usr/bin/php-cgi | |
PIDFILE=/var/run/$NAME.pid | |
SCRIPTNAME=/etc/init.d/$NAME | |
# Exit if the package is not installed | |
[ -x "$DAEMON" ] || exit 0 | |
# Read configuration variable file if it is present | |
[ -r /etc/default/$NAME ] && . /etc/default/$NAME | |
# Load the VERBOSE setting and other rcS variables | |
. /lib/init/vars.sh | |
# Define LSB log_* functions. | |
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. | |
. /lib/lsb/init-functions | |
# If the daemon is not enabled, give the user a warning and then exit, | |
# unless we are stopping the daemon | |
if [ "$START" != "yes" -a "$1" != "stop" ]; then | |
log_warning_msg "To enable $NAME, edit /etc/default/$NAME and set START=yes" | |
exit 0 | |
fi | |
# Process configuration | |
export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS | |
DAEMON_ARGS="-q -b $FCGI_HOST:$FCGI_PORT" | |
do_start() | |
{ | |
# Return | |
# 0 if daemon has been started | |
# 1 if daemon was already running | |
# 2 if daemon could not be started | |
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1 | |
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile --chuid $EXEC_AS_USER --startas $DAEMON -- $DAEMON_ARGS || return 2 | |
} | |
do_stop() | |
{ | |
# Return | |
# 0 if daemon has been stopped | |
# 1 if daemon was already stopped | |
# 2 if daemon could not be stopped | |
# other if a failure occurred | |
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE > /dev/null # --name $DAEMON | |
RETVAL="$?" | |
[ "$RETVAL" = 2 ] && return 2 | |
# Wait for children to finish too if this is a daemon that forks | |
# and if the daemon is only ever run from this initscript. | |
# If the above conditions are not satisfied then add some other code | |
# that waits for the process to drop all resources that could be | |
# needed by services started subsequently. A last resort is to | |
# sleep for some time. | |
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON | |
[ "$?" = 2 ] && return 2 | |
# Many daemons don't delete their pidfiles when they exit. | |
rm -f $PIDFILE | |
return "$RETVAL" | |
} | |
case "$1" in | |
start) | |
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" | |
do_start | |
case "$?" in | |
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; | |
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; | |
esac | |
;; | |
stop) | |
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" | |
do_stop | |
case "$?" in | |
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; | |
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; | |
esac | |
;; | |
restart|force-reload) | |
log_daemon_msg "Restarting $DESC" "$NAME" | |
do_stop | |
case "$?" in | |
0|1) | |
do_start | |
case "$?" in | |
0) log_end_msg 0 ;; | |
1) log_end_msg 1 ;; # Old process is still running | |
*) log_end_msg 1 ;; # Failed to start | |
esac | |
;; | |
*) | |
# Failed to stop | |
log_end_msg 1 | |
;; | |
esac | |
;; | |
*) | |
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 | |
exit 3 | |
;; | |
esac | |
========================================== | |
/etc/default/php-fastcgi | |
========================================== | |
# | |
# Settings for php-cgi in external FASTCGI Mode | |
# | |
# Should php-fastcgi run automatically on startup? (default: no) | |
START=yes | |
# Which user runs PHP? (default: www-data) | |
EXEC_AS_USER=www-data | |
# Host and TCP port for FASTCGI-Listener (default: localhost:9000) | |
FCGI_HOST=localhost | |
FCGI_PORT=9000 | |
# Environment variables, which are processed by PHP | |
PHP_FCGI_CHILDREN=5 | |
PHP_FCGI_MAX_REQUESTS=1000 | |
========================================== | |
chmod 755 /etc/init.d/php-fastcgi | |
update-rc.d php-fastcgi defaults | |
/etc/init.d/php-fastcgi start | |
mkdir /usr/local/nginx/sites-available | |
mkdir /usr/local/nginx/sites-enabled | |
/usr/local/nginx/sites-available/turpial.org.ve | |
========================================== | |
server { | |
listen 80; | |
server_name turpial.org.ve www.turpial.org.ve; | |
root /srv/www/wordpress; | |
index index.php index.html index.htm; | |
fastcgi_index index.php; | |
include /usr/local/nginx/global-restrictions.conf; | |
#try_files $uri $uri/ /index.php; | |
location / { | |
try_files $uri $uri/ /index.php?args; | |
} | |
location ~ ^/files/(.*)$ { | |
autoindex on; | |
autoindex_exact_size off; | |
} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
location ~ \.php$ { | |
root /srv/www/wordpress; | |
# Workaround PHP vulnerability: | |
# http://forum.nginx.org/read.php?2,88845,page=3 | |
try_files $uri =404; | |
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
include /usr/local/nginx/conf/fastcgi_params; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} | |
} | |
========================================== | |
/usr/local/nginx/sites-available/dev.turpial.org.ve | |
========================================== | |
server { | |
listen 80; | |
server_name dev.turpial.org.ve | |
root /srv/www/redmine/public; | |
passenger_enabled on; | |
passenger_use_global_queue on; | |
} | |
========================================== | |
/usr/local/nginx/global-restrictions.conf | |
========================================== | |
# Global restrictions configuration file. | |
# Designed to be included in any server {} block.</p> | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). | |
location ~ /\. { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
# Deny access to any files with a .php extension in the uploads directory | |
location ~* ^/wp-content/uploads/.*.php$ { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
# Deny access to any files with a .php extension in the uploads directory for multisite | |
location ~* /files/(.*).php$ { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
========================================== | |
ln -s /usr/local/nginx/sites-available/turpial.org.ve /usr/local/nginx/sites-enabled/ | |
/srv/redmine/config/setup_load_paths.rb | |
========================================== | |
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') | |
begin | |
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME'])) | |
rvm_lib_path = File.join(rvm_path, 'lib') | |
$LOAD_PATH.unshift rvm_lib_path | |
require 'rvm' | |
RVM.use_from_path! File.dirname(File.dirname(__FILE__)) | |
rescue LoadError | |
# RVM is unavailable at this point. | |
raise "RVM ruby lib is currently unavailable." | |
end | |
end | |
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__)) | |
require 'bundler/setup' | |
========================================== | |
Para Rails 2 eliminamos las 2 últimas líneas |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment