FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 08-07-2011, 11:10 PM
Jordon Bedwell
 
Default Apache and PHP with fcgi on 10.04

Snippet from Wipe_Out On 07/08/11 14:13:
> Any help converting from what I have setup to an fcgi setup would be appreciated..

I'm only going to show you how to do barebones, this will get you up and
running but this isn't secure at all without some sort of real ACL and
suexec, but then again, I don't remember the last time one of my clients
put up an ACL before I was there o.O most of them think suexec is good
enough. Anyways suexec is easy enough to install and configure so I'll
just give you the basics:

---

sudo apt-get install php5-cgi
apache2
libapache2-mod-fcgid
apache2-mpm-itk --no-install-recommends

---

sudo vim /etc/apache2/fcgi.bash
Contents:

#!/bin/sh

# The basics
export PHPRC=/etc/php5/cgi/
export PHP_FCGI_CHILDREN=3
export PHP_FCGI_MAX_REQUESTS=5000

# Time for the fun
exec /usr/lib/cgi-bin/php5

---

sudo chmod a+x /etc/apache2/fcgi.bash

---

sudo a2dismod authn_file
authz_default
authz_groupfile
authz_user
autoindex
cgi
status
auth_basic
authz_user

---

sudo echo "AddHandler fcgid-script .php" >>
/etc/apache2/mods-available/fcgid.conf

---

sudo echo "FCGIWrapper /etc/apache2/fcgi.bash .php" >>
/etc/apache2/mods-available/fcgid.conf

---

I love Apache and live by Debian, but, it's disgusting that they think
it's alright to violate FHS and Debian supports it because Apache
foundation does and they don't want to "alienate" users. While one could
argue against /srv/www it's well within FHS.

sudo rm -rf /var/www
mkdir -p /srv/www

---

sudo vim /etc/apache2/sites-available/default
Contents:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /srv/www

<Directory /srv/www/>
Options -Indexes +FollowSymLinks -MultiViews +ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>

LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

---

echo "<?php phpinfo();" > /srv/www/index.php

---

chown www-data:www-data /srv/www/index.php

---

sudo service apache2 restart

---

firefox http://localhost

---

Oh hai, how are you today FCGI and PHP? Nice to see you...

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-08-2011, 08:11 AM
Wipe_Out
 
Default Apache and PHP with fcgi on 10.04

Thanks Jordon.. I will give it a try..

On 8 August 2011 00:10, Jordon Bedwell <jordon@envygeeks.com> wrote:

Snippet from Wipe_Out On 07/08/11 14:13:

> Any help converting from what I have setup to an fcgi setup would be appreciated..



I'm only going to show you how to do barebones, this will get you up and

running but this isn't secure at all without some sort of real ACL and

suexec, but then again, I don't remember the last time one of my clients

put up an ACL before I was there o.O most of them think suexec is good

enough. *Anyways suexec is easy enough to install and configure so I'll

just give you the basics:



---



sudo apt-get install php5-cgi

apache2

libapache2-mod-fcgid

apache2-mpm-itk --no-install-recommends



---



sudo vim /etc/apache2/fcgi.bash

Contents:



#!/bin/sh



# The basics

export PHPRC=/etc/php5/cgi/

export PHP_FCGI_CHILDREN=3

export PHP_FCGI_MAX_REQUESTS=5000



# Time for the fun

exec /usr/lib/cgi-bin/php5



---



sudo chmod a+x /etc/apache2/fcgi.bash



---



sudo a2dismod authn_file

authz_default

authz_groupfile

authz_user

autoindex

cgi

status

auth_basic

authz_user



---



sudo echo "AddHandler fcgid-script .php" >>

/etc/apache2/mods-available/fcgid.conf



---



sudo echo "FCGIWrapper /etc/apache2/fcgi.bash .php" >>

/etc/apache2/mods-available/fcgid.conf



---



I love Apache and live by Debian, but, it's disgusting that they think

it's alright to violate FHS and Debian supports it because Apache

foundation does and they don't want to "alienate" users. While one could

argue against /srv/www it's well within FHS.



sudo rm -rf /var/www

mkdir -p /srv/www



---



sudo vim /etc/apache2/sites-available/default

Contents:



<VirtualHost *:80>

