Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
nndocs:lamp [2017/03/16 00:27] – [PHP] update for PHP 7.0.x, part I naptastic | nndocs:lamp [2018/07/04 00:30] – Add FIXMEs. naptastic |
---|
You'll need these: | You'll need these: |
| |
* This is so wrong | |
* ''apt-get -y install libxml2-dev zlib1g-dev libbz2-dev libcurl4-openssl-dev libjpeg8-dev libpng12-dev libmcrypt-dev libaspell-dev libpspell-dev libtidy-dev libxslt1-dev'' | * ''apt-get -y install libxml2-dev zlib1g-dev libbz2-dev libcurl4-openssl-dev libjpeg8-dev libpng12-dev libmcrypt-dev libaspell-dev libpspell-dev libtidy-dev libxslt1-dev'' |
| |
* ''<nowiki>curl http://www.php.net/get/php-7.0.16.tar.xz/from/this/mirror | xz -d | tar -x</nowiki>'' | * ''<nowiki>curl http://www.php.net/get/php-7.0.16.tar.xz/from/this/mirror | xz -d | tar -x</nowiki>'' |
* ''cd php-7.0.16/'' | * ''cd php-7.0.16/'' |
* ''<nowiki>./configure --enable-fpm --prefix=/opt/php70 --enable-bcmath --enable-calendar --enable-ftp --enable-libxml --enable-mbstring --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-mcrypt --enable-pdo --enable-soap --enable-sockets --enable-wddx --with-pcre-regex --with-pdo-mysql=shared --with-pic --with-pspell --with-tidy --with-xmlrpc --with-xsl --with-zlib --with-curl | * ''<nowiki>./configure --enable-fpm --prefix=/opt/php70 --enable-bcmath --enable-calendar --enable-ftp --enable-libxml --enable-mbstring --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-mcrypt --enable-pdo --enable-soap --enable-sockets --enable-wddx --with-pcre-regex --with-pdo-mysql=shared --with-pic --with-pspell --with-tidy --with-xmlrpc --with-xsl --with-zlib --with-curl --with-mysqli |
</nowiki>'' | </nowiki>'' |
* ''make'' | * ''make'' |
* ''make install'' | * ''make install'' |
| |
| FIXME Path is wrong |
Install ''php.ini'': | Install ''php.ini'': |
| |
* ''cp php.ini-production /usr/local/lib/php.ini'' | * ''cp php.ini-production /usr/local/lib/php.ini'' |
| |
| FIXME We use systemd service definition files now, not init scripts. |
Install the initscript: | Install the initscript: |
| |
* ''update-rc.d php-fpm defaults'' | * ''update-rc.d php-fpm defaults'' |
| |
| FIXME Path is wrong |
Install the FPM-specific configuration files. | Install the FPM-specific configuration files. |
| |
* ''mkdir -p /usr/local/etc/pools.d/'' | * ''mkdir -p /usr/local/etc/pools.d/'' |
| |
| FIXME Path is wrong |
Edit the file ''/usr/local/etc/php-fpm.conf'' and put this in it: | Edit the file ''/usr/local/etc/php-fpm.conf'' and put this in it: |
| |
error_log = /var/log/php-fpm.log | error_log = /var/log/php-fpm.log |
| |
| FIXME Path is wrong |
In ''/usr/local/etc/pools.d/'', you need to create a pool definition file for every user who will be using PHP scripts. I name them ''$username.conf''. | In ''/usr/local/etc/pools.d/'', you need to create a pool definition file for every user who will be using PHP scripts. I name them ''$username.conf''. |
| |
I'm debating whether it makes more sense to create a separate pool per-virtualhost instead of per-user. Whatever. Here's what you put in each pool definition file: | Here's what you put in each pool definition file: |
| |
[david] | [david] |
pm.max_requests = 32768 | pm.max_requests = 32768 |
;pm.status_path = /fpm-status | ;pm.status_path = /fpm-status |
| |
| FIXME Path is wrong |
| |
Of course, change 'david' to whatever username you're using. And you might have to create /usr/local/var/run/php.fpm | Of course, change 'david' to whatever username you're using. And you might have to create /usr/local/var/run/php.fpm |
| |
"But David," I hear you asking, "Why didn't you put it in /var/run?" Because /var/run is a ramdisk, so /var/run/php-fpm would have to be created every time PHP-FPM starts, and I didn't feel like hacking up the init script any more than I already do. Or I could put the socket files in /var/run not in a directory, but /var/run gets messy enough already. And since PHP's installation process treats /usr/local like its own root filesystem anyway, what the hell, let's do it. | |
| |
==== PHP-APC === | |
| |
* ''<nowiki>wget http://pecl.php.net/get/APC-3.1.13.tgz</nowiki>'' | |
* ''tar -xvf APC-3.1.13.tgz'' | |
* ''cd APC-3.1.13'' | |
* ''phpize'' | |
* ''<nowiki>./configure --enable-apc</nowiki>'' | |
* ''make'' | |
* ''make install'' | |
| |
Add this to the end of ''/usr/local/lib/php.ini'': | |
| |
extension='apc.so' | |
apc.enable=1 | |
apc.shm_size=256m | |
| |
At this point, PHP-FPM is ready to start if you want. | At this point, PHP-FPM is ready to start if you want. |
==== LAMP stack done. ==== | ==== LAMP stack done. ==== |
| |
Time to create some sites. By Debian convention, virtualhost definition files go in /etc/apache2/sites-available. By Naptastic convention, the vhost definition file is named the same as the ServerName directive contained within. If you're running Apache 2.4 (not documented yet; sorry,) add .conf to the end of the filename. | Time to create some sites. By Debian convention, VirtualHost (vhost) definition files go in /etc/apache2/sites-available. By Naptastic convention, the vhost definition file is named the same as the ServerName directive contained within, plus .conf because Apache 2.4 expects .conf. So, the vhost file for naptastic.com is named naptastic.com.conf and www.naptastic.com is a ServerAlias. |
| |
Here's the format for virtualhost files: | Here's the format for virtualhost files: |
| |
FIXME - This is specific to one site. Needs to be generalized. | FIXME - This is specific to one site. Needs to be generalized. |
| FIXME - This vhost is full of Apache 2.2 stuff and talks to FPM over a TCP socket instead of a socket file. Please update from an existing, optimized site. |