注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Package:PHP"

From Funtoo
Jump to navigation Jump to search
(initial commit (more to come, just want to save what ive got so far))
 
 
(9 intermediate revisions by 2 users not shown)
Line 9: Line 9:
== Install ==
== Install ==
=== Use Flags ===
=== Use Flags ===
By default php does not have the cgi, FPM/FastCGI, mysql, mysqli, apache2 use flag turned on.
By default php does not have the cgi, FPM/FastCGI, mysql, mysqli, apache2 use flag turned on.  Many packages are php aware, set the php global use flag so other applications can interact with php.


{{file|name=/usr/portage/make.conf|desc=insert desired use flags|body=
{{file|name=/etc/portage/make.conf|desc=insert desired use flags|body=
USE="mysql mysqli apache2 fpm cgi......"
USE="php mysql mysqli apache2 fpm cgi......"
}}
}}


Line 19: Line 19:


== Fpm ==
== Fpm ==
Fpm is a php handler.
Fpm is a php handler.  It is php daemonized.


=== init ===
=== init ===
Line 32: Line 32:


Php-fpm is controlled by <code>/etc/php/fpm-php*.*/php-fpm.conf</code> and <code>/etc/php/fpm-php*.*/php.ini</code>
Php-fpm is controlled by <code>/etc/php/fpm-php*.*/php-fpm.conf</code> and <code>/etc/php/fpm-php*.*/php.ini</code>
==== tips ====
==== Unix Socket ====
{{file|name=/etc/php/fpm-php5.6/php-fpm.conf|lang=|desc=use a unix socket for speed, security, and not consuming a port.|body=
listen = /var/run/php-fpm/php-fpm.sock
listen.backlog = -1
listen.owner = apache
listen.group = apache
listen.mode=0660
}}
==== Change Php Fpm's User/Group ====
This is for php-fpm worker processes permissions.  Making php-fpm workers work as the apache user makes most apache permission configurations work with out a bother.
{{file|name=/etc/php/fpm-php5.6/php-fpm.conf|lang=|desc=make workers run as another user|body=
;user = nobody
;group = nobody
user = apache
group = apache
}}
==== Limiting Workers ====
Limit worker numbers to 20 max.  When your server is behind a reverse proxy it doesn't need many workers.
{{file|name=/etc/php/fpm-php5.6/php-fpm.conf|lang=|desc=limit workers|body=
pm.max_children = 20
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 19
}}
==== Date & Time ====
Set the time and date for php web applications.  [http://php.net/manual/en/timezones.php full list of php timezones]
{{file|name=/etc/php/fpm-php5.6/php.ini|lang=|desc=set date and time|body=
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
}}
the same procedures can be done for other php implementations at
*/etc/php/cli-php5.6/php.ini
*/etc/php/apache2-php5.6/php.ini
*/etc/php/cgi-php5.6/php.ini
=== Media ===
==== Programming ====
{{#widget:YouTube|playlist=PL00694B0DAD604DE6}}
{{EbuildFooter}}
{{EbuildFooter}}

Latest revision as of 10:30, November 9, 2015

PHP

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.

Install

Use Flags

By default php does not have the cgi, FPM/FastCGI, mysql, mysqli, apache2 use flag turned on. Many packages are php aware, set the php global use flag so other applications can interact with php.

   /etc/portage/make.conf - insert desired use flags
USE="php mysql mysqli apache2 fpm cgi......"

Emerge

root # emerge php

Fpm

Fpm is a php handler. It is php daemonized.

init

To start the php-fpm service:

root # rc-service php-fpm start

To start the php-fpm service at boot:

root # rc-update add php-fpm

Configuration

Php-fpm is controlled by /etc/php/fpm-php*.*/php-fpm.conf and /etc/php/fpm-php*.*/php.ini

tips

Unix Socket

   /etc/php/fpm-php5.6/php-fpm.conf - use a unix socket for speed, security, and not consuming a port.
listen = /var/run/php-fpm/php-fpm.sock
listen.backlog = -1
listen.owner = apache
listen.group = apache
listen.mode=0660

Change Php Fpm's User/Group

This is for php-fpm worker processes permissions. Making php-fpm workers work as the apache user makes most apache permission configurations work with out a bother.

   /etc/php/fpm-php5.6/php-fpm.conf - make workers run as another user
;user = nobody
;group = nobody
user = apache
group = apache

Limiting Workers

Limit worker numbers to 20 max. When your server is behind a reverse proxy it doesn't need many workers.

   /etc/php/fpm-php5.6/php-fpm.conf - limit workers
pm.max_children = 20
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 19

Date & Time

Set the time and date for php web applications. full list of php timezones

   /etc/php/fpm-php5.6/php.ini - set date and time
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

the same procedures can be done for other php implementations at

  • /etc/php/cli-php5.6/php.ini
  • /etc/php/apache2-php5.6/php.ini
  • /etc/php/cgi-php5.6/php.ini

Media

Programming