* * * *ServerAdmin webmaster@localhost



* * * *DocumentRoot /srv/www



* * * *<Directory /srv/www/>

* * * * * * * *Options -Indexes +FollowSymLinks -MultiViews +ExecCGI

* * * * * * * *AllowOverride None

* * * * * * * *Order allow,deny

* * * * * * * *allow from all

* * * *</Directory>



* * * *LogLevel warn

* * * *ErrorLog ${APACHE_LOG_DIR}/error.log

* * * *CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>



---



echo "<?php phpinfo();" > /srv/www/index.php



---



chown www-data:www-data /srv/www/index.php



---



sudo service apache2 restart



---



firefox http://localhost



---



Oh hai, how are you today FCGI and PHP? Nice to see you...



--

ubuntu-users mailing list

ubuntu-users@lists.ubuntu.com

Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-08-2011, 06:36 PM
Ric Moore
 
Default Apache and PHP with fcgi on 10.04

On Mon, 2011-08-08 at 09:11 +0100, Wipe_Out wrote:
> Thanks Jordon.. I will give it a try..

Please don't top post and trim the cruft. Thanx, Ric
--
My father, Victor Moore (Vic) used to say:
"There are two Great Sins in the world...
..the Sin of Ignorance, and the Sin of Stupidity.
Only the former may be overcome." R.I.P. Dad.
Linux user# 44256


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-08-2011, 09:54 PM
Wipe_Out
 
Default Apache and PHP with fcgi on 10.04

Jordon.. Have got it working.. Thanks for the input.. Going to start tuning it to my needs now..
Can you clarify some things for me..
I am running mpm-itk and using it to execute php as the owner of the files in the virtual server..

I*understand*that for each virtual server a new php process will be created and will remain until the time out or the number of requests has been filled..
Will more than one php process ever be created for a single virtual server? If so how is this controlled?

If I wanted to use APC I would I need to restrict the number of processes for a virtual server to 1 so that it doesn't chew up all the server memory with a separate cache per process?

I have a virtual server with only 512MB ram hosting a couple of drupal sites so APC would be useful but I need to make sure the fcgi processes don't saturate the memory..
Thanks.


On 8 August 2011 09:11, Wipe_Out <wipe_out@users.sourceforge.net> wrote:

Thanks Jordon.. I will give it a try..

On 8 August 2011 00:10, Jordon Bedwell <jordon@envygeeks.com> wrote:


Snippet from Wipe_Out On 07/08/11 14:13:

> Any help converting from what I have setup to an fcgi setup would be appreciated..



I'm only going to show you how to do barebones, this will get you up and

running but this isn't secure at all without some sort of real ACL and

suexec, but then again, I don't remember the last time one of my clients

put up an ACL before I was there o.O most of them think suexec is good

enough. *Anyways suexec is easy enough to install and configure so I'll

just give you the basics:



---



sudo apt-get install php5-cgi

apache2

libapache2-mod-fcgid

apache2-mpm-itk --no-install-recommends



---



sudo vim /etc/apache2/fcgi.bash

Contents:



#!/bin/sh



# The basics

export PHPRC=/etc/php5/cgi/

export PHP_FCGI_CHILDREN=3

export PHP_FCGI_MAX_REQUESTS=5000



# Time for the fun

exec /usr/lib/cgi-bin/php5



---



sudo chmod a+x /etc/apache2/fcgi.bash



---



sudo a2dismod authn_file

authz_default

authz_groupfile

authz_user

autoindex

cgi

status

auth_basic

authz_user



---



sudo echo "AddHandler fcgid-script .php" >>

/etc/apache2/mods-available/fcgid.conf



---



sudo echo "FCGIWrapper /etc/apache2/fcgi.bash .php" >>

/etc/apache2/mods-available/fcgid.conf



---



I love Apache and live by Debian, but, it's disgusting that they think

it's alright to violate FHS and Debian supports it because Apache

foundation does and they don't want to "alienate" users. While one could

argue against /srv/www it's well within FHS.



sudo rm -rf /var/www

mkdir -p /srv/www



---



sudo vim /etc/apache2/sites-available/default

Contents:



<VirtualHost *:80>

* * * *ServerAdmin webmaster@localhost



* * * *DocumentRoot /srv/www



