https://wiki.archlinux.org/api.php?action=feedcontributions&user=Sirupsen&feedformat=atomArchWiki - User contributions [en]2024-03-19T04:12:58ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=RVM&diff=116608RVM2010-09-08T06:26:55Z<p>Sirupsen: /* User installation */</p>
<hr />
<div>[http://rvm.beginrescueend.com/ RVM] (Ruby Version Manager) is a command line tool which allows us to easily install, manage and work with multiple [[Ruby]] environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
The install process is very easy, and is the very same for any distro, including ArchLinux. You have two choices, one system-wide, another as a user. The first is for production servers, or if your are alone on your machine. You'll need root privileges. The second is the recommended for multiple users on the same machine (like a development test box).<br />
<br />
As an observation, installing RVM with gem is not recommended anymore. This article uses the [http://rvm.beginrescueend.com/rvm/install/ recommended documentation] with minor tweaks to make work on ArchLinux.<br />
<br />
==== Pre-requisites ====<br />
<br />
$ pacman -Sy git curl<br />
<br />
==== System-wide installation ====<br />
<br />
First we will use the script that rvm docs recommends to install:<br />
<br />
$ bash < <( curl -L http://github.com/wayneeseguin/rvm/raw/master/contrib/install-system-wide )<br />
<br />
'''If''' you want to check the script before:<br />
<br />
$ curl -L http://bit.ly/rvm-install-system-wide > rvm-install-system-wide<br />
<br />
Inspect the file here, then:<br />
<br />
$ bash < ./rvm-install-system-wide<br />
<br />
After the script process, add this to the last line of /etc/bash.bashrc<br />
<br />
$ <nowiki>[[ -s '/usr/local/lib/rvm' ]]</nowiki> && source '/usr/local/lib/rvm'<br />
<br />
Now go to post-installation procedures.<br />
<br />
==== User installation ====<br />
<br />
User-wide installation have a similar procedure to the system-wide install:<br />
<br />
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )<br />
<br />
Then add to your ~/.bash_profile or ~/.bashrc:<br />
<br />
$ <nowiki>[[ -s "$HOME/.rvm/scripts/rvm" ]]</nowiki> && source "$HOME/.rvm/scripts/rvm"<br />
<br />
==== Post installation ====<br />
<br />
After the installation, check with this command:<br />
<br />
$ type rvm | head -n1<br />
<br />
The response should be:<br />
<br />
$ rvm is a function<br />
<br />
Check if the rvm function is working:<br />
<br />
$ rvm notes<br />
<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7. Make sure, you have gcc or another fitting compiler installed.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== RVM update ====<br />
<br />
Simply use:<br />
<br />
$ rvm update<br />
<br />
==== Revert the default ruby to system ruby ====<br />
<br />
$ rvm system<br />
<br />
And check if the version complies with your system installed package:<br />
<br />
$ ruby -v<br />
$ pacman -Q ruby<br />
$ which ruby<br />
<br />
"which ruby" must be pointing to /usr/bin/ruby<br />
<br />
=== Troubleshooting ===<br />
<br />
You'll need to take care with rvm installations, since ArchLinux is very well updated, and some earlier ruby's patchlevels don't like it. RVM many times don't choose the latest patchlevel version to install, and you'll need to check manually on the [http://www.ruby-lang.org/en/news/ ruby website], and force RVM to install it.<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. Arch uses openssl 1.0, lower patchlevels of 1.8.7 assumes 0.9. <br />
<br />
You can use newer patchlevels, like p299 '''or newer''' with:<br />
<br />
$ rvm remove 1.8.7<br />
$ rvm install 1.8.7-p299<br />
<br />
Another approach is to install local openssl via RVM:<br />
<br />
$ rvm package install openssl<br />
$ rvm remove 1.8.7<br />
$ rvm install 1.8.7 -C --with-openssl-dir=$HOME/.rvm/usr<br />
<br />
==== Ruby 1.9.x won't compile with RVM ====<br />
<br />
Like with 1.8.x, earlier patchlevels don't like the OpenSSL 1.0. Then you can use the very same solution above, by installing openssl locally on RVM.<br />
<br />
$ rvm package install openssl<br />
$ rvm remove 1.9.1<br />
$ rvm install 1.9.1 -C --with-openssl-dir=/usr/local/rvm/usr</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106699Nginx2010-05-19T21:35:11Z<p>Sirupsen: /* Step 1: Start the FastCGI server */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. It is recommended to use [[NginX#Method_two_.28Third-party-wrapper.29]].<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
{{Note|Since NginX 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default NginX directory and symlinked to /srv/http/nginx in the Arch package. For PHP to work with NginX 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory Filename|/etc/nginx/html. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/}}<br />
<br />
Below is a daemon script to be used in {{Filename|/etc/rc.conf}} on boot to start PHP-cgi. save it as {{Filename||/etc/rc.d/fastcgi}} and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
This can be more comfortable than the first method because of increased flexibility.<br />
<br />
There are currently three options for deploying [[PHP]] on NginX:<br />
<br />
* ''fcgi''<br />
** Includes ''cgi-fcgi''<br />
* ''lighttpd''<br />
** Includes ''spawn-fcgi''<br />
* '''''PHP-FPM''''' (Available via the AUR, recommended)<br />
<br />
To spawn a process, issue one of the following commands (matching the package you installed):<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit {{Filename|/etc/php-fpm.conf}} at first. More details on ''php-fpm'' can be found at the [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|PHP-FPM will be included into {{Filename|PHP 5.4}}.}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If NginX has been working, run:<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit {{Filename|/srv/http/nginx/index.php}},<br />
<?php<br />
phpinfo();<br />
?> <br />
Visit the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with NginX.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====Error: 403 (Permission error)====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====Error: The page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====Error: No input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106698Nginx2010-05-19T21:29:48Z<p>Sirupsen: /* Step 3: Restart nginx */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
This can be more comfortable than the first method because of increased flexibility.<br />
<br />
There are currently three options for deploying [[PHP]] on NginX:<br />
<br />
* ''fcgi''<br />
** Includes ''cgi-fcgi''<br />
* ''lighttpd''<br />
** Includes ''spawn-fcgi''<br />
* '''''PHP-FPM''''' (Available via the AUR, recommended)<br />
<br />
To spawn a process, issue one of the following commands (matching the package you installed):<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit {{Filename|/etc/php-fpm.conf}} at first. More details on ''php-fpm'' can be found at the [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|PHP-FPM will be included into {{Filename|PHP 5.4}}.}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If NginX has been working, run:<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit {{Filename|/srv/http/nginx/index.php}},<br />
<?php<br />
phpinfo();<br />
?> <br />
Visit the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with NginX.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====Error: 403 (Permission error)====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====Error: The page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====Error: No input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106697Nginx2010-05-19T21:29:32Z<p>Sirupsen: /* Method two (Third-party-wrapper) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
This can be more comfortable than the first method because of increased flexibility.<br />
<br />
There are currently three options for deploying [[PHP]] on NginX:<br />
<br />
* ''fcgi''<br />
** Includes ''cgi-fcgi''<br />
* ''lighttpd''<br />
** Includes ''spawn-fcgi''<br />
* '''''PHP-FPM''''' (Available via the AUR, recommended)<br />
<br />
To spawn a process, issue one of the following commands (matching the package you installed):<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit {{Filename|/etc/php-fpm.conf}} at first. More details on ''php-fpm'' can be found at the [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|PHP-FPM will be included into {{Filename|PHP 5.4}}.}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run:<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit {{Filename|/srv/http/nginx/index.php}},<br />
<?php<br />
phpinfo();<br />
?> <br />
Visit the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with NginX.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====Error: 403 (Permission error)====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====Error: The page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====Error: No input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106696Nginx2010-05-19T21:21:46Z<p>Sirupsen: /* Method three (PHP-fpm) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
This can be more comfortable than the first method because of increased flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit {{Filename|/etc/php-fpm.conf}} at first. More details about {{Filname|php-fpm}} can be found at [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run:<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit {{Filename|/srv/http/nginx/index.php}},<br />
<?php<br />
phpinfo();<br />
?> <br />
Visit the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with NginX.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====Error: 403 (Permission error)====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====Error: The page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====Error: No input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106695Nginx2010-05-19T21:21:39Z<p>Sirupsen: /* Method two (Third-party-wrapper) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
This can be more comfortable than the first method because of increased flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit {{Filename|/etc/php-fpm.conf}} at first. More details about {{Filname|php-fpm}} can be found at [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run:<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit {{Filename|/srv/http/nginx/index.php}},<br />
<?php<br />
phpinfo();<br />
?> <br />
Visit the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with NginX.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====Error: 403 (Permission error)====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====Error: The page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====Error: No input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106694Nginx2010-05-19T21:20:22Z<p>Sirupsen: /* Step 2: Edit /etc/nginx/conf/nginx.conf */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run:<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit {{Filename|/srv/http/nginx/index.php}},<br />
<?php<br />
phpinfo();<br />
?> <br />
Visit the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with NginX.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====Error: 403 (Permission error)====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====Error: The page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====Error: No input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106693Nginx2010-05-19T21:20:06Z<p>Sirupsen: /* Step 3: Restart nginx */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run:<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit {{Filename|/srv/http/nginx/index.php}},<br />
<?php<br />
phpinfo();<br />
?> <br />
Visit the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with NginX.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====Error: 403 (Permission error)====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====Error: The page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====Error: No input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106692Nginx2010-05-19T21:19:14Z<p>Sirupsen: /* Troubleshooting */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====Error: 403 (Permission error)====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====Error: The page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====Error: No input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106691Nginx2010-05-19T21:18:28Z<p>Sirupsen: /* Security */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* Allow/deny visitors based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====The browser results in: '''no input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106690Nginx2010-05-19T21:18:12Z<p>Sirupsen: /* Setting up Nginx and Passenger */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial].<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====The browser results in: '''no input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby&diff=106689Ruby2010-05-19T21:15:47Z<p>Sirupsen: /* Bundler */</p>
<hr />
<div>[[Category:Development (English)]]<br />
Ruby is a dynamic, interpreted, open source programming language with a focus on simplicity and productivity.<br />
<br />
== Installing Ruby ==<br />
The version of Ruby you need to install depends on your requirements, as not all 3rd party code is compatible with all versions. Here's a summary of the versions below and how to get them:<br />
<br />
=== Ruby 1.9 (Development) ===<br />
'''Summary:''' Use Ruby 1.9 for a new new Rails project, or when you're sure all your required gems are supported by Ruby 1.9<br />
<br />
Pros:<br />
* Vastly improved performance over 1.8<br />
* New features for concurrency such as fibers.<br />
* Various other language improvements, such as an improved CSV parser.<br />
<br />
Cons:<br />
* Not compatible with many older gems (and Ruby On Rails versions prior to 2.3)<br />
* Changes in the language might cause older Ruby code not to run, or exhibit unexpected bugs.<br />
<br />
{{Box Note | Visit http://isitruby19.com/ to determine if the gems/modules you require are compatible with Ruby 1.9 }}<br />
<br />
To install Ruby 1.9, simply run:<br />
# pacman -S ruby<br />
<br />
Ruby 1.9 also includes RubyGems (detailed below), so you can easily update to the latest RubyGems using:<br />
# gem update --system<br />
<br />
=== Ruby 1.8.7 (Stable) ===<br />
'''Summary:''' Use Ruby 1.8.7 if you're unsure, or are not working on any legacy systems.<br />
<br />
Pros:<br />
* Latest version of the 1.8 branch, capable of running most if not all recently updated gems and Ruby On Rails<br />
<br />
Cons:<br />
* Introduces certain breaking changes from 1.8.6, which causes older lesser-maintained gems and Rails prior to 2.0 not to work without "monkey patching".<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=30221 ruby1.8] from the [[AUR]].<br />
<br />
RubyGems is not included with the ruby1.8 package, so install [http://aur.archlinux.org/packages.php?ID=30224 rubygems1.8] from the [[AUR]].<br />
<br />
=== Ruby 1.8.6 (Legacy) ===<br />
'''Summary:''' Use Ruby 1.8.6 if you are working on old project, older version of Rails (especially < 2.0), or simply want the least possible issues.<br />
<br />
Pros:<br />
* Compatible with just about anything <br />
<br />
Cons:<br />
* Missing some performance and language enhancements from 1.8.7<br />
* Support might be dropped with Rails 3.0 (in Beta at the time of writing)<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=36898 ruby1.8.6-legacy] from the [[AUR]]. <br />
<br />
RubyGems is not included with the ruby1.8.6-legacy package, so install [http://aur.archlinux.org/packages.php?ID=33312 rubygems] from the [[AUR]].<br />
<br />
{{Box Note | This package will replace the official "ruby" package, as installing both Ruby 1.8 and 1.9 while possible, can cause erratic behaviour of some 3rd party code }}<br />
<br />
=== Multiple versions ===<br />
If you want to run multiple versions on the same system (e.g. '''1.9.1''' and '''1.8.7'''), the easiest way is to use [[RVM]].<br />
<br />
== RubyGems ==<br />
''gem'' is the package manager of sorts for Ruby modules (called Gems), somewhat comparable to what pacman is to Arch Linux. The ''gem'' command will be installed if you followed the installation instructions above.<br />
<br />
=== Running as root ===<br />
When running gem as root, gems will be installed for everyone on the machine. This has the advantage of simplicity and is the most reliable method, but updating or installing gems without everyone's knowledge (like on a shared server) might cause Ruby applications to break.<br />
<br />
When not running gem as root, the gems will be installed into {{Filename|~/.gem}} and not affect anyone else, although it might be worth noting that not all gems are happy with be installed in this way, and might insist on being installed by root (especially if they have native extensions).<br />
<br />
[[Ruby#Bundler|Bundler]] solves these problems to some extent by packaging gems into your application. See the section below on using bundler.<br />
<br />
=== Updating RubyGems ===<br />
# gem update --system<br />
<br />
=== Installing a gem ===<br />
This example installs the MySQL ruby gem:<br />
# gem install mysql<br />
<br />
The process can be speeded up somewhat if you don't need local documentation:<br />
# gem install mysql --no-rdoc --no-ri<br />
<br />
The gem will now be downloaded, compiled if necessary, and installed.<br />
<br />
=== Bundler ===<br />
[http://github.com/carlhuda/bundler Bundler] installs gems (including those with native extensions) directly into your application, which works very well for shared hosting and easy deployment of [[Ruby on Rails]] applications for example. Bundler also resolves dependencies as a whole, rather than individually like RubyGems, making things a lot easier.<br />
<br />
It might be a good idea to install bundler as a system-wide gem so everyone can use it:<br />
# gem install bundler<br />
<br />
To start a new bundle:<br />
$ bundle init<br />
<br />
Then add your required gems into "Gemfile" in the current directory (created by bundle init):<br />
<br />
{{File|name=Gemfile|content=<br />
gem "rails", "2.3.4"<br />
gem "mysql"<br />
}}<br />
<br />
Finally, run the following to install your gems. They will all be installed locally into {{Filename|~/.bundle}}, eliminating the need for root access:<br />
$ bundle install<br />
<br />
== See also ==<br />
* [[Ruby On Rails]]<br />
<br />
== References ==<br />
* Ruby - ruby-lang.org/<br />
* Rubyforge - http://rubyforge.org<br />
* Bundler - http://github.com/carlhuda/bundler</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby&diff=106688Ruby2010-05-19T21:14:46Z<p>Sirupsen: /* Bundler */</p>
<hr />
<div>[[Category:Development (English)]]<br />
Ruby is a dynamic, interpreted, open source programming language with a focus on simplicity and productivity.<br />
<br />
== Installing Ruby ==<br />
The version of Ruby you need to install depends on your requirements, as not all 3rd party code is compatible with all versions. Here's a summary of the versions below and how to get them:<br />
<br />
=== Ruby 1.9 (Development) ===<br />
'''Summary:''' Use Ruby 1.9 for a new new Rails project, or when you're sure all your required gems are supported by Ruby 1.9<br />
<br />
Pros:<br />
* Vastly improved performance over 1.8<br />
* New features for concurrency such as fibers.<br />
* Various other language improvements, such as an improved CSV parser.<br />
<br />
Cons:<br />
* Not compatible with many older gems (and Ruby On Rails versions prior to 2.3)<br />
* Changes in the language might cause older Ruby code not to run, or exhibit unexpected bugs.<br />
<br />
{{Box Note | Visit http://isitruby19.com/ to determine if the gems/modules you require are compatible with Ruby 1.9 }}<br />
<br />
To install Ruby 1.9, simply run:<br />
# pacman -S ruby<br />
<br />
Ruby 1.9 also includes RubyGems (detailed below), so you can easily update to the latest RubyGems using:<br />
# gem update --system<br />
<br />
=== Ruby 1.8.7 (Stable) ===<br />
'''Summary:''' Use Ruby 1.8.7 if you're unsure, or are not working on any legacy systems.<br />
<br />
Pros:<br />
* Latest version of the 1.8 branch, capable of running most if not all recently updated gems and Ruby On Rails<br />
<br />
Cons:<br />
* Introduces certain breaking changes from 1.8.6, which causes older lesser-maintained gems and Rails prior to 2.0 not to work without "monkey patching".<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=30221 ruby1.8] from the [[AUR]].<br />
<br />
RubyGems is not included with the ruby1.8 package, so install [http://aur.archlinux.org/packages.php?ID=30224 rubygems1.8] from the [[AUR]].<br />
<br />
=== Ruby 1.8.6 (Legacy) ===<br />
'''Summary:''' Use Ruby 1.8.6 if you are working on old project, older version of Rails (especially < 2.0), or simply want the least possible issues.<br />
<br />
Pros:<br />
* Compatible with just about anything <br />
<br />
Cons:<br />
* Missing some performance and language enhancements from 1.8.7<br />
* Support might be dropped with Rails 3.0 (in Beta at the time of writing)<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=36898 ruby1.8.6-legacy] from the [[AUR]]. <br />
<br />
RubyGems is not included with the ruby1.8.6-legacy package, so install [http://aur.archlinux.org/packages.php?ID=33312 rubygems] from the [[AUR]].<br />
<br />
{{Box Note | This package will replace the official "ruby" package, as installing both Ruby 1.8 and 1.9 while possible, can cause erratic behaviour of some 3rd party code }}<br />
<br />
=== Multiple versions ===<br />
If you want to run multiple versions on the same system (e.g. '''1.9.1''' and '''1.8.7'''), the easiest way is to use [[RVM]].<br />
<br />
== RubyGems ==<br />
''gem'' is the package manager of sorts for Ruby modules (called Gems), somewhat comparable to what pacman is to Arch Linux. The ''gem'' command will be installed if you followed the installation instructions above.<br />
<br />
=== Running as root ===<br />
When running gem as root, gems will be installed for everyone on the machine. This has the advantage of simplicity and is the most reliable method, but updating or installing gems without everyone's knowledge (like on a shared server) might cause Ruby applications to break.<br />
<br />
When not running gem as root, the gems will be installed into {{Filename|~/.gem}} and not affect anyone else, although it might be worth noting that not all gems are happy with be installed in this way, and might insist on being installed by root (especially if they have native extensions).<br />
<br />
[[Ruby#Bundler|Bundler]] solves these problems to some extent by packaging gems into your application. See the section below on using bundler.<br />
<br />
=== Updating RubyGems ===<br />
# gem update --system<br />
<br />
=== Installing a gem ===<br />
This example installs the MySQL ruby gem:<br />
# gem install mysql<br />
<br />
The process can be speeded up somewhat if you don't need local documentation:<br />
# gem install mysql --no-rdoc --no-ri<br />
<br />
The gem will now be downloaded, compiled if necessary, and installed.<br />
<br />
=== Bundler ===<br />
[http://github.com/carlhuda/bundler Bundler] installs gems (including those with native extensions) directly into your application, which works very well for shared hosting and easy deployment of [[Ruby on Rails]] applications for example. Bundler also resolves dependencies as a whole, rather than individually like RubyGems, making things a lot easier.<br />
<br />
It might be a good idea to install bundler as a system-wide gem so everyone can use it:<br />
# gem install bundler<br />
<br />
To start a new bundle:<br />
$ bundle init<br />
<br />
Then add your required gems into "Gemfile" in the current directory (created by bundle init):<br />
gem "rails", "2.3.4"<br />
gem "mysql"<br />
<br />
Finally, run the following to install your gems. They will all be installed locally into {{Filename|~/.bundle}}, eliminating the need for root access:<br />
$ bundle install<br />
<br />
== See also ==<br />
* [[Ruby On Rails]]<br />
<br />
== References ==<br />
* Ruby - ruby-lang.org/<br />
* Rubyforge - http://rubyforge.org<br />
* Bundler - http://github.com/carlhuda/bundler</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby&diff=106687Ruby2010-05-19T21:14:33Z<p>Sirupsen: /* Bundler */</p>
<hr />
<div>[[Category:Development (English)]]<br />
Ruby is a dynamic, interpreted, open source programming language with a focus on simplicity and productivity.<br />
<br />
== Installing Ruby ==<br />
The version of Ruby you need to install depends on your requirements, as not all 3rd party code is compatible with all versions. Here's a summary of the versions below and how to get them:<br />
<br />
=== Ruby 1.9 (Development) ===<br />
'''Summary:''' Use Ruby 1.9 for a new new Rails project, or when you're sure all your required gems are supported by Ruby 1.9<br />
<br />
Pros:<br />
* Vastly improved performance over 1.8<br />
* New features for concurrency such as fibers.<br />
* Various other language improvements, such as an improved CSV parser.<br />
<br />
Cons:<br />
* Not compatible with many older gems (and Ruby On Rails versions prior to 2.3)<br />
* Changes in the language might cause older Ruby code not to run, or exhibit unexpected bugs.<br />
<br />
{{Box Note | Visit http://isitruby19.com/ to determine if the gems/modules you require are compatible with Ruby 1.9 }}<br />
<br />
To install Ruby 1.9, simply run:<br />
# pacman -S ruby<br />
<br />
Ruby 1.9 also includes RubyGems (detailed below), so you can easily update to the latest RubyGems using:<br />
# gem update --system<br />
<br />
=== Ruby 1.8.7 (Stable) ===<br />
'''Summary:''' Use Ruby 1.8.7 if you're unsure, or are not working on any legacy systems.<br />
<br />
Pros:<br />
* Latest version of the 1.8 branch, capable of running most if not all recently updated gems and Ruby On Rails<br />
<br />
Cons:<br />
* Introduces certain breaking changes from 1.8.6, which causes older lesser-maintained gems and Rails prior to 2.0 not to work without "monkey patching".<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=30221 ruby1.8] from the [[AUR]].<br />
<br />
RubyGems is not included with the ruby1.8 package, so install [http://aur.archlinux.org/packages.php?ID=30224 rubygems1.8] from the [[AUR]].<br />
<br />
=== Ruby 1.8.6 (Legacy) ===<br />
'''Summary:''' Use Ruby 1.8.6 if you are working on old project, older version of Rails (especially < 2.0), or simply want the least possible issues.<br />
<br />
Pros:<br />
* Compatible with just about anything <br />
<br />
Cons:<br />
* Missing some performance and language enhancements from 1.8.7<br />
* Support might be dropped with Rails 3.0 (in Beta at the time of writing)<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=36898 ruby1.8.6-legacy] from the [[AUR]]. <br />
<br />
RubyGems is not included with the ruby1.8.6-legacy package, so install [http://aur.archlinux.org/packages.php?ID=33312 rubygems] from the [[AUR]].<br />
<br />
{{Box Note | This package will replace the official "ruby" package, as installing both Ruby 1.8 and 1.9 while possible, can cause erratic behaviour of some 3rd party code }}<br />
<br />
=== Multiple versions ===<br />
If you want to run multiple versions on the same system (e.g. '''1.9.1''' and '''1.8.7'''), the easiest way is to use [[RVM]].<br />
<br />
== RubyGems ==<br />
''gem'' is the package manager of sorts for Ruby modules (called Gems), somewhat comparable to what pacman is to Arch Linux. The ''gem'' command will be installed if you followed the installation instructions above.<br />
<br />
=== Running as root ===<br />
When running gem as root, gems will be installed for everyone on the machine. This has the advantage of simplicity and is the most reliable method, but updating or installing gems without everyone's knowledge (like on a shared server) might cause Ruby applications to break.<br />
<br />
When not running gem as root, the gems will be installed into {{Filename|~/.gem}} and not affect anyone else, although it might be worth noting that not all gems are happy with be installed in this way, and might insist on being installed by root (especially if they have native extensions).<br />
<br />
[[Ruby#Bundler|Bundler]] solves these problems to some extent by packaging gems into your application. See the section below on using bundler.<br />
<br />
=== Updating RubyGems ===<br />
# gem update --system<br />
<br />
=== Installing a gem ===<br />
This example installs the MySQL ruby gem:<br />
# gem install mysql<br />
<br />
The process can be speeded up somewhat if you don't need local documentation:<br />
# gem install mysql --no-rdoc --no-ri<br />
<br />
The gem will now be downloaded, compiled if necessary, and installed.<br />
<br />
=== Bundler ===<br />
[http://github.com/carlhuda/bundler Bundler] installs gems (including those with native extensions) directly into your application, which works very well for shared hosting and easy deployment of [[Ruby on Rails]] applications for example. Bundler also resolves dependencies as a whole, rather than individually like RubyGems, making things a lot easier.<br />
<br />
It might be a good idea to install bundler as a system-wide gem so everyone can use it:<br />
# gem install bundler<br />
<br />
To start a new bundle:<br />
# bundle init<br />
<br />
Then add your required gems into "Gemfile" in the current directory (created by bundle init):<br />
gem "rails", "2.3.4"<br />
gem "mysql"<br />
<br />
Finally, run the following to install your gems. They will all be installed locally into {{Filename|~/.bundle}}, eliminating the need for root access:<br />
# bundle install<br />
<br />
== See also ==<br />
* [[Ruby On Rails]]<br />
<br />
== References ==<br />
* Ruby - ruby-lang.org/<br />
* Rubyforge - http://rubyforge.org<br />
* Bundler - http://github.com/carlhuda/bundler</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby&diff=106686Ruby2010-05-19T21:13:55Z<p>Sirupsen: /* Running as root */</p>
<hr />
<div>[[Category:Development (English)]]<br />
Ruby is a dynamic, interpreted, open source programming language with a focus on simplicity and productivity.<br />
<br />
== Installing Ruby ==<br />
The version of Ruby you need to install depends on your requirements, as not all 3rd party code is compatible with all versions. Here's a summary of the versions below and how to get them:<br />
<br />
=== Ruby 1.9 (Development) ===<br />
'''Summary:''' Use Ruby 1.9 for a new new Rails project, or when you're sure all your required gems are supported by Ruby 1.9<br />
<br />
Pros:<br />
* Vastly improved performance over 1.8<br />
* New features for concurrency such as fibers.<br />
* Various other language improvements, such as an improved CSV parser.<br />
<br />
Cons:<br />
* Not compatible with many older gems (and Ruby On Rails versions prior to 2.3)<br />
* Changes in the language might cause older Ruby code not to run, or exhibit unexpected bugs.<br />
<br />
{{Box Note | Visit http://isitruby19.com/ to determine if the gems/modules you require are compatible with Ruby 1.9 }}<br />
<br />
To install Ruby 1.9, simply run:<br />
# pacman -S ruby<br />
<br />
Ruby 1.9 also includes RubyGems (detailed below), so you can easily update to the latest RubyGems using:<br />
# gem update --system<br />
<br />
=== Ruby 1.8.7 (Stable) ===<br />
'''Summary:''' Use Ruby 1.8.7 if you're unsure, or are not working on any legacy systems.<br />
<br />
Pros:<br />
* Latest version of the 1.8 branch, capable of running most if not all recently updated gems and Ruby On Rails<br />
<br />
Cons:<br />
* Introduces certain breaking changes from 1.8.6, which causes older lesser-maintained gems and Rails prior to 2.0 not to work without "monkey patching".<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=30221 ruby1.8] from the [[AUR]].<br />
<br />
RubyGems is not included with the ruby1.8 package, so install [http://aur.archlinux.org/packages.php?ID=30224 rubygems1.8] from the [[AUR]].<br />
<br />
=== Ruby 1.8.6 (Legacy) ===<br />
'''Summary:''' Use Ruby 1.8.6 if you are working on old project, older version of Rails (especially < 2.0), or simply want the least possible issues.<br />
<br />
Pros:<br />
* Compatible with just about anything <br />
<br />
Cons:<br />
* Missing some performance and language enhancements from 1.8.7<br />
* Support might be dropped with Rails 3.0 (in Beta at the time of writing)<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=36898 ruby1.8.6-legacy] from the [[AUR]]. <br />
<br />
RubyGems is not included with the ruby1.8.6-legacy package, so install [http://aur.archlinux.org/packages.php?ID=33312 rubygems] from the [[AUR]].<br />
<br />
{{Box Note | This package will replace the official "ruby" package, as installing both Ruby 1.8 and 1.9 while possible, can cause erratic behaviour of some 3rd party code }}<br />
<br />
=== Multiple versions ===<br />
If you want to run multiple versions on the same system (e.g. '''1.9.1''' and '''1.8.7'''), the easiest way is to use [[RVM]].<br />
<br />
== RubyGems ==<br />
''gem'' is the package manager of sorts for Ruby modules (called Gems), somewhat comparable to what pacman is to Arch Linux. The ''gem'' command will be installed if you followed the installation instructions above.<br />
<br />
=== Running as root ===<br />
When running gem as root, gems will be installed for everyone on the machine. This has the advantage of simplicity and is the most reliable method, but updating or installing gems without everyone's knowledge (like on a shared server) might cause Ruby applications to break.<br />
<br />
When not running gem as root, the gems will be installed into {{Filename|~/.gem}} and not affect anyone else, although it might be worth noting that not all gems are happy with be installed in this way, and might insist on being installed by root (especially if they have native extensions).<br />
<br />
[[Ruby#Bundler|Bundler]] solves these problems to some extent by packaging gems into your application. See the section below on using bundler.<br />
<br />
=== Updating RubyGems ===<br />
# gem update --system<br />
<br />
=== Installing a gem ===<br />
This example installs the MySQL ruby gem:<br />
# gem install mysql<br />
<br />
The process can be speeded up somewhat if you don't need local documentation:<br />
# gem install mysql --no-rdoc --no-ri<br />
<br />
The gem will now be downloaded, compiled if necessary, and installed.<br />
<br />
=== Bundler ===<br />
[http://github.com/carlhuda/bundler Bundler] installs gems (including those with native extensions) directly into your application, which works very well for shared hosting and easy deployment of [[Ruby on Rails]] applications for example. Bundler also resolves dependencies as a whole, rather than individually like RubyGems, making things a lot easier.<br />
<br />
It might be a good idea to install bundler as a system-wide gem so everyone can use it:<br />
# gem install bundler<br />
<br />
To start a new bundle:<br />
# bundle init<br />
<br />
Then add your required gems into "Gemfile" in the current directory (created by bundle init):<br />
gem "rails", "2.3.4"<br />
gem "mysql"<br />
<br />
Finally, run the following to install your gems. They will all be installed locally into ~/.bundle, eliminating the need for root access:<br />
# bundle install<br />
<br />
== See also ==<br />
* [[Ruby On Rails]]<br />
<br />
== References ==<br />
* Ruby - ruby-lang.org/<br />
* Rubyforge - http://rubyforge.org<br />
* Bundler - http://github.com/carlhuda/bundler</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby_on_Rails&diff=106685Ruby on Rails2010-05-19T21:11:11Z<p>Sirupsen: /* Configuration */ Root unnecessary</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|RubyOnRails|Ruby On Rails}}<br />
<br />
[http://rubyonrails.org/ Ruby on Rails], often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language. It is intended to be used with an Agile development methodology that is used by web developers for rapid development.<br />
<br />
This document describes how to set up the Ruby on Rails Framework on an Arch Linux system.<br />
<br />
Ruby on Rails requires [[Ruby]] to be installed, so read that article first for installation instructions.<br />
<br />
== Installation via RubyGems (Recommended) ==<br />
{{Box Note | If this command is run without being root (using sudo or otherwise), the gem will be installed into the home directory of the user.}}<br />
<br />
# gem install rails<br />
<br />
Building the documentation takes a while. If you want to skip it, append the parameters --no-ri --no-rdoc to the install command.<br />
# gem install rails --no-ri --no-rdoc<br />
<br />
===Updating gems===<br />
gem is a package manager for Ruby modules, somewhat like pacman is to Arch Linux. To update your gems, simply run:<br />
# gem update<br />
<br />
== Installing via the AUR ==<br />
{{Warning | This is not recommended, as this might not include the latest Rails version, and additional dependencies may be introduced that may require you to run "gem install" anyway. }}<br />
There is a [http://aur.archlinux.org/packages.php?ID=14624 Rails package] available in the [[AUR]]. Note that this is not in an official repository, so you'll need to build it manually with makepkg or using an [[AUR Helpers|AUR helper]].<br />
<br />
== Configuration ==<br />
Rails is bundled with a basic HTTP server called WeBrick. You can create a test application to test it. First, create an application with the rails command :<br />
<br />
$ rails testapp_name<br />
<br />
Next start the web server. It listens on port 3000 by default :<br />
<br />
$ cd testapp_name<br />
$ ruby script/server <br />
<br />
Finally open your server address on port 3000 in your web browser. For example, if you're working on your local machine, visit http://localhost:3000/<br />
<br />
A test-page should shown greeting you "Welcome aboard".<br />
<br />
== Web servers ==<br />
While the default Ruby On Rails HTTP server (WeBrick) is convenient for basic development it is not recommended for production use. Here are some suitable alternatives:<br />
<br />
=== Mongrel ===<br />
Mongrel is a drop-in replacement for WeBrick, that can be run in precisely the same way, but offers better performance.<br />
<br />
First install the Mongrel gem:<br />
# gem install mongrel<br />
<br />
Then start it using:<br />
# mongrel_rails start<br />
<br />
Alternatively, you can just run "ruby script/server" again, as it replaces WeBrick by default.<br />
<br />
Generally, Mongrel is used in a production environment by running multiple instances of mongrel_rails, which are load-balanced behind an [[nginx]] or [[Apache]] reverse proxy. However, you might find Phusion Passenger (see below) a much simpler solution for running a production environment.<br />
<br />
=== Phusion Passenger (Recommended for production) ===<br />
[http://www.modrails.com/ Passenger] also known as {{Filename|mod_rails}} is a module available for [[NginX]] and [[Apache]], that greatly simplifies setting up a Rails server environment.<br />
<br />
Start by installing the Passenger gem:<br />
# gem install passenger<br />
<br />
If you are aiming to use [[Apache]] with Passenger, install the following package from the AUR<br />
# passenger-install-apache2-module<br />
<br />
For [[NginX]]:<br />
# passenger-install-nginx-module<br />
<br />
The installer will provide you with any additional information regarding the installation (such as installing additional libraries).<br />
<br />
{{Note|See [[NginX#Ruby_.28Rack-based_and_Rails.29]] for more information on configuring a Rails/ Passenger/NginX web stack.}}<br />
<br />
== Databases ==<br />
Most web applications will need to interact with some sort of database. ActiveRecord (the ORM used by Rails to provide database abstraction) supports several database vendors, the most popular of which are MySQL, SQLite, and PostgreSQL.<br />
<br />
=== SQLite ===<br />
SQLite is the default lightweight database for Ruby on Rails. To enable SQLite, simply install ruby-sqlite3<br />
# pacman -S ruby-sqlite3<br />
<br />
=== MySQL 5+ ===<br />
{{Box Note | You must first install MySQL with the appropriate headers in /usr/include (just pacman -S mysql is fine) before attempting to install the Ruby MySQL extensions }}<br />
<br />
Please refer to [[MySQL]] on how to install MySQL Server.<br />
<br />
A gem with some native extensions is required, probably best installed as root:<br />
# sudo gem install mysql<br />
<br />
You can generate a rails application configured for MySQL by using the -d parameter :<br />
# rails -d mysql testapp_name<br />
<br />
You then need to edit config/database.yml. Rails uses different databases for development, testing, production and other environments. Here's an example development configuration for MySQL running on localhost:<br />
<br />
development:<br />
adapter: mysql<br />
database: my_application_database<br />
username: development<br />
password: my_secret_password<br />
<br />
Note that you don't have to actually create the database using a MySQL, as this can be done via Rails with :<br />
# rake db:create<br />
<br />
If no errors are shown, then your database has been created and Rails can talk to your MySQL database.<br />
<br />
== See also ==<br />
* [[Ruby]]<br />
* [[nginx]]<br />
* [[LAMP]]<br />
* [[MySQL]]<br />
<br />
== References ==<br />
* Ruby on Rails http://rubyonrails.org/download<br />
* Mongrel http://mongrel.rubyforge.org/</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby_on_Rails&diff=106684Ruby on Rails2010-05-19T21:07:18Z<p>Sirupsen: /* Phusion Passenger (Recommended for production) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|RubyOnRails|Ruby On Rails}}<br />
<br />
[http://rubyonrails.org/ Ruby on Rails], often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language. It is intended to be used with an Agile development methodology that is used by web developers for rapid development.<br />
<br />
This document describes how to set up the Ruby on Rails Framework on an Arch Linux system.<br />
<br />
Ruby on Rails requires [[Ruby]] to be installed, so read that article first for installation instructions.<br />
<br />
== Installation via RubyGems (Recommended) ==<br />
{{Box Note | If this command is run without being root (using sudo or otherwise), the gem will be installed into the home directory of the user.}}<br />
<br />
# gem install rails<br />
<br />
Building the documentation takes a while. If you want to skip it, append the parameters --no-ri --no-rdoc to the install command.<br />
# gem install rails --no-ri --no-rdoc<br />
<br />
===Updating gems===<br />
gem is a package manager for Ruby modules, somewhat like pacman is to Arch Linux. To update your gems, simply run:<br />
# gem update<br />
<br />
== Installing via the AUR ==<br />
{{Warning | This is not recommended, as this might not include the latest Rails version, and additional dependencies may be introduced that may require you to run "gem install" anyway. }}<br />
There is a [http://aur.archlinux.org/packages.php?ID=14624 Rails package] available in the [[AUR]]. Note that this is not in an official repository, so you'll need to build it manually with makepkg or using an [[AUR Helpers|AUR helper]].<br />
<br />
== Configuration ==<br />
Rails is bundled with a basic HTTP server called WeBrick. You can create a test application to test it. First, create an application with the rails command :<br />
<br />
# rails testapp_name<br />
<br />
Next start the web server. It listens on port 3000 by default :<br />
<br />
# cd testapp_name<br />
# ruby script/server <br />
<br />
Finally open your server address on port 3000 in your web browser. For example, if you're working on your local machine, visit http://localhost:3000/<br />
<br />
You should see a test page titled "Welcome aboard".<br />
<br />
== Web servers ==<br />
While the default Ruby On Rails HTTP server (WeBrick) is convenient for basic development it is not recommended for production use. Here are some suitable alternatives:<br />
<br />
=== Mongrel ===<br />
Mongrel is a drop-in replacement for WeBrick, that can be run in precisely the same way, but offers better performance.<br />
<br />
First install the Mongrel gem:<br />
# gem install mongrel<br />
<br />
Then start it using:<br />
# mongrel_rails start<br />
<br />
Alternatively, you can just run "ruby script/server" again, as it replaces WeBrick by default.<br />
<br />
Generally, Mongrel is used in a production environment by running multiple instances of mongrel_rails, which are load-balanced behind an [[nginx]] or [[Apache]] reverse proxy. However, you might find Phusion Passenger (see below) a much simpler solution for running a production environment.<br />
<br />
=== Phusion Passenger (Recommended for production) ===<br />
[http://www.modrails.com/ Passenger] also known as {{Filename|mod_rails}} is a module available for [[NginX]] and [[Apache]], that greatly simplifies setting up a Rails server environment.<br />
<br />
Start by installing the Passenger gem:<br />
# gem install passenger<br />
<br />
If you are aiming to use [[Apache]] with Passenger, install the following package from the AUR<br />
# passenger-install-apache2-module<br />
<br />
For [[NginX]]:<br />
# passenger-install-nginx-module<br />
<br />
The installer will provide you with any additional information regarding the installation (such as installing additional libraries).<br />
<br />
{{Note|See [[NginX#Ruby_.28Rack-based_and_Rails.29]] for more information on configuring a Rails/ Passenger/NginX web stack.}}<br />
<br />
== Databases ==<br />
Most web applications will need to interact with some sort of database. ActiveRecord (the ORM used by Rails to provide database abstraction) supports several database vendors, the most popular of which are MySQL, SQLite, and PostgreSQL.<br />
<br />
=== SQLite ===<br />
SQLite is the default lightweight database for Ruby on Rails. To enable SQLite, simply install ruby-sqlite3<br />
# pacman -S ruby-sqlite3<br />
<br />
=== MySQL 5+ ===<br />
{{Box Note | You must first install MySQL with the appropriate headers in /usr/include (just pacman -S mysql is fine) before attempting to install the Ruby MySQL extensions }}<br />
<br />
Please refer to [[MySQL]] on how to install MySQL Server.<br />
<br />
A gem with some native extensions is required, probably best installed as root:<br />
# sudo gem install mysql<br />
<br />
You can generate a rails application configured for MySQL by using the -d parameter :<br />
# rails -d mysql testapp_name<br />
<br />
You then need to edit config/database.yml. Rails uses different databases for development, testing, production and other environments. Here's an example development configuration for MySQL running on localhost:<br />
<br />
development:<br />
adapter: mysql<br />
database: my_application_database<br />
username: development<br />
password: my_secret_password<br />
<br />
Note that you don't have to actually create the database using a MySQL, as this can be done via Rails with :<br />
# rake db:create<br />
<br />
If no errors are shown, then your database has been created and Rails can talk to your MySQL database.<br />
<br />
== See also ==<br />
* [[Ruby]]<br />
* [[nginx]]<br />
* [[LAMP]]<br />
* [[MySQL]]<br />
<br />
== References ==<br />
* Ruby on Rails http://rubyonrails.org/download<br />
* Mongrel http://mongrel.rubyforge.org/</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106603Nginx2010-05-19T07:28:18Z<p>Sirupsen: /* Method two (Third-party-wrapper) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:<br />
<br />
{{Note|You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from [http://php-fpm.anight.org/ php-fpm website]}}<br />
<br />
{{Note|Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See [[Nginx#Troubleshooting]]}}<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====The browser results in: '''no input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106602Nginx2010-05-19T07:26:52Z<p>Sirupsen: /* Troubleshooting */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====The browser results in: '''no input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106601Nginx2010-05-19T07:26:37Z<p>Sirupsen: /* Security */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====The browser results in: '''no input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106600Nginx2010-05-19T07:26:07Z<p>Sirupsen: /* Tips */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
====The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later.====<br />
This is because the FastCGI server has not been started. <br />
<br />
====The browser results in: '''no input file specified====<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106599Nginx2010-05-19T07:24:15Z<p>Sirupsen: /* Ruby (Rack-based and Rails) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel], [http://code.macournoyer.com/thin/ Thin] and [http://unicorn.bogomips.org/ Unicorn].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ready to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
{{Note|With Passenger you are also able to run other Rack-based applications, including Sinatra. Note, however, that these requires a {{Filename|config.ru}} file in the source directory.}}<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106598RVM2010-05-19T07:19:56Z<p>Sirupsen: /* Ruby 1.8.x won't compile with RVM */</p>
<hr />
<div>[http://rvm.beginrescueend.com/ RVM] (Ruby Version Manager) is a command line tool which allows us to easily install, manage and work with multiple [[Ruby]] environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
# gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. {{Filename|~/.bashrc}}) And then running:<br />
<br />
# rvm-install<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [http://aur.archlinux.org/packages.php?ID=30221 Ruby1.8 package in the AUR] has solved this issue with a patch included in the package. Simply [http://aur.archlinux.org/packages.php?ID=30221 download the package from AUR], download the [ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.7-p249.tar.bz2 Ruby 1.8.7 source], apply the patch contained in the package from the AUR, once the source has been patched, archive the patched source to a tar.gz file, and put this file into: {{Filename|~/.rvm/archives/ruby.1.8.7-p249.tar.gz}}<br />
<br />
Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106597RVM2010-05-19T07:19:25Z<p>Sirupsen: /* Installing RVM */</p>
<hr />
<div>[http://rvm.beginrescueend.com/ RVM] (Ruby Version Manager) is a command line tool which allows us to easily install, manage and work with multiple [[Ruby]] environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
# gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. {{Filename|~/.bashrc}}) And then running:<br />
<br />
# rvm-install<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [http://aur.archlinux.org/packages.php?ID=30221 Ruby1.8 package in the AUR] has solved this issue with a patch included in the package. Simply [http://aur.archlinux.org/packages.php?ID=30221 download the package from AUR], download the [ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.7-p249.tar.bz2 Ruby 1.8.7 source], apply the patch contained in the package from the AUR, once the source has been patched, archive the patched source to a tar.gz file, and put this file into: <br />
<br />
~/.rvm/archives/ruby.1.8.7-p249.tar.gz. <br />
<br />
Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106596RVM2010-05-19T07:18:10Z<p>Sirupsen: /* Ruby Version Manager (RVM) */</p>
<hr />
<div>[http://rvm.beginrescueend.com/ RVM] (Ruby Version Manager) is a command line tool which allows us to easily install, manage and work with multiple [[Ruby]] environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
$ gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. ~/.bashrc) And then running:<br />
<br />
$ rvm-install<br />
<br />
'''Note: ''' Above commands ''may'' have to be run as the superuser.<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [http://aur.archlinux.org/packages.php?ID=30221 Ruby1.8 package in the AUR] has solved this issue with a patch included in the package. Simply [http://aur.archlinux.org/packages.php?ID=30221 download the package from AUR], download the [ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.7-p249.tar.bz2 Ruby 1.8.7 source], apply the patch contained in the package from the AUR, once the source has been patched, archive the patched source to a tar.gz file, and put this file into: <br />
<br />
~/.rvm/archives/ruby.1.8.7-p249.tar.gz. <br />
<br />
Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Skype&diff=106595Skype2010-05-19T07:14:08Z<p>Sirupsen: /* Low sound in Skype, but works everywhere else */</p>
<hr />
<div>[[Category:Audio/Video (English)]]<br />
[[Category:Internet and Email (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|Skype}}<br />
<br />
===Installing Skype===<br />
To install skype, you need to have the community repository uncommented in /etc/pacman.conf<br />
<br />
#[community]<br />
# Add your preferred servers here, they will be used first<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
becomes:<br />
[community]<br />
# Add your preferred servers here, they will be used first<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
Now use pacman to install Skype:<br />
# pacman -S skype<br />
<br />
====64-bit Installation====<br />
Because skype is only offered as a 32-bit binary, there is no official arch package for x86_64. However, you can install bin32-skype from AUR instead, or you can install it manually following these commands:<br />
<br />
Create a temporary work directory:<br />
$ cd ~ && mkdir temp-skype-install<br />
Remove any previous versions of skype (not skype data): <br />
$ sudo rm -rf /usr/share/skype/ && sudo rm -rf /usr/bin/skype<br />
Get skype: <br />
$ wget http://www.skype.com/go/getskype-linux-beta-static <br />
$ tar xvf skype_static-2.1.0.81.tar.bz2 && cd skype_static-2.1.0.81 <br />
Install skype:<br />
$ sudo mkdir /usr/share/skype/ <br />
$ sudo mv avatars/ /usr/share/skype/ <br />
$ sudo mv icons/ /usr/share/skype/ <br />
$ sudo mv lang/ /usr/share/skype/ <br />
$ sudo mv sounds/ /usr/share/skype/ <br />
$ sudo mv skype /usr/bin/ <br />
Remove temporary work directory:<br />
$ cd ~ && rm -rf temp-skype-install<br />
<br />
You can find an user submitted script that makes all the above automatically:<br />
$ wget http://tinyurl.com/arch-skype-install -O- | sh<br />
<br />
{{Note|If you don't have them installed, you need the 32bit libraries available in pacman's repositories: # '''pacman -S lib32'''}}<br />
<br />
===Skype Sound===<br />
Recent versions of Skype (2.0+) have native [[ALSA]] Support, ealier versions support only the deprecated [[OSS]].<br />
<br />
====Skype ALSA Sound (2.0+)====<br />
Sound should work out of the box, if not you can select a sound device to use in skype options.<br />
if you have problems with skype blocking your sound device, you only need to add the following to your ~/.asoundrc<br />
pcm.dmixout {<br />
# Just pass this on to the system dmix<br />
type plug<br />
slave {<br />
pcm "dmix"<br />
}<br />
}<br />
then you can start skype as normal, go to the audio options and select dmixout as your speaker- and ringingdevice.<br />
<br />
====Skype-OSS Sound (Pre-2.0)====<br />
if you have a recent version of skype, this will not work and is not needed, look at the "important notes" on start of this page.<br />
Option B is preferred over other options.<br />
With option B you can use skype AND let other programs play sound too.<br />
With option C you can do that too, but option B is way easier to set up.<br />
<br />
=====A. With OSS or Kernel OSS emulation for ALSA=====<br />
Start "skype" and make sure no other program is using your soundcard.<br />
If you want to use skype AND let another program play sound too, look at option B instead.<br />
<br />
=====B. Making ALSA + dMix work for Skype=====<br />
First of all, we need to install the alsa-oss package from pacman:<br />
# pacman -S alsa-oss<br />
<br />
Add the following to "~/.asoundrc" (the file ".asoundrc" in your home directory)<br />
If the file doesn't exist yet, just create it!<br />
<br />
Many thanks to Lorenzo Colitti for figuring this out!<br />
<br />
# .asoundrc to use skype at the same time as other audio apps like xmms<br />
#<br />
# Successfully tested on an IBM x40 with i810_audio using Linux 2.6.15 and<br />
# Debian unstable with skype 1.2.0.18-API. No sound daemons (asound, esd, etc.)<br />
# running. However, YMMV.<br />
#<br />
# For background, see:<br />
#<br />
# https://bugtrack.alsa-project.org/alsa-bug/view.php?id=1228<br />
# https://bugtrack.alsa-project.org/alsa-bug/view.php?id=1224<br />
#<br />
# (C) 2006-06-03 Lorenzo Colitti - http://www.colitti.com/lorenzo/<br />
# Licensed under the GPLv2 or later<br />
<br />
pcm.skype {<br />
type asym<br />
playback.pcm "skypeout"<br />
capture.pcm "skypein"<br />
}<br />
<br />
pcm.skypein {<br />
# Convert from 8-bit unsigned mono (default format set by aoss when<br />
# /dev/dsp is opened) to 16-bit signed stereo (expected by dsnoop)<br />
#<br />
# We can't just use a "plug" plugin because although the open will<br />
# succeed, the buffer sizes will be wrong and we'll hear no sound at<br />
# all.<br />
type route<br />
slave {<br />
pcm "skypedsnoop"<br />
format S16_LE<br />
}<br />
ttable {<br />
0 {0 0.5}<br />
1 {0 0.5}<br />
}<br />
}<br />
<br />
pcm.skypeout {<br />
# Just pass this on to the system dmix<br />
type plug<br />
slave {<br />
pcm "dmix"<br />
}<br />
}<br />
<br />
pcm.skypedsnoop {<br />
type dsnoop<br />
ipc_key 1133<br />
slave {<br />
# "Magic" buffer values to get skype audio to work<br />
# If these are not set, opening /dev/dsp succeeds but no sound<br />
# will be heard. According to the alsa developers this is due<br />
# to skype abusing the OSS API.<br />
pcm "hw:0,0"<br />
period_size 256<br />
periods 16<br />
buffer_size 16384<br />
}<br />
bindings {<br />
0 0<br />
}<br />
}<br />
<br />
If you get the error message :<br />
<br />
The dmix plugin supports only playback stream<br />
<br />
then add the following to .asoundrc :<br />
<br />
pcm.asymed {<br />
type asym<br />
playback.pcm "dmix"<br />
capture.pcm "dsnoop"<br />
}<br />
<br />
pcm.!default {<br />
type plug<br />
slave.pcm "asymed"<br />
}<br />
<br />
<br />
Now run skype in this way each time you want to use skype:<br />
ALSA_OSS_PCM_DEVICE="skype" aoss skype<br />
<br />
Optionally you can make a script to start skype:<br />
<br />
As root, create the file: '''/usr/bin/askype'''<br />
<br />
# Little script to run Skype correctly using the modified .asoundrc<br />
# See: http://wiki.archlinux.org/index.php/Skype for more information!<br />
#<br />
# Questions/Remarks: profox@debianbox.be<br />
<br />
ALSA_OSS_PCM_DEVICE="skype" aoss skype<br />
<br />
Now make sure every user is able to execute the file:<br />
# chmod a+x /usr/bin/askype<br />
<br />
You can also fix the menu entry so you can start Skype from the your window manager's menu:<br />
<br />
Edit the file: '''/usr/share/applications/skype.desktop'''<br />
<br />
[Desktop Entry]<br />
Name=Skype<br />
Comment=P2P software for high-quality voice communication<br />
Exec=askype<br />
Icon=skype.png<br />
Terminal=0<br />
Type=Application<br />
Encoding=UTF-8<br />
Categories=Network;Application;<br />
<br />
Sometimes it takes a while for Skype to start up,<br />
<br />
but once it's loaded it should work ok!<br />
<br />
=====C. Using OSS emulation with oss2jack=====<br />
oss2jack is another way to have OSS emulation without using ALSA directly. Instead, oss2jack creates a OSS device that forwards everything to JACK (JACK Audio Connection Kit), which in turn mixes, then outputs to the standard ALSA device. For more information on setting this up, please refer to [[Allow_multiple_programs_to_play_sound_at_once#ALSA_with_oss2jack]].<br />
<br />
<br />
===Problems===<br />
<br />
====I can receive multiple audio streams, but I can only send one====<br />
Skype can send and receive audio and I still hear other sounds playing from other applications, but I can't record my microphone with other applications. That is because Skype or aoss blocks the audio input for itself.<br />
<br />
====No video with GSPCA webcams====<br />
Install libv4l, the userspace video for linux libary, and run skype with<br />
<br />
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype<br />
<br />
to start skype with v4l1 compatibility.<br />
<br />
For 64-bit install lib32-libv4l and run Skype with<br />
<br />
LD_PRELOAD=/opt/lib32/usr/lib/libv4l/v4l1compat.so skype<br />
<br />
====Skype doesn't use my GTK theme, even though other QT apps do====<br />
Run skype using the following command:<br />
<br />
/usr/bin/skype --disable-cleanlooks -style GTK<br />
<br />
If you wish menus within desktop environments to load skype with a GTK theme by default then modify the 'Exec' line of /usr/share/applications/skype.desktop so that it reads:<br />
<br />
Exec=/usr/bin/skype --disable-cleanlooks -style GTK<br />
<br />
Similarly if you have set skype to autostart then modify ~/.config/autostart/skype.desktop in the same way.<br />
<br />
====The microphone does not work====<br />
Just play with alsamixer. I needed to switch the Digital column from analog which is my jack input for mic to digital which is my microphone embeded into monitor.<br />
Also you can press tab to switch to Capture and press space to select a source.<br />
<br />
====Avatars are not shown in 64-bit====<br />
You need to run<br />
<br />
export QT_PLUGIN_PATH=$QT_PLUGIN_PATH:/opt/lib32/usr/lib/qt/plugins<br />
<br />
before starting Skype. Either you could add it to your .bashrc or you could use a script to execute it before running Skype. For example renaming /usr/bin/skype to /usr/bin/skype2 and add<br />
<br />
#! /bin/bash<br />
export QT_PLUGIN_PATH=$QT_PLUGIN_PATH:/opt/lib32/usr/lib/qt/plugins<br />
skype2<br />
<br />
as /usr/bin/skype. To have the variable available when you start your programms via starter application (for example gmrun), add the export line to the autostart config file of your window manager.<br />
<br />
====No incoming video stream====<br />
This might be related to Cairo dock, though i'm not sure.<br />
You need to start skype with:<br />
<br />
<code>export XLIB_SKIP_ARGB_VISUALS=1 && skype</code><br />
<br />
====Low sound in Skype, but works everywhere else====<br />
If you are sure your microphone is configured correct in Alsa (try recording with a 3rd-party-utility to determent whether it's an Alsa, or Skype problem), it's most likely because Skype is controlling your volume levels. Simply disable this feature in the voice settings page in the Skype configuration window.<br />
<br />
===Questions or Remarks===<br />
You are free to edit this wiki entry if you have anything to add or change, and for more questions or remarks you can mail me ([[User:ProfoX|profoX]]) at profox@debianbox.be</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Skype&diff=106594Skype2010-05-19T07:13:22Z<p>Sirupsen: /* Problems */</p>
<hr />
<div>[[Category:Audio/Video (English)]]<br />
[[Category:Internet and Email (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|Skype}}<br />
<br />
===Installing Skype===<br />
To install skype, you need to have the community repository uncommented in /etc/pacman.conf<br />
<br />
#[community]<br />
# Add your preferred servers here, they will be used first<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
becomes:<br />
[community]<br />
# Add your preferred servers here, they will be used first<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
Now use pacman to install Skype:<br />
# pacman -S skype<br />
<br />
====64-bit Installation====<br />
Because skype is only offered as a 32-bit binary, there is no official arch package for x86_64. However, you can install bin32-skype from AUR instead, or you can install it manually following these commands:<br />
<br />
Create a temporary work directory:<br />
$ cd ~ && mkdir temp-skype-install<br />
Remove any previous versions of skype (not skype data): <br />
$ sudo rm -rf /usr/share/skype/ && sudo rm -rf /usr/bin/skype<br />
Get skype: <br />
$ wget http://www.skype.com/go/getskype-linux-beta-static <br />
$ tar xvf skype_static-2.1.0.81.tar.bz2 && cd skype_static-2.1.0.81 <br />
Install skype:<br />
$ sudo mkdir /usr/share/skype/ <br />
$ sudo mv avatars/ /usr/share/skype/ <br />
$ sudo mv icons/ /usr/share/skype/ <br />
$ sudo mv lang/ /usr/share/skype/ <br />
$ sudo mv sounds/ /usr/share/skype/ <br />
$ sudo mv skype /usr/bin/ <br />
Remove temporary work directory:<br />
$ cd ~ && rm -rf temp-skype-install<br />
<br />
You can find an user submitted script that makes all the above automatically:<br />
$ wget http://tinyurl.com/arch-skype-install -O- | sh<br />
<br />
{{Note|If you don't have them installed, you need the 32bit libraries available in pacman's repositories: # '''pacman -S lib32'''}}<br />
<br />
===Skype Sound===<br />
Recent versions of Skype (2.0+) have native [[ALSA]] Support, ealier versions support only the deprecated [[OSS]].<br />
<br />
====Skype ALSA Sound (2.0+)====<br />
Sound should work out of the box, if not you can select a sound device to use in skype options.<br />
if you have problems with skype blocking your sound device, you only need to add the following to your ~/.asoundrc<br />
pcm.dmixout {<br />
# Just pass this on to the system dmix<br />
type plug<br />
slave {<br />
pcm "dmix"<br />
}<br />
}<br />
then you can start skype as normal, go to the audio options and select dmixout as your speaker- and ringingdevice.<br />
<br />
====Skype-OSS Sound (Pre-2.0)====<br />
if you have a recent version of skype, this will not work and is not needed, look at the "important notes" on start of this page.<br />
Option B is preferred over other options.<br />
With option B you can use skype AND let other programs play sound too.<br />
With option C you can do that too, but option B is way easier to set up.<br />
<br />
=====A. With OSS or Kernel OSS emulation for ALSA=====<br />
Start "skype" and make sure no other program is using your soundcard.<br />
If you want to use skype AND let another program play sound too, look at option B instead.<br />
<br />
=====B. Making ALSA + dMix work for Skype=====<br />
First of all, we need to install the alsa-oss package from pacman:<br />
# pacman -S alsa-oss<br />
<br />
Add the following to "~/.asoundrc" (the file ".asoundrc" in your home directory)<br />
If the file doesn't exist yet, just create it!<br />
<br />
Many thanks to Lorenzo Colitti for figuring this out!<br />
<br />
# .asoundrc to use skype at the same time as other audio apps like xmms<br />
#<br />
# Successfully tested on an IBM x40 with i810_audio using Linux 2.6.15 and<br />
# Debian unstable with skype 1.2.0.18-API. No sound daemons (asound, esd, etc.)<br />
# running. However, YMMV.<br />
#<br />
# For background, see:<br />
#<br />
# https://bugtrack.alsa-project.org/alsa-bug/view.php?id=1228<br />
# https://bugtrack.alsa-project.org/alsa-bug/view.php?id=1224<br />
#<br />
# (C) 2006-06-03 Lorenzo Colitti - http://www.colitti.com/lorenzo/<br />
# Licensed under the GPLv2 or later<br />
<br />
pcm.skype {<br />
type asym<br />
playback.pcm "skypeout"<br />
capture.pcm "skypein"<br />
}<br />
<br />
pcm.skypein {<br />
# Convert from 8-bit unsigned mono (default format set by aoss when<br />
# /dev/dsp is opened) to 16-bit signed stereo (expected by dsnoop)<br />
#<br />
# We can't just use a "plug" plugin because although the open will<br />
# succeed, the buffer sizes will be wrong and we'll hear no sound at<br />
# all.<br />
type route<br />
slave {<br />
pcm "skypedsnoop"<br />
format S16_LE<br />
}<br />
ttable {<br />
0 {0 0.5}<br />
1 {0 0.5}<br />
}<br />
}<br />
<br />
pcm.skypeout {<br />
# Just pass this on to the system dmix<br />
type plug<br />
slave {<br />
pcm "dmix"<br />
}<br />
}<br />
<br />
pcm.skypedsnoop {<br />
type dsnoop<br />
ipc_key 1133<br />
slave {<br />
# "Magic" buffer values to get skype audio to work<br />
# If these are not set, opening /dev/dsp succeeds but no sound<br />
# will be heard. According to the alsa developers this is due<br />
# to skype abusing the OSS API.<br />
pcm "hw:0,0"<br />
period_size 256<br />
periods 16<br />
buffer_size 16384<br />
}<br />
bindings {<br />
0 0<br />
}<br />
}<br />
<br />
If you get the error message :<br />
<br />
The dmix plugin supports only playback stream<br />
<br />
then add the following to .asoundrc :<br />
<br />
pcm.asymed {<br />
type asym<br />
playback.pcm "dmix"<br />
capture.pcm "dsnoop"<br />
}<br />
<br />
pcm.!default {<br />
type plug<br />
slave.pcm "asymed"<br />
}<br />
<br />
<br />
Now run skype in this way each time you want to use skype:<br />
ALSA_OSS_PCM_DEVICE="skype" aoss skype<br />
<br />
Optionally you can make a script to start skype:<br />
<br />
As root, create the file: '''/usr/bin/askype'''<br />
<br />
# Little script to run Skype correctly using the modified .asoundrc<br />
# See: http://wiki.archlinux.org/index.php/Skype for more information!<br />
#<br />
# Questions/Remarks: profox@debianbox.be<br />
<br />
ALSA_OSS_PCM_DEVICE="skype" aoss skype<br />
<br />
Now make sure every user is able to execute the file:<br />
# chmod a+x /usr/bin/askype<br />
<br />
You can also fix the menu entry so you can start Skype from the your window manager's menu:<br />
<br />
Edit the file: '''/usr/share/applications/skype.desktop'''<br />
<br />
[Desktop Entry]<br />
Name=Skype<br />
Comment=P2P software for high-quality voice communication<br />
Exec=askype<br />
Icon=skype.png<br />
Terminal=0<br />
Type=Application<br />
Encoding=UTF-8<br />
Categories=Network;Application;<br />
<br />
Sometimes it takes a while for Skype to start up,<br />
<br />
but once it's loaded it should work ok!<br />
<br />
=====C. Using OSS emulation with oss2jack=====<br />
oss2jack is another way to have OSS emulation without using ALSA directly. Instead, oss2jack creates a OSS device that forwards everything to JACK (JACK Audio Connection Kit), which in turn mixes, then outputs to the standard ALSA device. For more information on setting this up, please refer to [[Allow_multiple_programs_to_play_sound_at_once#ALSA_with_oss2jack]].<br />
<br />
<br />
===Problems===<br />
<br />
====I can receive multiple audio streams, but I can only send one====<br />
Skype can send and receive audio and I still hear other sounds playing from other applications, but I can't record my microphone with other applications. That is because Skype or aoss blocks the audio input for itself.<br />
<br />
====No video with GSPCA webcams====<br />
Install libv4l, the userspace video for linux libary, and run skype with<br />
<br />
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype<br />
<br />
to start skype with v4l1 compatibility.<br />
<br />
For 64-bit install lib32-libv4l and run Skype with<br />
<br />
LD_PRELOAD=/opt/lib32/usr/lib/libv4l/v4l1compat.so skype<br />
<br />
====Skype doesn't use my GTK theme, even though other QT apps do====<br />
Run skype using the following command:<br />
<br />
/usr/bin/skype --disable-cleanlooks -style GTK<br />
<br />
If you wish menus within desktop environments to load skype with a GTK theme by default then modify the 'Exec' line of /usr/share/applications/skype.desktop so that it reads:<br />
<br />
Exec=/usr/bin/skype --disable-cleanlooks -style GTK<br />
<br />
Similarly if you have set skype to autostart then modify ~/.config/autostart/skype.desktop in the same way.<br />
<br />
====The microphone does not work====<br />
Just play with alsamixer. I needed to switch the Digital column from analog which is my jack input for mic to digital which is my microphone embeded into monitor.<br />
Also you can press tab to switch to Capture and press space to select a source.<br />
<br />
====Avatars are not shown in 64-bit====<br />
You need to run<br />
<br />
export QT_PLUGIN_PATH=$QT_PLUGIN_PATH:/opt/lib32/usr/lib/qt/plugins<br />
<br />
before starting Skype. Either you could add it to your .bashrc or you could use a script to execute it before running Skype. For example renaming /usr/bin/skype to /usr/bin/skype2 and add<br />
<br />
#! /bin/bash<br />
export QT_PLUGIN_PATH=$QT_PLUGIN_PATH:/opt/lib32/usr/lib/qt/plugins<br />
skype2<br />
<br />
as /usr/bin/skype. To have the variable available when you start your programms via starter application (for example gmrun), add the export line to the autostart config file of your window manager.<br />
<br />
====No incoming video stream====<br />
This might be related to Cairo dock, though i'm not sure.<br />
You need to start skype with:<br />
<br />
<code>export XLIB_SKIP_ARGB_VISUALS=1 && skype</code><br />
<br />
====Low sound in Skype, but works everywhere else====<br />
If you are sure your microphone is configured correct in Alsa (try recording with a 3rd-party-utility to determent whether it's an Alsa, or Skype problem), it's most likely because Skype is controlling you volume levels. Simply disable this feature in the voice settings page in the Skype configuration window.<br />
<br />
===Questions or Remarks===<br />
You are free to edit this wiki entry if you have anything to add or change, and for more questions or remarks you can mail me ([[User:ProfoX|profoX]]) at profox@debianbox.be</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106593Nginx2010-05-19T07:09:44Z<p>Sirupsen: /* Setting up Nginx and Passenger */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel] and [http://code.macournoyer.com/thin/ Thin].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ''basically'' read to go.<br />
<br />
For further information on setting up Nginx with Ruby, read the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106592Nginx2010-05-19T07:08:15Z<p>Sirupsen: /* Configuring */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel] and [http://code.macournoyer.com/thin/ Thin].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ''basically'' read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106574RVM2010-05-18T20:19:28Z<p>Sirupsen: /* Ruby Version Manager (RVM) */</p>
<hr />
<div>== Ruby Version Manager (RVM) ==<br />
<br />
[http://rvm.beginrescueend.com/ RVM] is a command line tool which allows us to easily install, manage and work with multiple [[Ruby]] environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
$ gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. ~/.bashrc) And then running:<br />
<br />
$ rvm-install<br />
<br />
'''Note: ''' Above commands ''may'' have to be run as the superuser.<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [http://aur.archlinux.org/packages.php?ID=30221 Ruby1.8 package in the AUR] has solved this issue with a patch included in the package. Simply [http://aur.archlinux.org/packages.php?ID=30221 download the package from AUR], download the [ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.7-p249.tar.bz2 Ruby 1.8.7 source], apply the patch contained in the package from the AUR, once the source has been patched, archive the patched source to a tar.gz file, and put this file into: <br />
<br />
~/.rvm/archives/ruby.1.8.7-p249.tar.gz. <br />
<br />
Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby&diff=106565Ruby2010-05-18T18:30:45Z<p>Sirupsen: /* Bundler */</p>
<hr />
<div>[[Category:Development (English)]]<br />
Ruby is a dynamic, interpreted, open source programming language with a focus on simplicity and productivity.<br />
<br />
== Installing Ruby ==<br />
The version of Ruby you need to install depends on your requirements, as not all 3rd party code is compatible with all versions. Here's a summary of the versions below and how to get them:<br />
<br />
=== Ruby 1.9 (Development) ===<br />
'''Summary:''' Use Ruby 1.9 for a new new Rails project, or when you're sure all your required gems are supported by Ruby 1.9<br />
<br />
Pros:<br />
* Vastly improved performance over 1.8<br />
* New features for concurrency such as fibers.<br />
* Various other language improvements, such as an improved CSV parser.<br />
<br />
Cons:<br />
* Not compatible with many older gems (and Ruby On Rails versions prior to 2.3)<br />
* Changes in the language might cause older Ruby code not to run, or exhibit unexpected bugs.<br />
<br />
{{Box Note | Visit http://isitruby19.com/ to determine if the gems/modules you require are compatible with Ruby 1.9 }}<br />
<br />
To install Ruby 1.9, simply run:<br />
# pacman -S ruby<br />
<br />
Ruby 1.9 also includes RubyGems (detailed below), so you can easily update to the latest RubyGems using:<br />
# gem update --system<br />
<br />
=== Ruby 1.8.7 (Stable) ===<br />
'''Summary:''' Use Ruby 1.8.7 if you're unsure, or are not working on any legacy systems.<br />
<br />
Pros:<br />
* Latest version of the 1.8 branch, capable of running most if not all recently updated gems and Ruby On Rails<br />
<br />
Cons:<br />
* Introduces certain breaking changes from 1.8.6, which causes older lesser-maintained gems and Rails prior to 2.0 not to work without "monkey patching".<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=30221 ruby1.8] from the [[AUR]].<br />
<br />
RubyGems is not included with the ruby1.8 package, so install [http://aur.archlinux.org/packages.php?ID=30224 rubygems1.8] from the [[AUR]].<br />
<br />
=== Ruby 1.8.6 (Legacy) ===<br />
'''Summary:''' Use Ruby 1.8.6 if you are working on old project, older version of Rails (especially < 2.0), or simply want the least possible issues.<br />
<br />
Pros:<br />
* Compatible with just about anything <br />
<br />
Cons:<br />
* Missing some performance and language enhancements from 1.8.7<br />
* Support might be dropped with Rails 3.0 (in Beta at the time of writing)<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=36898 ruby1.8.6-legacy] from the [[AUR]]. <br />
<br />
RubyGems is not included with the ruby1.8.6-legacy package, so install [http://aur.archlinux.org/packages.php?ID=33312 rubygems] from the [[AUR]].<br />
<br />
{{Box Note | This package will replace the official "ruby" package, as installing both Ruby 1.8 and 1.9 while possible, can cause erratic behaviour of some 3rd party code }}<br />
<br />
=== Multiple versions ===<br />
If you want to run multiple versions on the same system (e.g. '''1.9.1''' and '''1.8.7'''), the easiest way is to use [[RVM]].<br />
<br />
== RubyGems ==<br />
''gem'' is the package manager of sorts for Ruby modules (called Gems), somewhat comparable to what pacman is to Arch Linux. The ''gem'' command will be installed if you followed the installation instructions above.<br />
<br />
=== Running as root ===<br />
When running gem as root, gems will be installed for everyone on the machine. This has the advantage of simplicity and is the most reliable method, but updating or installing gems without everyone's knowledge (like on a shared server) might cause Ruby applications to break.<br />
<br />
When not running gem as root, the gems will be installed into ~/.gem and not affect anyone else, although it might be worth noting that not all gems are happy to be installed in this way and might insist on being installed by root (especially if they have native extensions).<br />
<br />
[[Ruby#Bundler|Bundler]] solves these problems to some extent by packaging gems into your application. See the section below on using bundler.<br />
<br />
=== Updating RubyGems ===<br />
# gem update --system<br />
<br />
=== Installing a gem ===<br />
This example installs the MySQL ruby gem:<br />
# gem install mysql<br />
<br />
The process can be speeded up somewhat if you don't need local documentation:<br />
# gem install mysql --no-rdoc --no-ri<br />
<br />
The gem will now be downloaded, compiled if necessary, and installed.<br />
<br />
=== Bundler ===<br />
[http://github.com/carlhuda/bundler Bundler] installs gems (including those with native extensions) directly into your application, which works very well for shared hosting and easy deployment of [[Ruby on Rails]] applications for example. Bundler also resolves dependencies as a whole, rather than individually like RubyGems, making things a lot easier.<br />
<br />
It might be a good idea to install bundler as a system-wide gem so everyone can use it:<br />
# gem install bundler<br />
<br />
To start a new bundle:<br />
# bundle init<br />
<br />
Then add your required gems into "Gemfile" in the current directory (created by bundle init):<br />
gem "rails", "2.3.4"<br />
gem "mysql"<br />
<br />
Finally, run the following to install your gems. They will all be installed locally into ~/.bundle, eliminating the need for root access:<br />
# bundle install<br />
<br />
== See also ==<br />
* [[Ruby On Rails]]<br />
<br />
== References ==<br />
* Ruby - ruby-lang.org/<br />
* Rubyforge - http://rubyforge.org<br />
* Bundler - http://github.com/carlhuda/bundler</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby&diff=106564Ruby2010-05-18T18:30:25Z<p>Sirupsen: /* Installing Ruby */</p>
<hr />
<div>[[Category:Development (English)]]<br />
Ruby is a dynamic, interpreted, open source programming language with a focus on simplicity and productivity.<br />
<br />
== Installing Ruby ==<br />
The version of Ruby you need to install depends on your requirements, as not all 3rd party code is compatible with all versions. Here's a summary of the versions below and how to get them:<br />
<br />
=== Ruby 1.9 (Development) ===<br />
'''Summary:''' Use Ruby 1.9 for a new new Rails project, or when you're sure all your required gems are supported by Ruby 1.9<br />
<br />
Pros:<br />
* Vastly improved performance over 1.8<br />
* New features for concurrency such as fibers.<br />
* Various other language improvements, such as an improved CSV parser.<br />
<br />
Cons:<br />
* Not compatible with many older gems (and Ruby On Rails versions prior to 2.3)<br />
* Changes in the language might cause older Ruby code not to run, or exhibit unexpected bugs.<br />
<br />
{{Box Note | Visit http://isitruby19.com/ to determine if the gems/modules you require are compatible with Ruby 1.9 }}<br />
<br />
To install Ruby 1.9, simply run:<br />
# pacman -S ruby<br />
<br />
Ruby 1.9 also includes RubyGems (detailed below), so you can easily update to the latest RubyGems using:<br />
# gem update --system<br />
<br />
=== Ruby 1.8.7 (Stable) ===<br />
'''Summary:''' Use Ruby 1.8.7 if you're unsure, or are not working on any legacy systems.<br />
<br />
Pros:<br />
* Latest version of the 1.8 branch, capable of running most if not all recently updated gems and Ruby On Rails<br />
<br />
Cons:<br />
* Introduces certain breaking changes from 1.8.6, which causes older lesser-maintained gems and Rails prior to 2.0 not to work without "monkey patching".<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=30221 ruby1.8] from the [[AUR]].<br />
<br />
RubyGems is not included with the ruby1.8 package, so install [http://aur.archlinux.org/packages.php?ID=30224 rubygems1.8] from the [[AUR]].<br />
<br />
=== Ruby 1.8.6 (Legacy) ===<br />
'''Summary:''' Use Ruby 1.8.6 if you are working on old project, older version of Rails (especially < 2.0), or simply want the least possible issues.<br />
<br />
Pros:<br />
* Compatible with just about anything <br />
<br />
Cons:<br />
* Missing some performance and language enhancements from 1.8.7<br />
* Support might be dropped with Rails 3.0 (in Beta at the time of writing)<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=36898 ruby1.8.6-legacy] from the [[AUR]]. <br />
<br />
RubyGems is not included with the ruby1.8.6-legacy package, so install [http://aur.archlinux.org/packages.php?ID=33312 rubygems] from the [[AUR]].<br />
<br />
{{Box Note | This package will replace the official "ruby" package, as installing both Ruby 1.8 and 1.9 while possible, can cause erratic behaviour of some 3rd party code }}<br />
<br />
=== Multiple versions ===<br />
If you want to run multiple versions on the same system (e.g. '''1.9.1''' and '''1.8.7'''), the easiest way is to use [[RVM]].<br />
<br />
== RubyGems ==<br />
''gem'' is the package manager of sorts for Ruby modules (called Gems), somewhat comparable to what pacman is to Arch Linux. The ''gem'' command will be installed if you followed the installation instructions above.<br />
<br />
=== Running as root ===<br />
When running gem as root, gems will be installed for everyone on the machine. This has the advantage of simplicity and is the most reliable method, but updating or installing gems without everyone's knowledge (like on a shared server) might cause Ruby applications to break.<br />
<br />
When not running gem as root, the gems will be installed into ~/.gem and not affect anyone else, although it might be worth noting that not all gems are happy to be installed in this way and might insist on being installed by root (especially if they have native extensions).<br />
<br />
[[Ruby#Bundler|Bundler]] solves these problems to some extent by packaging gems into your application. See the section below on using bundler.<br />
<br />
=== Updating RubyGems ===<br />
# gem update --system<br />
<br />
=== Installing a gem ===<br />
This example installs the MySQL ruby gem:<br />
# gem install mysql<br />
<br />
The process can be speeded up somewhat if you don't need local documentation:<br />
# gem install mysql --no-rdoc --no-ri<br />
<br />
The gem will now be downloaded, compiled if necessary, and installed.<br />
<br />
=== Bundler ===<br />
[http://github.com/carlhuda/bundler Bundler] installs gems (including those with native extensions) directly into your application, which works very well for shared hosting and easy deployment of [[Ruby On Rails]] applications for example. Bundler also resolves dependencies as a whole, rather than individually like RubyGems, making things a lot easier.<br />
<br />
It might be a good idea to install bundler as a system-wide gem so everyone can use it:<br />
# gem install bundler<br />
<br />
To start a new bundle:<br />
# bundle init<br />
<br />
Then add your required gems into "Gemfile" in the current directory (created by bundle init):<br />
gem "rails", "2.3.4"<br />
gem "mysql"<br />
<br />
Finally, run the following to install your gems. They will all be installed locally into ~/.bundle, eliminating the need for root access:<br />
# bundle install<br />
<br />
== See also ==<br />
* [[Ruby On Rails]]<br />
<br />
== References ==<br />
* Ruby - ruby-lang.org/<br />
* Rubyforge - http://rubyforge.org<br />
* Bundler - http://github.com/carlhuda/bundler</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Ruby&diff=106563Ruby2010-05-18T18:29:51Z<p>Sirupsen: /* Installing Ruby */</p>
<hr />
<div>[[Category:Development (English)]]<br />
Ruby is a dynamic, interpreted, open source programming language with a focus on simplicity and productivity.<br />
<br />
== Installing Ruby ==<br />
The version of Ruby you need to install depends on your requirements, as not all 3rd party code is compatible with all versions. Here's a summary of the versions below and how to get them:<br />
<br />
=== Ruby 1.9 (Development) ===<br />
'''Summary:''' Use Ruby 1.9 for a new new Rails project, or when you're sure all your required gems are supported by Ruby 1.9<br />
<br />
Pros:<br />
* Vastly improved performance over 1.8<br />
* New features for concurrency such as fibers.<br />
* Various other language improvements, such as an improved CSV parser.<br />
<br />
Cons:<br />
* Not compatible with many older gems (and Ruby On Rails versions prior to 2.3)<br />
* Changes in the language might cause older Ruby code not to run, or exhibit unexpected bugs.<br />
<br />
{{Box Note | Visit http://isitruby19.com/ to determine if the gems/modules you require are compatible with Ruby 1.9 }}<br />
<br />
To install Ruby 1.9, simply run:<br />
# pacman -S ruby<br />
<br />
Ruby 1.9 also includes RubyGems (detailed below), so you can easily update to the latest RubyGems using:<br />
# gem update --system<br />
<br />
=== Ruby 1.8.7 (Stable) ===<br />
'''Summary:''' Use Ruby 1.8.7 if you're unsure, or are not working on any legacy systems.<br />
<br />
Pros:<br />
* Latest version of the 1.8 branch, capable of running most if not all recently updated gems and Ruby On Rails<br />
<br />
Cons:<br />
* Introduces certain breaking changes from 1.8.6, which causes older lesser-maintained gems and Rails prior to 2.0 not to work without "monkey patching".<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=30221 ruby1.8] from the [[AUR]].<br />
<br />
RubyGems is not included with the ruby1.8 package, so install [http://aur.archlinux.org/packages.php?ID=30224 rubygems1.8] from the [[AUR]].<br />
<br />
=== Ruby 1.8.6 (Legacy) ===<br />
'''Summary:''' Use Ruby 1.8.6 if you are working on old project, older version of Rails (especially < 2.0), or simply want the least possible issues.<br />
<br />
Pros:<br />
* Compatible with just about anything <br />
<br />
Cons:<br />
* Missing some performance and language enhancements from 1.8.7<br />
* Support might be dropped with Rails 3.0 (in Beta at the time of writing)<br />
<br />
You can install [http://aur.archlinux.org/packages.php?ID=36898 ruby1.8.6-legacy] from the [[AUR]]. <br />
<br />
RubyGems is not included with the ruby1.8.6-legacy package, so install [http://aur.archlinux.org/packages.php?ID=33312 rubygems] from the [[AUR]].<br />
<br />
=== Multiple versions ===<br />
If you want to run multiple versions at the same time (e.g. '''1.9.1''' and '''1.8.7'''), the easiest way is to use [[RVM]].<br />
<br />
{{Box Note | This package will replace the official "ruby" package, as installing both Ruby 1.8 and 1.9 while possible, can cause erratic behaviour of some 3rd party code }}<br />
<br />
== RubyGems ==<br />
''gem'' is the package manager of sorts for Ruby modules (called Gems), somewhat comparable to what pacman is to Arch Linux. The ''gem'' command will be installed if you followed the installation instructions above.<br />
<br />
=== Running as root ===<br />
When running gem as root, gems will be installed for everyone on the machine. This has the advantage of simplicity and is the most reliable method, but updating or installing gems without everyone's knowledge (like on a shared server) might cause Ruby applications to break.<br />
<br />
When not running gem as root, the gems will be installed into ~/.gem and not affect anyone else, although it might be worth noting that not all gems are happy to be installed in this way and might insist on being installed by root (especially if they have native extensions).<br />
<br />
[[Ruby#Bundler|Bundler]] solves these problems to some extent by packaging gems into your application. See the section below on using bundler.<br />
<br />
=== Updating RubyGems ===<br />
# gem update --system<br />
<br />
=== Installing a gem ===<br />
This example installs the MySQL ruby gem:<br />
# gem install mysql<br />
<br />
The process can be speeded up somewhat if you don't need local documentation:<br />
# gem install mysql --no-rdoc --no-ri<br />
<br />
The gem will now be downloaded, compiled if necessary, and installed.<br />
<br />
=== Bundler ===<br />
[http://github.com/carlhuda/bundler Bundler] installs gems (including those with native extensions) directly into your application, which works very well for shared hosting and easy deployment of [[Ruby On Rails]] applications for example. Bundler also resolves dependencies as a whole, rather than individually like RubyGems, making things a lot easier.<br />
<br />
It might be a good idea to install bundler as a system-wide gem so everyone can use it:<br />
# gem install bundler<br />
<br />
To start a new bundle:<br />
# bundle init<br />
<br />
Then add your required gems into "Gemfile" in the current directory (created by bundle init):<br />
gem "rails", "2.3.4"<br />
gem "mysql"<br />
<br />
Finally, run the following to install your gems. They will all be installed locally into ~/.bundle, eliminating the need for root access:<br />
# bundle install<br />
<br />
== See also ==<br />
* [[Ruby On Rails]]<br />
<br />
== References ==<br />
* Ruby - ruby-lang.org/<br />
* Rubyforge - http://rubyforge.org<br />
* Bundler - http://github.com/carlhuda/bundler</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=World_of_Warcraft&diff=106562World of Warcraft2010-05-18T18:27:21Z<p>Sirupsen: /* Downloading and installing via Blizzard's client */</p>
<hr />
<div>[[Category:Games and entertainment (English)]]<br />
[[Category:Wine (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{out of date}}<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|World of Warcraft}}<br />
{{i18n_links_end}}<br />
<br />
World of Warcraft (WoW) is a Massively Multiplayer Online Role-Playing Game (MMORPG) by Blizzard Entertainment taking place in the fictional world of Azeroth, the world that previous Blizzard titles in the Realtime Stategy (RTS) Warcraft series. For more information about the game itself, visit [http://www.worldofwarcraft.com/ the Official World of Warcraft website].<br />
<br />
This article will describe how install and run in on Arch Linux using [http://winehq.org/ Wine].<br />
<br />
Some of this information was provided by http://www.wowwiki.com/Linux/Wine which is the best general source of information on WoW on Wine.<br />
<br />
==Introduction==<br />
As Blizzard so kindly created World of Warcraft with OpenGL support, we don't need [http://www.transgaming.com/products_linux.php Transgaming's Cedega], which is a non-free version of Wine with better DirectX support. Wine has as good, or better, OpenGL support than Cedega, and doesn't cost you a penny. <br />
<br />
Running WoW is slightly more difficult than some other games with Wine, but still relatively easy. It's quite possible that you will need to patch Wine to work with WoW, however, even this process is rather simple with Arch. The following guide will explain it all, step by step.<br />
<br />
If you do choose to purchase Cedega, which runs some games that Wine does not, for example, Guild Wars, the process is almost identical. I use Cedega myself because Wine currently doesn't cope with my Wireless USB keyboard well.<br />
<br />
==Installing Wine==<br />
<br />
Wine now no longer requires it's own special "World of Warcraft" version. The one in the repositories works fine (currently 0.9.38.1). Install both wine and unzip, which you will need later.<br />
<br />
pacman -S unzip wine<br />
<br />
==Installing Cedega==<br />
<br />
Cedega 6.01 is available in the AUR. To get the cedega program you will need to subscribe to Transgaming ; this currently costs about £3 per month. <br />
<br />
You also need dbus-python, which isn't a dependency of Cedega.<br />
<br />
pacman -S dbus-python<br />
<br />
==Installing the Game==<br />
There are five options for installing World of Warcraft. <br />
<br />
===Downloading and installing via Blizzard's client===<br />
<br />
The most straightforward way of installing World of Warcraft on Linux is usually this method, while it may not be the fastest. On slower connections, however, you may not wish to use this method due to the fact that you will have to download the entire game, including patches.<br />
<br />
It is known to work with Wine 1.1.39 which can be downloaded off [http://www.winehq.org/ Wine's website] and compiled. However, you may wish to try with the newest version from the extra section, installed via Pacman like so:<br />
<br />
# pacman -S wine<br />
<br />
====Downloading the Client====<br />
<br />
First step is to download the client.<br />
European users can download it off the european World of Warcraft website [http://www.wow-europe.com/en/downloads/client/index.html here,] while people from the United States would probably want to download the [http://www.worldofwarcraft.com/downloads/wowclient-download.html US client.]<br />
<br />
====Installing the Game====<br />
<br />
Once the client is downloaded run the file with Wine:<br />
wine InstallWoW.exe<br />
<br />
A window will pop up asking you which product to install. I chose to install World of Warcraft, then World of Warcraft: The Burning Crusade, and finally World of Warcraft: Wrath of the Lich King, while I was unsure if just choosing the newest expansion would install the older ones, please confirm whether this is true or not.<br />
<br />
====Troubleshooting====<br />
<br />
=====Not able to agree to terms=====<br />
In some versions of Wine, you can not agree to the terms even though you scrolled down. Try to compile the latest Wine from source. Or use a version of wine it is known to work with, i.e. '''1.1.39''' (please add more here).<br />
<br />
=====Wine crashes while reading terms=====<br />
Wine crashes as soon as the terms which must be agreed to install the game opens. This is because the installer fetches the terms from a website somewhere, and therefore uses a browser implementation to show them. Wine's implementation of this is named [Gecko http://wiki.winehq.org/Gecko], and this must be installed in order for the installation to work!<br />
<br />
===Copying the CDs to a folder===<br />
<br />
This method's goal is to copy the 5 install CDs to a folder. This seems to solve problems with deciding whether a CD is mounted and needs changing or not ; I think this is a fundamental problem because Windows doesn't have the basic concept of mounting and unmounting drives.<br />
<br />
mkdir /mnt/temp<br />
cd /mnt/temp<br />
<br />
mount /mnt/cdrom<br />
cp -R /mnt/cdrom/* /mnt/temp<br />
umount /mnt/cdrom<br />
(repeat above for each of the 5 CDs)<br />
<br />
Then run the World of Warcraft Installer with :<br />
<br />
wine Installer.exe<br />
<br />
===Copying an Existing Installation===<br />
<br />
The third is to simply copy an exisiting WoW installation from a Windows drive to Linux. <br />
<br />
'''NOTE:''' If you do not alreay have Wine installed, or have not run World of Warcraft with Wine before, you should skip down to [[#Installing Wine]], then come back to this section. ''Please DO NOT SKIP this section unless you are absolutely sure you know what you are doing.''<br />
<br />
Copy the C:\Program Files\World of Warcraft directory from Windows to ~/.wine/drive_c/Program Files/World of Warcraft.<br />
<br />
Example (assuming your windows partition is mounted at <tt>/mnt/windows</tt> and you are in your home directory) (Quotes are needed because of the spaces in the file names):<br />
<br />
cp -R "/mnt/windows/Program Files/World of Warcraft" ".wine/drive_c/Program Files/World of Warcraft"<br />
<br />
This will ensure that Wine knows about your WoW and will be able to configure it properly, and also ensures that WoW won't notice it has even been moved at all.<br />
<br />
Now that you have WoW installed, skip down to [[#Post-Installation]].<br />
<br />
===New Installation from CD===<br />
'''NOTE:''' We will assume that your Wine CD-ROM drive is "D:\" for this guide. Please use the correct letter as set up in the [[#Installing Wine]] section.<br />
<br />
Insert the first CD, mount it, and start the installation with:<br />
<br />
wine "D:\Installer.exe"<br />
<br />
When it asks for the next cd, simply unmount your CD drive and mount the next CD. Make absolutely sure that you mount the CD before telling the installer to load the CD, or it may make the installation fail. If you have any issues installing using the CDs, please read the next section.<br />
<br />
The WoW installation uses all 5 CDs, so it will take a while. Go outside and get some fresh air while the CD loads, because soon you won't have any "free time". :P<br />
<br />
===New Installation from DVD===<br />
'''NOTE:''' Note that on some WoW DVD's the installer executable is hidden and you need to mount the disc with the 'unhide' option. To do this type in a terminal:<br />
mount -t iso9660 -o ro,unhide /dev/cdrom /media/cdrom/<br />
<br />
Insert first the DVD. If it will be mounted automatically - just unmount.<br />
<br />
# umount /media/dvd<br />
<br />
Now mount manually<br />
<br />
# mount -t iso9660 /dev/dvd0 /mnt/dvd<br />
<br />
Now you will find the Install.exe on the DVD<br />
<br />
~ wine /mnt/dvd/Installer.exe<br />
<br />
==Installing Patches==<br />
Now we will need to update WoW. As of today (1st July 2007), the latest version of WoW is 2.1.2.6803 . This will change over time, of course. The best place I have found to access the latest patches is http://www.wowwiki.com/Patch_mirrors<br />
<br />
I think the simplest way of updating World of Warcraft is to download the patches (links are at the Patch Wiki) and copy them into the working directory for World of Warcraft. I have had problems with the Blizzard Downloaders either not working at all, or working very slowly. If you download them, you can reuse them if you reinstall or have an accident.<br />
<br />
The current patches which are needed for 2.1.2.6803 are listed below <br />
<br />
WoW-1.12.0-enGB-patch.exe<br />
wow-1.12.x-to-2.0.1-engb-patch-3.zip<br />
WoW-2.1.0-enGB-patch.exe<br />
WoW-2.1.0.6692-to-2.1.0.6729-enGB-patch.exe<br />
WoW-2.1.0.6729-to-2.1.1.6739-enGB-patch.exe<br />
WoW-2.1.1.6739-to-2.1.2.6803-enGB-patch.exe<br />
<br />
I am British (pauses to sing "God Save the Queen"), so I use the enGB patches. There exist other patches for other versions of the game in the USA, France, Germany and Spain.<br />
<br />
When you have downloaded the files into their own folder for neatness, copy these patches into the World of Warcraft working directory (paulr is my user name, you will need to use yours)<br />
<br />
cp * /home/paulr/.wine/drive_c/Program\ Files/World\ of\ Warcraft/<br />
<br />
The 1.12.x patch needs to be unzipped into the working directory<br />
<br />
cd /home/paulr/.wine/drive_c/Program\ Files/World\ of\ Warcraft/<br />
unzip wow-1.12.x-to-2.0.1-engb-patch-3.zip<br />
<br />
The simplest way to install the patches seems to be to run World of Warcraft. It detects that you have downloaded the patches and doesn't do it again.<br />
<br />
cd /home/paulr/.wine/drive_c/Program\ Files/World\ of\ Warcraft/<br />
wine WoW.exe<br />
<br />
You have to keep going round 5 times, it does get a bit dull, but it's fairly reliable. Accept the offer to Install the Gecko renderer when it comes up on your first patch install.<br />
<br />
The original Wiki says you can install patches with Wine as follows:<br />
<br />
wine wow-VERSION-LANG-patch.exe<br />
<br />
I haven't tried this, so I can't say if this works, and I don't know how to install the zip file this way :) <br />
<br />
If the Launcher (it displays a little box with News and Play) seems to stop when downloading, close its window and re-run WoW.exe<br />
<br />
==Installing in Cedega==<br />
<br />
Installing in Cedega is done by running the program from the menus, selecting Install, typing "World of Warcraft" in the Game name, selecting the WoW profile, navigating to the Installer.exe file using browse, and then clicking continue.<br />
<br />
===Fixes for Cedega===<br />
<br />
On my Gnome system, Cedega will not run using Alsa, it is necessary to switch to OSS. <br />
<br />
The current version of Cedega requires you to edit the following file<br />
<br />
gedit .cedega/configuration_profiles/cedega_6.0.1 <br />
<br />
and add the following line to the [d3dgl] section<br />
<br />
"VertexShadersLevel" = "1.1" <br />
<br />
==Configuration==<br />
<br />
The World of Warcraft configuration file is kept in the WTF directory (do Blizzard have a sense of humour ?)<br />
<br />
Edit it with<br />
<br />
gedit WTF/Config.wtf<br />
<br />
===Using OpenGL===<br />
<br />
Add the following line which makes WoW run in OpenGL (hurrah !) instead of grotty old DirectX Mode (boo). <br />
<br />
SET gxApi "opengl"<br />
<br />
This is a REQUIREMENT for Wine, but is not required for Cedega.<br />
<br />
===Resolution and Colour depth===<br />
<br />
You can change the following two lines to set the default WoW resolution. I have a 19" Monitor so I can use the following.<br />
<br />
SET gxColorBits "24"<br />
SET gxResolution "1440x900"<br />
<br />
===Windowing===<br />
<br />
You can run in a Window by setting this, but I haven't tried it.<br />
<br />
SET gxWindow "1" <br />
<br />
===Sound Issues===<br />
<br />
====Configuring the Buffer====<br />
If the sound makes a horrendous racket with squeaks and white noise try :<br />
<br />
SET SoundOutputSystem "1" <br />
SET SoundBufferSize "100"<br />
<br />
====Stuttering or Static Sound====<br />
Run <tt>winecfg</tt>, and in the "Audio" tab, selected "OSS" as the sound driver, using "Standard" hardware acceleration and driver emulation enabled.<br />
<br />
You can also set WoW to run at a higher "nice level", which will usually improve sound performance (<tt>renice</tt> must be run as root):<br />
<br />
sudo renice -15 `pidof WoW.exe`<br />
<br />
==A customised version of Wine==<br />
If you wish to compile wine from source yourself, you will need to edit the Wine PKGBUILD.<br />
(Note that patching Wine with fixes for WoW is no longer necessary)<br />
<br />
First, update your ABS with this command:<br />
<br />
pacman -S cvsup<br />
abs<br />
<br />
Next, copy the Wine PKGBUILD to <tt>/var/abs/local/wine</tt>:<br />
<br />
cp -R /var/abs/extra/x11/wine /var/abs/local<br />
<br />
and edit the PKGBUILD so that it looks something like this:<br />
<br />
<pre># $Id: PKGBUILD,v 1.12 2006/04/04 17:10:07 tpowa Exp $<br />
# Maintainer: Dale Blount <dale@archlinux.org><br />
# Contributor: Matt Smith (Majik) <darkknight@helpdesk.zaz.net><br />
pkgname=wine<br />
pkgver=0.9.12<br />
pkgrel=1<br />
pkgdesc="Emulator of the Windows 3.x and Win32 APIs"<br />
url="http://www.winehq.com"<br />
# don't add arts, it's only a dep if configured<br />
depends=('x-server' 'libjpeg' 'libungif' 'alsa-lib' 'glut' 'openldap' 'libxslt' 'lcms' 'libxxf86dga' 'freeglut')<br />
makedepends=('alsa-lib' 'arts' 'sane')<br />
install=<br />
source=(http://ibiblio.org/pub/linux/system/emulators/wine/wine-$pkgver.tar.bz2 \<br />
wine-$pkgver-wow_fixes.patch)<br />
<br />
build() {<br />
cd $startdir/src/$pkgname-$pkgver<br />
msg "Patching Wine..."<br />
patch -Np0 ../$pkgname-0.9.11-wow-fixes.patch<br />
<br />
msg "Done patching, starting build..."<br />
./configure --prefix=/usr --sysconfdir=/etc --enable-opengl --with-x<br />
make depend || return 1<br />
make || return 1<br />
make prefix=$startdir/pkg/usr install || return 1<br />
# expand conflicts with textutils ( doesn't exist anymore ? )<br />
# mv $startdir/pkg/usr/bin/expand $startdir/pkg/usr/bin/wine-expand || return 1<br />
mkdir -p $startdir/pkg/etc/wine<br />
# mkdir -p $startdir/pkg/etc/profile.d<br />
# cp -r $startdir/src/$pkgname-$pkgver/documentation/samples $startdir/pkg/etc/wine<br />
}<br />
#md5sums=('b21d359b75f07255bb5cd34384bdc3cf' 'a65f6f2d422e5ee50af8492ebd38470f')<br />
</pre><br />
<br />
'''NOTE:''' You can get the <tt>wine-$pkgver-wow_fixes.patch</tt> from here: http://appdb.winehq.org/appview.php?versionId=4031<br />
<br />
Now execute the following commands to build and install your custom wine:<br />
<br />
cd /var/abs/local/wine<br />
makepkg -w `pwd`<br />
pacman -U wine-*.pkg.tar.gz<br />
<br />
You now have a working version of Wine!<br />
<br />
==Performance Tweaks==<br />
<br />
1. Here is a performance tweak that can boost your FPS significantly (everything without quotes):<br />
<br />
- Open wine's version of the registry editor by running "regedit"<br />
- Navigate to HKEY_CURRENT_USER\Software\Wine\ <br />
- Select the "Wine" folder, right-click onto the folder symbol and select New-> Key and rename it to "OpenGL"<br />
- Select the OpenGL-Key, then right-click into the right-hand pane, chose New-> String Value and hit enter<br />
- Rename "New Value #1" to "DisabledExtensions"<br />
- Double-Click on the renamed Key and enter "GL_ARB_vertex_buffer_object" into the "value" field<br />
<br />
That was it, close the registry editor again, your changes will be saved automatically.<br />
<br />
2. If you are finding it annoying that turning your character by let's say 90 degree takes n seconds normally, but n+m seconds in pupolated areas (in other words: that the polygon count of your surroundings affects the camera turning speed), apply something to "GL_ARB_vertex_buffer_object", like let's say a "2", so it looks like this: "GL_ARB_vertex_buffer_object2". You will still have the performance boost of the above tweak, but with a smoother feeling.<br />
<br />
==Kernel Timing Bug==<br />
<br />
If you are having problems with choppy video every 15 seconds or so, it is related to the kernel scheduler. There is a custom version of the kernel in AUR [http://aur.archlinux.org/packages.php?ID=17195 here], or you can roll your own with ABS.<br />
<br />
cp -r /var/abs/core/kernel26 ~/abs (or whatever your preferred abs directory is)<br />
cd abs/kernel26<br />
gedit config<br />
<br />
At this point, look for CONFIG_SCHED_DEBUG. Change<br />
<br />
# CONFIG_SCHED_DEBUG is not set<br />
to<br />
CONFIG_SCHED_DEBUG=y<br />
and save. Repeat for config.x86_64.<br />
<br />
After the config files are changed, run<br />
md5sum config<br />
md5sum config.x86_64<br />
<br />
Note the sums provided. They will be needed to update PKGBUILD. Look at<br />
source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_basekernel.tar.bz2<br />
ftp://ftp.archlinux.org/other/kernel26/${_patchname}.bz2<br />
# the main kernel config files<br />
config config.x86_64<br />
# standard config files for mkinitcpio ramdisk<br />
kernel26.preset)<br />
and<br />
md5sums=('5169d01c405bc3f866c59338e217968c'<br />
'003e89dd71b32ae9b93cd1601da3b1b0'<br />
'499d4841fbff665d0d0c768513018ba8'<br />
'5b5c7a9266af17d6ca3ebff420cd5381'<br />
'25584700a0a679542929c4bed31433b6')<br />
Config and config.x86_64 are the 3rd and 4th entries in md5sums. Replace with your newly generated md5sums and save. Run makepkg as per normal.<br />
<br />
After compiling and installing the new kernel, it may be necessary to compile new custom video drivers. For nVidia, see [[NVIDIA#How to install NVIDIA Driver with custom kernel|here]].<br />
<br />
Once the new kernel has been compiled and installed, add the following to /etc/sysctl.conf:<br />
kernel.sched_features=21<br />
kernel.sched_batch_wakeup_granularity_ns=25000000<br />
kernel.sched_min_granularity_ns=4000000<br />
and reboot.<br />
<br />
==Links==<br />
<br />
[http://appdb.winehq.org/appview.php?iVersionId=6482 World of Warcraft in the wine APPDB]<br />
<br />
[http://www.wowwiki.com/Main_Page WoWWiki]<br />
<br />
[http://www.wowwiki.com/Patch_mirrors Patch Mirrors]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106561Nginx2010-05-18T18:21:59Z<p>Sirupsen: /* Configuring for Ruby (on Rails) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
===Ruby (Rack-based and Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel] and [http://code.macournoyer.com/thin/ Thin].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ''basically'' read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106560Nginx2010-05-18T18:21:16Z<p>Sirupsen: /* Configuring */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
====Step 2: Edit /etc/nginx/conf/nginx.conf====<br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
====Step 3: Restart nginx====<br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel] and [http://code.macournoyer.com/thin/ Thin].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ''basically'' read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106559Nginx2010-05-18T18:19:59Z<p>Sirupsen: Grammar, more detailed information, layout</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2010/05/14/may_2010_web_server_survey.html May 2010 Web Server Survey]'', Nginx now hosts nearly 6.55% of all domains worldwide, while [[lighttpd]] hosts about 0.91%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.65:<br />
# pacman -S nginx<br />
Or, you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
Check that /etc/rc.d/nginx has this line correct:<br />
<br />
PID="/var/run/nginx.pid"<br />
<br />
Then, run:<br />
# /etc/rc.d/nginx start<br />
<br />
To start the service, Nginx server should now be running. <br />
<br />
The default served (i.e. the page served at http://127.0.0.1) page is: <br />
/srv/http/nginx/index.html<br />
<br />
(The Nginx package does not install a default '''index.html''', you must create this one yourself if you wish). <br />
<br />
After creating a ''/srv/http/nginx/index.html'' webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if Nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf:<br />
<br />
DAEMONS=(syslog-ng hal .. nginx)<br />
<br />
==Configuring ==<br />
<br />
You can modify the configurations by editing the files in ''/etc/nginx/conf''. (''/etc/nginx/conf/nginx.conf'' being the main config file). <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with Nginx ===<br />
FastCGI technology is introduced into Nginx to work with many external tools and servers, i.e: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
FastCGI is usually faster than implementations in e.g. Apache where PHP is loaded each time, with FastCGI the script is simply passed to the PHP deamon, and the appropriate value is returned and used by Nginx.<br />
<br />
====Step 1: Start the FastCGI server====<br />
There are two different ways to run FastCGI server. The third is PHP-only.<br />
<br />
=====Method one (PHP's built-in)=====<br />
Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is ''/etc/nginx/html'' which is moved outside the default nginx directory and symlinked to ''/srv/http/nginx'' in the Arch package. For php to work with nginx 0.7.62 the open_basedir in ''/etc/php/php.ini'' has to contain the directory ''/etc/nginx/html''. i.e. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as ''/etc/rc.d/fastcgi'' and add "fastcgi" to your DAEMONS array in ''/etc/rc.conf''<br />
<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
=====Method two (Third-party-wrapper)=====<br />
Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
=====Method three (PHP-fpm)=====<br />
<br />
Use [http://php-fpm.org/ PHP-fam].<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel] and [http://code.macournoyer.com/thin/ Thin].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ''basically'' read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=106558Nginx2010-05-18T18:02:21Z<p>Sirupsen: /* Configuring for Ruby (on Rails) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html June 2009 Web Server Survey from Netcraft]'', nginx now hosts nearly 3.37% of all domains worldwide, while lighttpd hosts about 1.8%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.62:<br />
# pacman -S nginx<br />
or you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
check that /etc/rc.d/nginx has this line correct.<br />
PID="/var/run/nginx.pid"<br />
<br />
Run<br />
# /etc/rc.d/nginx start<br />
The nginx server should now be running. <br />
The default main page is /srv/http/nginx/index.html(the nginx package does not install a default index.html, you must create this now). <br />
After creating a /srv/http/nginx/index.html webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf.<br />
<br />
==Configuring ==<br />
You can modify the configurations by editing the files in /etc/nginx/conf. (/etc/nginx/conf/nginx.conf being the main config file) . <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with nginx ===<br />
FastCGI technology is introduced into nginx to work with many external tools and servers, ie: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
'''Step 1: Start the FastCGI server'''<br><br />
There are two different ways to run FastCGI server: <br />
<br />
1) Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default nginx directory and symlinked to /srv/http/nginx in the arch package. For php to work with nginx 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory /etc/nginx/html. IE. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as /etc/rc.d/fastcgi and add "fastcgi" to your DAEMONS array in /etc/rc.conf<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
2) Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for to make Nginx work with Ruby anymore, although very well possible.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are a great toolkit, and this setup is extremely easy to achieve on Arch Linux.<br />
It should be noted, however, that there are other alternatives, including [http://github.com/fauna/mongrel Mongrel] and [http://code.macournoyer.com/thin/ Thin].<br />
<br />
====Setting up Nginx and Passenger====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are ''basically'' read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
===Troubleshooting===<br />
<br />
====403 errors====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webapp''') and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106557RVM2010-05-18T17:56:05Z<p>Sirupsen: /* Ruby Version Manager (RVM) */</p>
<hr />
<div>== Ruby Version Manager (RVM) ==<br />
<br />
[http://rvm.beginrescueend.com/ RVM] is a command line tool which allows us to easily install, manage and work with multiple ruby environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
$ gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. ~/.bashrc) And then running:<br />
<br />
$ rvm-install<br />
<br />
'''Note: ''' Above commands ''may'' have to be run as the superuser.<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [http://aur.archlinux.org/packages.php?ID=30221 Ruby1.8 package in the AUR] has solved this issue with a patch included in the package. Simply [http://aur.archlinux.org/packages.php?ID=30221 download the package from AUR], download the [ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.7-p249.tar.bz2 Ruby 1.8.7 source], apply the patch contained in the package from the AUR, once the source has been patched, archive the patched source to a tar.gz file, and put this file into: <br />
<br />
~/.rvm/archives/ruby.1.8.7-p249.tar.gz. <br />
<br />
Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106555RVM2010-05-18T17:54:45Z<p>Sirupsen: /* Ruby 1.8.x won't compile with RVM */</p>
<hr />
<div>== Ruby Version Manager (RVM) ==<br />
<br />
RVM is a command line tool which allows us to easily install, manage and work with multiple ruby environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
$ gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. ~/.bashrc) And then running:<br />
<br />
$ rvm-install<br />
<br />
'''Note: ''' Above commands ''may'' have to be run as the superuser.<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [http://aur.archlinux.org/packages.php?ID=30221 Ruby1.8 package in the AUR] has solved this issue with a patch included in the package. Simply [http://aur.archlinux.org/packages.php?ID=30221 download the package from AUR], download the [ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.7-p249.tar.bz2 Ruby 1.8.7 source], apply the patch contained in the package from the AUR, once the source has been patched, archive the patched source to a tar.gz file, and put this file into: <br />
<br />
~/.rvm/archives/ruby.1.8.7-p249.tar.gz. <br />
<br />
Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106554RVM2010-05-18T17:51:47Z<p>Sirupsen: /* Ruby 1.8.x won't compile with RVM */</p>
<hr />
<div>== Ruby Version Manager (RVM) ==<br />
<br />
RVM is a command line tool which allows us to easily install, manage and work with multiple ruby environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
$ gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. ~/.bashrc) And then running:<br />
<br />
$ rvm-install<br />
<br />
'''Note: ''' Above commands ''may'' have to be run as the superuser.<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [http://aur.archlinux.org/packages.php?ID=30221 Ruby1.8 package in the AUR] has solved this issue with a patch included in the package. Simply [http://aur.archlinux.org/packages.php?ID=30221 download the package from AUR], download Ruby 1.8.7 source, apply the patch contained in the package, archive it the patched source to a tar.gz file, and put this file into ~/.rvm/archives/ruby.1.8.7-p249.tar.gz. Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106553RVM2010-05-18T17:50:18Z<p>Sirupsen: /* Listing Ruby Environments */</p>
<hr />
<div>== Ruby Version Manager (RVM) ==<br />
<br />
RVM is a command line tool which allows us to easily install, manage and work with multiple ruby environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
$ gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. ~/.bashrc) And then running:<br />
<br />
$ rvm-install<br />
<br />
'''Note: ''' Above commands ''may'' have to be run as the superuser.<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
System Ruby<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [Ruby1.8 package in the AUR](http://aur.archlinux.org/packages.php?ID=30221) has solved this issue with a patch included in the package. Simply [download the package from AUR](http://aur.archlinux.org/packages.php?ID=30221), download Ruby 1.8.7 source, apply the patch contained in the package, archive it the patched source to a tar.gz file, and put this file into ~/.rvm/archives/ruby.1.8.7-p249.tar.gz. Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=RVM&diff=106552RVM2010-05-18T17:49:53Z<p>Sirupsen: Initial</p>
<hr />
<div>== Ruby Version Manager (RVM) ==<br />
<br />
RVM is a command line tool which allows us to easily install, manage and work with multiple ruby environments from interpreters to sets of gems.<br />
<br />
=== Installing RVM ===<br />
<br />
To install RVM under Arch Linux, simply install it as a RubyGem:<br />
<br />
$ gem install rvm<br />
<br />
Once the Gem is installed, follow the instructions given. These involves adding a line to your environments init file. (e.g. ~/.bashrc) And then running:<br />
<br />
$ rvm-install<br />
<br />
'''Note: ''' Above commands ''may'' have to be run as the superuser.<br />
<br />
=== Using RVM ===<br />
<br />
Here's some RVM usage examples, for general usage no more is needed.<br />
<br />
==== Installing an environment ====<br />
<br />
To install a Ruby environment, run:<br />
<br />
$ rvm install <environment/ruby version><br />
<br />
For example, to install Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm install 1.8.7<br />
<br />
This should download, configure and install Ruby 1.8.7.<br />
<br />
==== Listing Ruby Environments ====<br />
<br />
To see all available Ruby environments, run the following command:<br />
<br />
$ rvm list<br />
<br />
This would generate a list like so:<br />
<br />
~> rvm list<br />
<br />
rvm Rubies<br />
<br />
jruby-1.5.0 [ [i386-java] ]<br />
=> ruby-1.8.7-p249 [ i386 ]<br />
ruby-1.9.2-head [ i386 ]<br />
<br />
System Ruby<br />
<br />
system [ i386 ]<br />
<br />
The ASCII arrow indicates which environment is currently enabled. In this case, it is Ruby 1.8.7. This could be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
==== Switching Environment ====<br />
<br />
To switch from one environment, to another simply run:<br />
<br />
$ rvm <version/environment><br />
<br />
For example to switch to Ruby 1.8.7 one would run the following command:<br />
<br />
$ rvm 1.8.7<br />
<br />
It can be confirmed by running:<br />
<br />
$ ruby --version<br />
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]<br />
<br />
=== Troubleshooting ===<br />
<br />
==== Ruby 1.8.x won't compile with RVM ====<br />
<br />
This is a known issue on Arch Linux, and is caused by a problem with openssl. The [Ruby1.8 package in the AUR](http://aur.archlinux.org/packages.php?ID=30221) has solved this issue with a patch included in the package. Simply [download the package from AUR](http://aur.archlinux.org/packages.php?ID=30221), download Ruby 1.8.7 source, apply the patch contained in the package, archive it the patched source to a tar.gz file, and put this file into ~/.rvm/archives/ruby.1.8.7-p249.tar.gz. Try to install Ruby 1.8.7 via RVM again, and it should use the patched source, and work.</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=104763Nginx2010-04-26T19:23:25Z<p>Sirupsen: /* 403 errors */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html June 2009 Web Server Survey from Netcraft]'', nginx now hosts nearly 3.37% of all domains worldwide, while lighttpd hosts about 1.8%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.62:<br />
# pacman -S nginx<br />
or you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
check that /etc/rc.d/nginx has this line correct.<br />
PID="/var/run/nginx.pid"<br />
<br />
Run<br />
# /etc/rc.d/nginx start<br />
The nginx server should now be running. <br />
The default main page is /srv/http/nginx/index.html(the nginx package does not install a default index.html, you must create this now). <br />
After creating a /srv/http/nginx/index.html webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf.<br />
<br />
==Configuring ==<br />
You can modify the configurations by editing the files in /etc/nginx/conf. (/etc/nginx/conf/nginx.conf being the main config file) . <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with nginx ===<br />
FastCGI technology is introduced into nginx to work with many external tools and servers, ie: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
'''Step 1: Start the FastCGI server'''<br><br />
There are two different ways to run FastCGI server: <br />
<br />
1) Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default nginx directory and symlinked to /srv/http/nginx in the arch package. For php to work with nginx 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory /etc/nginx/html. IE. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as /etc/rc.d/fastcgi and add "fastcgi" to your DAEMONS array in /etc/rc.conf<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
2) Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for Ruby anymore.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are recommended, and this setup is extremely easy to achieve on Arch Linux.<br />
<br />
====Installation====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are basically read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
====Troubleshooting====<br />
<br />
=====403 errors=====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webap'''p) and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determent this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=104762Nginx2010-04-26T19:23:15Z<p>Sirupsen: /* 403 errors */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html June 2009 Web Server Survey from Netcraft]'', nginx now hosts nearly 3.37% of all domains worldwide, while lighttpd hosts about 1.8%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.62:<br />
# pacman -S nginx<br />
or you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
check that /etc/rc.d/nginx has this line correct.<br />
PID="/var/run/nginx.pid"<br />
<br />
Run<br />
# /etc/rc.d/nginx start<br />
The nginx server should now be running. <br />
The default main page is /srv/http/nginx/index.html(the nginx package does not install a default index.html, you must create this now). <br />
After creating a /srv/http/nginx/index.html webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf.<br />
<br />
==Configuring ==<br />
You can modify the configurations by editing the files in /etc/nginx/conf. (/etc/nginx/conf/nginx.conf being the main config file) . <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with nginx ===<br />
FastCGI technology is introduced into nginx to work with many external tools and servers, ie: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
'''Step 1: Start the FastCGI server'''<br><br />
There are two different ways to run FastCGI server: <br />
<br />
1) Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default nginx directory and symlinked to /srv/http/nginx in the arch package. For php to work with nginx 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory /etc/nginx/html. IE. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as /etc/rc.d/fastcgi and add "fastcgi" to your DAEMONS array in /etc/rc.conf<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
2) Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for Ruby anymore.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are recommended, and this setup is extremely easy to achieve on Arch Linux.<br />
<br />
====Installation====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are basically read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
====Troubleshooting====<br />
<br />
=====403 errors=====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webap'''p) and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determant this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=104757Nginx2010-04-26T16:07:11Z<p>Sirupsen: /* Configuring for Ruby (on Rails) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html June 2009 Web Server Survey from Netcraft]'', nginx now hosts nearly 3.37% of all domains worldwide, while lighttpd hosts about 1.8%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.62:<br />
# pacman -S nginx<br />
or you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
check that /etc/rc.d/nginx has this line correct.<br />
PID="/var/run/nginx.pid"<br />
<br />
Run<br />
# /etc/rc.d/nginx start<br />
The nginx server should now be running. <br />
The default main page is /srv/http/nginx/index.html(the nginx package does not install a default index.html, you must create this now). <br />
After creating a /srv/http/nginx/index.html webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf.<br />
<br />
==Configuring ==<br />
You can modify the configurations by editing the files in /etc/nginx/conf. (/etc/nginx/conf/nginx.conf being the main config file) . <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with nginx ===<br />
FastCGI technology is introduced into nginx to work with many external tools and servers, ie: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
'''Step 1: Start the FastCGI server'''<br><br />
There are two different ways to run FastCGI server: <br />
<br />
1) Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default nginx directory and symlinked to /srv/http/nginx in the arch package. For php to work with nginx 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory /etc/nginx/html. IE. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as /etc/rc.d/fastcgi and add "fastcgi" to your DAEMONS array in /etc/rc.conf<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
2) Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for Ruby anymore.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are recommended, and this setup is extremely easy to achieve on Arch Linux.<br />
<br />
====Installation====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are basically read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
====Troubleshooting====<br />
<br />
=====403 errors=====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webap'''p) and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determine this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=104756Nginx2010-04-26T16:06:33Z<p>Sirupsen: /* Configuring for Ruby (on Rails) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html June 2009 Web Server Survey from Netcraft]'', nginx now hosts nearly 3.37% of all domains worldwide, while lighttpd hosts about 1.8%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.62:<br />
# pacman -S nginx<br />
or you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
check that /etc/rc.d/nginx has this line correct.<br />
PID="/var/run/nginx.pid"<br />
<br />
Run<br />
# /etc/rc.d/nginx start<br />
The nginx server should now be running. <br />
The default main page is /srv/http/nginx/index.html(the nginx package does not install a default index.html, you must create this now). <br />
After creating a /srv/http/nginx/index.html webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf.<br />
<br />
==Configuring ==<br />
You can modify the configurations by editing the files in /etc/nginx/conf. (/etc/nginx/conf/nginx.conf being the main config file) . <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with nginx ===<br />
FastCGI technology is introduced into nginx to work with many external tools and servers, ie: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
'''Step 1: Start the FastCGI server'''<br><br />
There are two different ways to run FastCGI server: <br />
<br />
1) Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default nginx directory and symlinked to /srv/http/nginx in the arch package. For php to work with nginx 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory /etc/nginx/html. IE. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as /etc/rc.d/fastcgi and add "fastcgi" to your DAEMONS array in /etc/rc.conf<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
2) Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials on configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use [http://www.fastcgi.com/drupal/ FastCGI] for Ruby anymore.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are recommended, and this setup extremely easy to achieve on Arch Linux.<br />
<br />
====Installation====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are basically read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
====Troubleshooting====<br />
<br />
=====403 errors=====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webap'''p) and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determine this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=104754Nginx2010-04-26T16:04:36Z<p>Sirupsen: /* 403 errors */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html June 2009 Web Server Survey from Netcraft]'', nginx now hosts nearly 3.37% of all domains worldwide, while lighttpd hosts about 1.8%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.62:<br />
# pacman -S nginx<br />
or you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
check that /etc/rc.d/nginx has this line correct.<br />
PID="/var/run/nginx.pid"<br />
<br />
Run<br />
# /etc/rc.d/nginx start<br />
The nginx server should now be running. <br />
The default main page is /srv/http/nginx/index.html(the nginx package does not install a default index.html, you must create this now). <br />
After creating a /srv/http/nginx/index.html webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf.<br />
<br />
==Configuring ==<br />
You can modify the configurations by editing the files in /etc/nginx/conf. (/etc/nginx/conf/nginx.conf being the main config file) . <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with nginx ===<br />
FastCGI technology is introduced into nginx to work with many external tools and servers, ie: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
'''Step 1: Start the FastCGI server'''<br><br />
There are two different ways to run FastCGI server: <br />
<br />
1) Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default nginx directory and symlinked to /srv/http/nginx in the arch package. For php to work with nginx 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory /etc/nginx/html. IE. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as /etc/rc.d/fastcgi and add "fastcgi" to your DAEMONS array in /etc/rc.conf<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
2) Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials for configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use FastCGI for Ruby.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are recommended. And is extremely easy to setup for Arch Linux.<br />
<br />
====Installation====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are basically read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
====Troubleshooting====<br />
<br />
=====403 errors=====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webap'''p) and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determine this), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=104752Nginx2010-04-26T16:03:48Z<p>Sirupsen: /* Configuring for Ruby (on Rails) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html June 2009 Web Server Survey from Netcraft]'', nginx now hosts nearly 3.37% of all domains worldwide, while lighttpd hosts about 1.8%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.62:<br />
# pacman -S nginx<br />
or you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
check that /etc/rc.d/nginx has this line correct.<br />
PID="/var/run/nginx.pid"<br />
<br />
Run<br />
# /etc/rc.d/nginx start<br />
The nginx server should now be running. <br />
The default main page is /srv/http/nginx/index.html(the nginx package does not install a default index.html, you must create this now). <br />
After creating a /srv/http/nginx/index.html webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf.<br />
<br />
==Configuring ==<br />
You can modify the configurations by editing the files in /etc/nginx/conf. (/etc/nginx/conf/nginx.conf being the main config file) . <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with nginx ===<br />
FastCGI technology is introduced into nginx to work with many external tools and servers, ie: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
'''Step 1: Start the FastCGI server'''<br><br />
There are two different ways to run FastCGI server: <br />
<br />
1) Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default nginx directory and symlinked to /srv/http/nginx in the arch package. For php to work with nginx 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory /etc/nginx/html. IE. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as /etc/rc.d/fastcgi and add "fastcgi" to your DAEMONS array in /etc/rc.conf<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
2) Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials for configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use FastCGI for Ruby.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are recommended. And is extremely easy to setup for Arch Linux.<br />
<br />
====Installation====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are basically read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
====Troubleshooting====<br />
<br />
=====403 errors=====<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webap'''p) and the user has the right permissions (you can temporarily chmod all the files to 777 in order to determine this matter), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsenhttps://wiki.archlinux.org/index.php?title=Nginx&diff=104751Nginx2010-04-26T16:03:24Z<p>Sirupsen: /* Configuring for Ruby (on Rails) */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
[[Category:Web Server (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|NginX}}<br />
{{i18n_entry|简体中文|Archlinux NginX配置指南(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==Summary==<br />
Nginx (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to the ''[http://news.netcraft.com/archives/2009/06/17/june_2009_web_server_survey.html June 2009 Web Server Survey from Netcraft]'', nginx now hosts nearly 3.37% of all domains worldwide, while lighttpd hosts about 1.8%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
==Installation ==<br />
The nginx package is now in the [community] repository, the latest stable version is nginx-0.7.62:<br />
# pacman -S nginx<br />
or you can compile and install the latest development version with ABS.<br />
<br />
==Starting service ==<br />
check that /etc/rc.d/nginx has this line correct.<br />
PID="/var/run/nginx.pid"<br />
<br />
Run<br />
# /etc/rc.d/nginx start<br />
The nginx server should now be running. <br />
The default main page is /srv/http/nginx/index.html(the nginx package does not install a default index.html, you must create this now). <br />
After creating a /srv/http/nginx/index.html webpage, you can use this URL: <nowiki>http://127.0.0.1</nowiki> to test if nginx is working.<br />
<br />
To enable service by default at startup just add "nginx" to the DAEMONS in the /etc/rc.conf.<br />
<br />
==Configuring ==<br />
You can modify the configurations by editing the files in /etc/nginx/conf. (/etc/nginx/conf/nginx.conf being the main config file) . <br />
<br />
More details can be referred from [http://wiki.codemongers.com/NginxConfiguration Nginx Configuration Examples].<br />
<br />
===Use PHP/Python with nginx ===<br />
FastCGI technology is introduced into nginx to work with many external tools and servers, ie: PHP and Python. So, you cannot use PHP or Python service unless FastCGI server has been started. <br />
<br />
PHP and Python can be run as FastCGI application and can process FastCGI requests from nginx.<br />
<br />
'''Step 1: Start the FastCGI server'''<br><br />
There are two different ways to run FastCGI server: <br />
<br />
1) Directly running PHP’s built-in FastCGI server - this method does not require any third party tools.<br />
<br />
Archlinux's '''''php''''' package in the [extra] repository has already enabled FastCGI support.<br />
<br />
For example:<br />
$ sudo pacman -S php php-cgi<br />
$ php-cgi -b 127.0.0.1:9000 &<br />
<br />
This command sets up the local machine as a FastCGI server using port 9000.<br />
<br />
'''Note:''' Since nginx 0.7.62, the default internal $document_root is /etc/nginx/html which is moved outside the default nginx directory and symlinked to /srv/http/nginx in the arch package. For php to work with nginx 0.7.62 the open_basedir in /etc/php/php.ini has to contain the directory /etc/nginx/html. IE. open_basedir = /etc/nginx/html/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
Below is a daemon script to be used in rc.conf on boot to start php-cgi. save it as /etc/rc.d/fastcgi and add "fastcgi" to your DAEMONS array in /etc/rc.conf<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy 'Starting Fastcgi Server'<br />
if /usr/bin/php-cgi -b 127.0.0.1:9000 &<br />
then<br />
add_daemon fastcgi<br />
stat_done<br />
else<br />
stat_fail fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy 'Stopping Fastcgi Server'<br />
[ -e /var/run/daemons/fastcgi ] && kill $(pidof php-cgi) &> /dev/null;<br />
if [ $? -gt 0 ]; then <br />
stat_fail<br />
else<br />
rm_daemon fastcgi<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
esac<br />
<br />
2) Running PHP inside some third-party wrapper - this can be more comfortable than first method because of more flexibility. You can install ''fcgi''(which includes ''cgi-fcgi''), ''lighttpd'' (which includes ''spawn-fcgi''), and '''''PHP-FPM ''''' (PHP FastCGI Process Manager, which is now in the AUR. Recommended.)<br />
<br />
For example:<br />
<br />
# cgi-fcgi -start -connect localhost:9000 /usr/bin/php-cgi<br />
<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -C 9 -f /usr/bin/php-cgi<br />
<br />
# php --fpm -b 127.0.0.1:9000<br />
<br />
'''Note:''' You may need to edit /etc/php-fpm.conf at first. More details about php-fpm can be referred from '''[http://php-fpm.anight.org/ php-fpm website]'''<br />
<br />
'''Note:''' Sometimes, you may encounter some permission issue when running some third party software to start PHP as FastCGI-server. See '''[[Nginx#Tips|Tips]]'''.<br />
<br />
<br />
'''Step 2: Edit /etc/nginx/conf/nginx.conf'''<br><br />
Un-comment these lines and edit in the file to be as follows:<br />
location ~ \.php$ {<br />
root html;<br />
fastcgi_pass 127.0.0.1:9000;<br />
fastcgi_index index.php; <br />
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;<br />
include fastcgi_params<br />
}<br />
<br />
'''Step 3: Restart nginx'''<br><br />
If nginx has been working, run<br />
# /etc/rc.d/nginx restart<br />
<br />
Edit /srv/http/nginx/index.php,<br />
<?php<br />
phpinfo();<br />
?> <br />
view the URL: <nowiki>http://localhost/index.php</nowiki> with your browser, and you'll find PHP has worked well with nginx.<br />
<br />
===Configuring for Ruby (on Rails)===<br />
The [http://wiki.rubyonrails.org/ Ruby on Rails wiki] has tutorials for configuring Ruby for [http://nginx.org/ Nginx]. It is not recommended to use FastCGI for Ruby.<br />
[http://nginx.org/ Nginx] and [http://modrails.com/ Passenger] are recommended. And is extremely easy to setup for Arch Linux.<br />
<br />
====Installation====<br />
Install the [http://aur.archlinux.org/packages.php?ID=28185 Nginx Passenger] package from AUR, and you are basically read to go.<br />
<br />
I encourage you to read through the Nginx part of [http://wiki.rubyonrails.org/deployment/vps-setup-nginx-passenger this tutorial] for configuring Nginx for Ruby on Rails.<br />
<br />
Note that with Passenger you are also able to run other Ruby web frameworks, e.g. [http://www.sinatrarb.com/ Sinatra] or anything [http://rack.rubyforge.org/ Rack]-based.<br />
<br />
====Troubleshooting====<br />
<br />
'''403 errors'''<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. '''/home/arch/public/webap'''p) and the user has the right permissions (you can temporarily chmod all the files to 777 in order to determine this matter), '''/home/arch''' might be '''chmod 750''', simply '''chmod''' it to '''751''', and it should work.<br />
<br />
===Security ===<br />
* allow/deny based on IP <br />
[http://wiki.codemongers.com/NginxHttpAccessModule ngx_http_access_module]<br />
* HTTP authentication<br />
[http://wiki.codemongers.com/NginxHttpAuthBasicModule ngx_http_auth_basic_module]<br />
* HTTPS support<br />
[http://wiki.codemongers.com/NginxHttpSslModule ngx_http_ssl_module]<br />
<br />
==Tips==<br />
* Tuning the kernel for better speed<br />
Add the followings to /etc/sysctl.conf<br />
net.ipv4.tcp_fin_timeout = 30<br />
net.ipv4.tcp_keepalive_time = 300<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.tcp_tw_reuse = 1<br />
net.ipv4.tcp_tw_recycle = 1<br />
net.ipv4.ip_local_port_range = 5000 65000 <br />
and make it active:<br />
# /sbin/sysctl -p<br />
<br />
* The browser results in: '''the page you are looking for is temporarily unavailable. Please try again later. '''<br />
This is because the FastCGI server has not been started. <br />
<br />
* The browser results in: '''no input file specified'''<br />
Most Likely you don't have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it's simply an permission issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For instance :<br />
$ sudo groupadd www<br />
$ sudo useradd -g www www<br />
$ sudo chmod +w /srv/www/nginx/html<br />
$ sudo chown -R www:www /srv/www/nginx/html<br />
$ sudo spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in nginx.conf, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, don't define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as /srv/www/nginx/html by default using the variable "open_basedir" in /etc/php/php.ini, you can change them if you need.<br />
<br />
==References ==<br />
*[http://nginx.net/ Nginx Official site]<br />
*[http://wiki.nginx.org/Main Nginx Wiki]<br />
*[http://calomel.org/nginx.html Nginx Howto]</div>Sirupsen