Mica enciclopedie Romaneasca
Instalare Container VPS-uri pe CentOS 5.4
In acest scurt tuotrial voi descrie modul de instalare al Kernel-ului OpenVZ pe sistemul de operare CentOS 5.4 OpenVZ este varianta cu sursa-deschisa (OpenSource) a renumitului Virtuozzo. Ok, Sa incepem: 1. Instalarea OpenVZ Cel mai simplu mod de instalare este sa adaugam in repository-ul YUM si adresa openVZ. Pentru aceasta executam urmatoarele comenzi: cd /etc/yum.repos.d wget http:/...
Installing PHP 5.3, Nginx And PHP-fpm On Ubuntu/Debian
Since Apache is most of the time a memory hungy process, people started to look for different ways to host their website. Apache is clearly not the only webserver available. A few good examples are lighttpd and nginx. In this tutorial I will show you how to install it on your Ubuntu server. This tutorial also applies to Debian, though. There is only a very small difference. Ready? Let's begin...
VBoxHeadless – Running Virtual Machines With VirtualBox 3.1.x On A Headless Debian Lenny Server
This guide explains how you can run virtual machines with Sun xVM VirtualBox 3.1.x on a headless Debian Lenny server. Normally you use the VirtualBox GUI to manage your virtual machines, but a server does not have a desktop environment. Fortunately, VirtualBox comes with a tool called VBoxHeadless that allows you to connect to the virtual machines over a remote desktop connection, so there's no n...
Server Monitoring With munin And monit On Debian Lenny
In this article I will describe how you can monitor your Debian Lenny server with munin and monit. munin produces nifty little graphics about nearly every aspect of your server (load average, memory usage, CPU usage, MySQL throughput, eth0 traffic, etc.) without much configuration, whereas monit checks the availability of services like Apache, MySQL, Postfix and takes the appropriate action such ...
How To Install Z-Push On An ISPConfig 3 Server (Debian Lenny)
Z-push is an implementation of the ActiveSync protocol which is used 'over-the-air' for multi platform ActiveSync devices, including Windows Mobile, iPhone, Sony Ericsson and Nokia mobile devices. With Z-push any groupware can be connected and synced with these devices. This install of Z-Push is on a The Perfect Server - Debian Lenny (Debian 5.0) [ISPConfig 3] setup. I'm using z-push on my 1st w...
How To Set Up Apache2 With mod_fcgid And PHP5 On Ubuntu 8.10
This tutorial describes how you can install Apache2 with mod_fcgid and PHP5 on Ubuntu 8.10. mod_fcgid is a compatible alternative to the older mod_fastcgi. It lets you execute PHP scripts with the permissions of their owners instead of the Apache user. I do not issue any guarantee that this will work for you!   1 Preliminary Note I'm using an Ubuntu 8.10 server in this tutorial wi...
Instalare ProFTP cu suport MySQL pe *.deb
Presupunand ca avem deja instalat PHP5 cu suport pentru MySQL (Gasiti tutorialul de instalare pe situl http://auto-scripts.com) putem incepe procedura de instalare a clientului FTP (in acest caz ProFTP) cu suport MySQL. 1. De ce instalam cu suport MySQL? Deoarece in acest fel putem realiza un numar infinit de conturi FTP virtuale, putem schimba parolele extrem de simplu, putem crea limita de ...
Cum sa repari/citesti un CD sau DVD zgariat sau ars
Battlefield: Bad Company 2, superior pe PC
   Battlefield Bad Company 2 Intr-o era in care jocurile pe PC au inceput sa devina niste simple portari ale versiunilor de consola (de multe ori neadaptate asa cum ar trebui posibilitatilor oferite de un computer), Battlefield: Bad Company 2 pare a fi o exceptie de la aceasta nefericita regula.Din trailerul de mai jos puteti afla ce avantaje va prezenta versiunea de PC a lui B...
Download si instalare Windows 7 in limba romana
Download linkPentru instalare: 1. Deschideti control panel si faceti click pe Change Display Challenge sub Clock, Language, and Region Box. Daca folositi Classic View, selectati Regional and Language Options. 2. Mergeti la “Keyboards and Languages” tab si faceti click pe Install/Uninstall Languages  Navigati unde aveti salvat, si deschideti-l.Acum pachetul trebuie sa va apare...

How To Set Up Apache2 With mod_fcgid And PHP5 On Ubuntu 8.10

Posted By: admin on April 13, 2010 in English tutorials - Comments: No Comments »

This tutorial describes how you can install Apache2 with mod_fcgid and PHP5 on Ubuntu 8.10. mod_fcgid is a compatible alternative to the older mod_fastcgi.

It lets you execute PHP scripts with the permissions of their owners instead of the Apache user.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I’m using an Ubuntu 8.10 server in this tutorial with the hostname server1.example.com and the IP address 192.168.0.100.

I will create two Apache vhosts in this tutorial, www.example1.com and www.example2.com, to demonstrate the usage of mod_fcgid.

Make sure you’re logged in as root:

sudo su

/bin/sh is a symlink to /bin/dash, however we need /bin/bash, not /bin/dash. Therefore we do this:

ln -sf /bin/bash /bin/sh

In addition to that, we must disable AppArmor:

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils

 

2 Installing Apache2/mod_fcgi/PHP5

In order to install Apache2, mod_fcgid, and PHP5, run

apt-get install apache2 apache2-suexec libapache2-mod-fcgid php5-cgi

If Apache2 was already installed with PHP5 as an Apache module, disable the PHP5 module now:

a2dismod php5

Then enable the following modules…

a2enmod rewrite
a2enmod suexec
a2enmod include
a2enmod fcgid

… and open /etc/php5/cgi/php.ini:

vi /etc/php5/cgi/php.ini

Add the line cgi.fix_pathinfo = 1 right at the end of the file:

[...]
cgi.fix_pathinfo = 1

Then reload Apache:

/etc/init.d/apache2 force-reload

 

3 Creating Vhosts For www.example1.com And www.example2.com

I will now create two vhosts, www.example1.com (with the document root /var/www/web1/web) and www.example2.com (with the document root /var/www/web2/web). www.example1.com will be owned by the user and group web1, and www.example2.com by the user and group web2.

First we create the users and groups:

groupadd web1
groupadd web2
useradd -s /bin/false -d /var/www/web1 -m -g web1 web1
useradd -s /bin/false -d /var/www/web2 -m -g web2 web2

Then we create the document roots and make them owned by the users/groups web1 resp. web2:

mkdir -p /var/www/web1/web
chown web1:web1 /var/www/web1/web
mkdir -p /var/www/web2/web
chown web2:web2 /var/www/web2/web

We will run PHP using suExec; suExec’s document root is /var/www, as the following command shows:

/usr/lib/apache2/suexec -V

root@server1:~# /usr/lib/apache2/suexec -V
 -D AP_DOC_ROOT=”/var/www”
 -D AP_GID_MIN=100
 -D AP_HTTPD_USER=”www-data”
 -D AP_LOG_EXEC=”/var/log/apache2/suexec.log”
 -D AP_SAFE_PATH=”/usr/local/bin:/usr/bin:/bin”

 -D AP_UID_MIN=100
 -D AP_USERDIR_SUFFIX=”public_html”
root@server1:~#

Therefore we cannot call the PHP binary (/usr/lib/cgi-bin/php) directly because it is located outside suExec’s document root. As suExec does not allow symlinks, the only way to solve the problem is to create a wrapper script for each web site in a subdirectory of /var/www; the wrapper script will then call the PHP binary /usr/lib/cgi-bin/php. The wrapper script must be owned by the user and group of each web site, therefore we need one wrapper script for each web site. I’m going to create the wrapper scripts in subdirectories of /var/www/php-fcgi-scripts, e.g. /var/www/php-fcgi-scripts/web1 and /var/www/php-fcgi-scripts/web2.

mkdir -p /var/www/php-fcgi-scripts/web1
mkdir -p /var/www/php-fcgi-scripts/web2

vi /var/www/php-fcgi-scripts/web1/php-fcgi-starter

#!/bin/sh
PHPRC=/etc/php5/cgi/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/lib/cgi-bin/php

vi /var/www/php-fcgi-scripts/web2/php-fcgi-starter

#!/bin/sh
PHPRC=/etc/php5/cgi/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/lib/cgi-bin/php

The PHPRC line contains the directory where the php.ini file is located (i.e., /etc/php5/cgi/ translates to /etc/php5/cgi/php.ini). PHP_FCGI_MAX_REQUESTS is the maximum number of requests before an fcgid process is stopped and a new one is launched. PHP_FCGI_CHILDREN defines the number of PHP children that will be launched.

The php-fcgi-starter scripts must be executable, and they (and the directories they are in) must be owned by the web site’s user and group:

chmod 755 /var/www/php-fcgi-scripts/web1/php-fcgi-starter
chmod 755 /var/www/php-fcgi-scripts/web2/php-fcgi-starter
chown -R web1:web1 /var/www/php-fcgi-scripts/web1
chown -R web2:web2 /var/www/php-fcgi-scripts/web2

Now we create the Apache vhosts for www.example1.com and www.example2.com:

vi /etc/apache2/sites-available/web1

<VirtualHost *:80>
  ServerName www.example1.com
  ServerAlias example1.com
  ServerAdmin webmaster@example1.com
  DocumentRoot /var/www/web1/web/

  <IfModule mod_fcgid.c>
    SuexecUserGroup web1 web1
    PHP_Fix_Pathinfo_Enable 1
    <Directory /var/www/web1/web/>

      Options +ExecCGI
      AllowOverride All
      AddHandler fcgid-script .php
      FCGIWrapper /var/www/php-fcgi-scripts/web1/php-fcgi-starter .php
      Order allow,deny
      Allow from all
    </Directory>
  </IfModule>

  # ErrorLog /var/log/apache2/error.log
  # CustomLog /var/log/apache2/access.log combined
  ServerSignature Off

</VirtualHost>

a2ensite web1

vi /etc/apache2/sites-available/web2

<VirtualHost *:80>
  ServerName www.example2.com
  ServerAlias example2.com
  ServerAdmin webmaster@example2.com
  DocumentRoot /var/www/web2/web/

  <IfModule mod_fcgid.c>
    SuexecUserGroup web2 web2
    PHP_Fix_Pathinfo_Enable 1
    <Directory /var/www/web2/web/>

      Options +ExecCGI
      AllowOverride All
      AddHandler fcgid-script .php
      FCGIWrapper /var/www/php-fcgi-scripts/web2/php-fcgi-starter .php
      Order allow,deny
      Allow from all
    </Directory>
  </IfModule>

  # ErrorLog /var/log/apache2/error.log
  # CustomLog /var/log/apache2/access.log combined
  ServerSignature Off

</VirtualHost>

a2ensite web2

Make sure you fill in the right paths (and the correct user and group in the SuexecUserGroup line).

Reload Apache afterwards:

/etc/init.d/apache2 reload

VN:F [1.9.0_1079]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.0_1079]
Rating: 0 (from 0 votes)
859 Vizualizari. | Raporteaza Post/Eroare

Raporteaza Post/EroareClose

Tags: , ,

Leave a Reply

Copyright ©2012