* * * *<Directory /srv/www/>

* * * * * * * *Options -Indexes +FollowSymLinks -MultiViews +ExecCGI

* * * * * * * *AllowOverride None

* * * * * * * *Order allow,deny

* * * * * * * *allow from all

* * * *</Directory>



* * * *LogLevel warn

* * * *ErrorLog ${APACHE_LOG_DIR}/error.log

* * * *CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>



---



echo "<?php phpinfo();" > /srv/www/index.php



---



chown www-data:www-data /srv/www/index.php



---



sudo service apache2 restart



---



firefox http://localhost



---



Oh hai, how are you today FCGI and PHP? Nice to see you...



--

ubuntu-users mailing list

ubuntu-users@lists.ubuntu.com

Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users





--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-08-2011, 10:21 PM
Wipe_Out
 
Default Apache and PHP with fcgi on 10.04

On 8 August 2011 19:36, Ric Moore <wayward4now@gmail.com> wrote:

On Mon, 2011-08-08 at 09:11 +0100, Wipe_Out wrote:

> Thanks Jordon.. I will give it a try..



Please don't top post and trim the cruft. Thanx, Ric


Sorry Ric.. Haven't used lists for a while and forgot the protocol..*

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-08-2011, 11:59 PM
Jordon Bedwell
 
Default Apache and PHP with fcgi on 10.04

On 08/08/11 16:54, Wipe_Out wrote:
> Jordon.. Have got it working.. Thanks for the input.. Going to start tuning it
> to my needs now..

No problem. I'm here to help.

> I understand that for each virtual server a new php process will be created and
> will remain until the time out or the number of requests has been filled..

Yes, this is correct, read below for more info on that.

> Will more than one php process ever be created for a single virtual server? If
> so how is this controlled?

Well it's a complicated algorithm IMO when it comes to optimising
processes. Theoretically for such a small server slightly more spawns
(some people and yes one client did take this quite literally and called
me and hour later saying he spawned 100 children and raced his server,
he got mad when I laughed at him on the phone, I found that quite
funny), you also want less requests so you can that you collect better
but for a rapid server where things are constantly evolving in traffic,
spawning causes latency which you don't want at all. Overhead is
overhead is OVERHEAD is THIS SYSADMIN SUCKS FIRE HIM on a busy server.
So you start adjusting requests and then after a determined amount of
requests you start to spawn more children and lowering requests and
adjusting based on what you experience in most latent times. Right now
I would suggest you up children spawns to 5 and lower requests to
n<100-300 so it starts collecting faster. If you see processes that sit
around all day then lower your spawns first and increment your requests
per child on a need be basis.

To clarify my horrible run on English:
If Children is defaulted to 3:
Small Server == Slightly more children w/ less requests
Medium Server == Slightly more children with slightly more requests
Large Server == High requests per child, children adjusted by analysis.

So by that:
Small Server == 3 - 7 children with 100-300 requests per.
Medium Server == 3 - 11 children with 300-1300 requests per.
Large Server == Switch to FPM with 1300 to n-optimised requests per.
^ To clarify Large, you'll still need to optimise startup children too.
Past large server I won't explain, that will just complicate things.

You can get into a lot more trouble with FPM, believe me on that, even
though it's meant to make management easier, it's easiness can destroy
some sysadmins who do not pay attention and just leave it as it is, talk
about some overhead. With normal FCGI you have to pay attention or it's
game over, with FPM it's only game over after the goalie takes a
football to the eye and gets knocked out. I've seen guys who are
spawning so many children at once with FPM their server just gives up
and calls it, hits the shower. It's not even gonna play this game,
forfeit. So you have to think about that when you start building your
server, and a lot of people who manage their own servers don't think
about that at all until they have that WTF MY SERVER IS DEAD moment.

---

If you want dynamic children you'll need to uninstall php5-cgi and
install php5-fpm (which Ubuntu and Debian now both include because it's
now apart of PHP since 5.3 if I remember right, could be a revision off)

> If I wanted to use APC I would I need to restrict the number of processes for a
> virtual server to 1 so that it doesn't chew up all the server memory with a
> separate cache per process?

No the APC cache is shared.

