Environment: Ubuntu
The PHP5 source needed for compiling additional modules
sudo apt-get install gcc php5-dev
Compiling Twig Source Code
|
git clone https://github.com/fabpot/Twig.git cd Twig/ext/twig/ sudo phpize sudo ./configure sudo make sudo make install |
Installation
PHP5
vim /etc/php5/conf.d/twig.ini
PHP5-FPM
vim /etc/php5/fpm/conf.d/twig.ini
Add the following to your twig.ini
file
Restarting
PHP5
sudo service apache2 restart
PHP5-FPM
sudo service php5-fpm restart
Install Apache2 + FastCGI + PHP-FPM
Apache Settings
/etc/apache2/sites-availabe/test.server.com.conf:
|
<VirtualHost 127.0.0.1:8080> ServerName test.server.com ServerAdmin webmaster@server.com DocumentRoot /var/www/test.server.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> |
/etc/apache2/ports.conf:
Install Nginx
sudo apt-get install nginx
/etc/nginx/sites-available/test:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
server { listen 80; root /var/www/test.server.com; index index.html index.php index.htm; server_name test.server.com; location / { # Custom 404 page # try_files $uri $uri/ /not_found_error.html; } location ~ \.php$ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; } location ~ /\.ht { deny all; } } |
sudo ln -s /etc/nginx/sites-available/test /etc/nginx/sites-enabled/test
sudo rm /etc/nginx/sites-enabled/default
Restart Server
sudo service nginx restart
sudo service apache2 restart
sudo service php5-fpm restart
Installation
|
$ sudo apt-get install apache2-mpm-worker libapache2-mod-fastcgi php5-fpm $ sudo a2enmod actions alias fastcgi |
Configuration
edit /etc/apache2/mods-enabled/fastcgi.conf
:
|
AddHandler php5-fcgi .php Action php5-fcgi /php5-fcgi Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization |
Restart Apache2 and PHP5-FPM
|
$ sudo service apache2 restart && sudo service php5-fpm restart |
— Updated 2014-01-09 (Ubuntu 13.10)–
mkdir /var/www/cgi-bin
touch /var/www/cgi-bin/php5.fcgi
chown -R www-data:www-data /var/www/cgi-bin
edit /etc/apache2/mods-enabled/fastcgi.conf
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<IfModule mod_fastcgi.c> AddHandler fastcgi-script .fcgi #FastCgiWrapper /usr/lib/apache2/suexec FastCgiIpcDir /var/lib/apache2/fastcgi Alias /php5.fcgi /var/www/cgi-bin/php5.fcgi AddType application/x-httpd-fastphp5 .php Action application/x-httpd-fastphp5 /php5.fcgi FastCGIExternalServer /var/www/cgi-bin/php5.fcgi -socket /var/run/php5-fpm.sock <Directory "/var/www/cgi-bin"> Order allow,deny <Files "php5.fcgi"> Order deny,allow </Files> </Directory> </IfModule> |
Virtual host setting example :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<VirtualHost *:80> # Admin email, Server Name (domain name), and any aliases ServerAdmin webmaster@email.com ServerName www.example.com # ServerAlias example.com # Index file and Document Root (where the public files are located) DirectoryIndex index.php index.html index.htm DocumentRoot /var/www/example <Directory /var/www/example> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all Require all granted </Directory> # Log file locations LogLevel warn ErrorLog ${APACHE_LOG_DIR}/error.example.com.log CustomLog ${APACHE_LOG_DIR}/access.example.com.log combined </VirtualHost> |
References
Continue Reading
Nginx with Apache + FastCGI + PHP-FPM