Amazon Web Services - AWS EC2 - Ubuntu 14.04
PHP 5
1. Installation
# apt-get install php5-common php5-cli php5-fpm
# php -v
PHP 5.5.9-1ubuntu4.9 (cli) (built: Apr 17 2015 11:44:57)
2. Start
# service php5-fpm start | stop | restart | status
Determine user and group of NginX daemon (process)
#ps -aux | grep nginx
nginx 14447 0.0 0.0 106432 3204 ? S 18:38 0:00 nginx: worker process
3. PHP-FPM socket
FastCGI Process Manager - controll PHP processes.
:: socket ::
Instead of using TCP port 127.0.0.1:9000 we want to use the socket. Then in /etc/php5/fpm/pool.d/www.conf file instead
listen = 127.0.0.1:9000
put
listen = /var/run/php5-fpm.sock
After command #service php5-fpm restart file /var/run/php5-fpm.sock is created.
Notice: We don't have to configure this if it is configured by default PHP installation.
In /etc/nginx/includes/php.conf put:
#### /etc/nginx/includes/php.conf ####
# enabling PHP through php-fpm
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
Check PHP with phpinfo().
- U /usr/share/nginx/html/phpinfo.php staviti <?php phpinfo() ?>
4. PHP modules
To list all PHP modules use <?php phpinfo(); ?> or:
# php -m
4.1 Mysql
#apt-get install php5-mysql
Install mysql, mysqli, pdo-mysql PHP drivers in /etc/php5/fpm/conf.d/ automatically.
4.2 GD (Image library)
#apt-get install php5-gd
5. Misc
5.1 Enabling PHP short tags <?= variable ?>
In /etc/php5/fpm/php.ini
short_open_tag = On