> I have a virtual server with only 512MB ram hosting a couple of drupal sites so
> APC would be useful but I need to make sure the fcgi processes don't saturate
> the memory..

Well, since I don't know the stats of your server I can't say for sure
if it would be harmful or helpful. At this point based on the specs
you've given me I can assume it would be harmful because the server
already lacks the visitors to justify constant caching, but then again
one could argue that caching would speed up requests when there are very
few requests, but I could come back with there being an abundant amount
of resources available so it would be a waste of memory that could be
used for oh snap moments. I can argue with myself over this all day,
don't dare me to.

---

A lot of what I said is based on work experience but every server is
different so I tried to highlight that you need to analyse things on a
per server and client basis and not go off a general algorithm because
every case is very different. The algorithm only defines the base set
of rules, you need to adjust the algorithm on your own.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-09-2011, 03:10 PM
Wipe_Out
 
Default Apache and PHP with fcgi on 10.04

On 9 August 2011 00:59, Jordon Bedwell <jordon@envygeeks.com> wrote:

On 08/08/11 16:54, Wipe_Out wrote:

So by that:

Small Server == 3 - 7 children with 100-300 requests per.

Medium Server == 3 - 11 children with 300-1300 requests per.

Large Server == Switch to FPM with 1300 to n-optimised requests per.

^ To clarify Large, you'll still need to optimise startup children too.

Past large server I won't explain, that will just complicate things.



According to the apache website..PHP child process management (PHP_FCGI_CHILDREN) should always be disabled with mod_fcgid, which will only route one request at a time to application processes it has spawned; thus, any child processes created by PHP will not be used effectively. (Additionally, the PHP child processes may not be terminated properly.) By default, and with the environment variable setting*PHP_FCGI_CHILDREN=0, PHP child process management is disabled.
Ref :*http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

Is this something you would agree with?
My guess is that would mean APC wouldn't work similar to running php-cgi..

---



If you want dynamic children you'll need to uninstall php5-cgi and

install php5-fpm (which Ubuntu and Debian now both include because it's

now apart of PHP since 5.3 if I remember right, could be a revision off)


Just checked.. Its 5.3.3.. I'm on 10.04 which has 5.3.2..*
FPM does sound like the answer to everything with all the*benefits*and addressing all the drawbacks.. At least thats what it says on the tin..

Thanks..
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-13-2011, 11:04 PM
Wipe_Out
 
Default Apache and PHP with fcgi on 10.04

On 8 August 2011 00:10, Jordon Bedwell <jordon@envygeeks.com> wrote:


Snippet from Wipe_Out On 07/08/11 14:13:

---


sudo apt-get install php5-cgi

apache2

libapache2-mod-fcgid

apache2-mpm-itk --no-install-recommends



---



sudo vim /etc/apache2/fcgi.bash

Contents:



#!/bin/sh



# The basics

export PHPRC=/etc/php5/cgi/

export PHP_FCGI_CHILDREN=3

export PHP_FCGI_MAX_REQUESTS=5000



# Time for the fun

exec /usr/lib/cgi-bin/php5



---



sudo chmod a+x /etc/apache2/fcgi.bash



--

sudo echo "AddHandler fcgid-script .php" >>

/etc/apache2/mods-available/fcgid.conf



---



sudo echo "FCGIWrapper /etc/apache2/fcgi.bash .php" >>

/etc/apache2/mods-available/fcgid.conf



---


*

Hi Jordon,
I have tried the basic setup you suggested along with others I have found via google but I can't get it to work..

Chrome shows this error..Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

The error log for the virtual server shows.
root@server1:~# tail /home/www.site.com/logs/error.log*

[Sat Aug 13 19:37:37 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7426*
[Sat Aug 13 19:37:39 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7427*
[Sat Aug 13 19:37:40 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7428*

[Sat Aug 13 19:37:41 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7429*
[Sat Aug 13 19:37:45 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7430*
[Sat Aug 13 19:40:00 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7442*

[Sat Aug 13 19:41:27 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7444*
[Sat Aug 13 20:06:56 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7469*
[Sat Aug 13 20:07:07 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7470*

[Sat Aug 13 20:07:07 2011] [emerg] (13)Permission denied: mod_fcgid: can't get lock in pid 7471

Any ideas why this is*happening?

Thanks..
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 07:01 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org