nginx with php with Concrete5 CMS - incomplete
This post is "incomplete" because although Concrete5 is installed correctly and works, I can't get pretty links to work right with nginx. Maybe this will still be useful for somebody! ...
Hey all,
In this post we'll see how to setup nginx with PHP support and as an example set up Concrete5 CMS.
Note:
This post has been partially based on this post and the nginx PHP configuration on this one.
Prerequisites:
Let's get started:
1. Make sure those packages are installed so they don't have to be installed by the ports.
pkg_add -r tcl85 wget curl unzip
2. Install nginx from ports:
cd /usr/ports/www/nginx;time make install clean
When prompted for the nginx options make sure you add HTTP_SSL_MODULE:
took less than a minute to compile.
3. Install PHP5:
cd /usr/ports/lang/php5;time make install clean
Take the default options and continue.
This took about 3 minutes.
4. Now install the PHP5 extensions:
cd /usr/ports/lang/php5-extensions/;time make install clean
When prompted for the php5-extensions 1.5 options make sure to add:
GD, MYSQL, MYSQLI
Make sure to remove:
PDO_SQLITE,
Also remove:
SQLITE,SQLITE3
take the default options for all other ports.
This took about 6 minutes.
5. Install spawn-fcgi to start/stop PHP:
pkg_add -r spawn-fcgi
6. Start spawn-fcgi:
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/local/bin/php-cgi
7. Make sure it's working:
sockstat -4 | grep 9000
You should see something like:
www php-cgi 42253 0 tcp4 127.0.0.1:9000 *:*
8. Edit /etc/rc.conf and add nginx and spawn-fastcgi so they start up when FreeBSD boots up:
ee /etc/rc.conf
add the lines:
nginx_enable="YES"
spawn_fcgi_enable="YES"
From now on to start/stop/restart spawn-fastcgi do the following:
Start:
/usr/local/etc/rc.d/spawn-fcgi start
Stop:
/usr/local/etc/rc.d/spawn-fcgi stop
Restart:
/usr/local/etc/rc.d/spawn-fcgi restart
Same with nginx:
Start:
/usr/local/etc/rc.d/nginx start
Stop:
/usr/local/etc/rc.d/nginx stop
Restart:
/usr/local/etc/rc.d/nginx restart
9. Create the directories for Concrete5 and enter that directory:
mkdir /var/www; cd /var/www
10. Download the source code of Concrete5 (latest version as of the time this post was written: 5.5.1 - January 23, 2012)
wget http://www.concrete5.org/download_file/-/view/33453/
11. Rename the file:
mv index.html concrete.zip
12. Unzip:
unzip concrete.zip
13. Move the files to the correct location:
mv concrete5.5.0/* .
14. Change the permissions:
chown -R www:www config/ packages/ files/
15. Enter the nginx directory:
cd /usr/local/etc/nginx/
16. Edit the nginx.conf file:
ee nginx.conf
delete all lines and replace with:
worker_processes 1;
error_log /var/log/error.log;
events { worker_connections 1024; }
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root /var/www/;
location / {
try_files $uri $uri/ /index.php;
}
include fastcgi_params;
}
}
17. Edit the fastcgi_params file:
ee fastcgi_params
Replace the contents with:
fastcgi_intercept_errors on;
location ~ .php {
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
18. Restart nginx and fastcgi
/usr/local/etc/rc.d/nginx restart
/usr/local/etc/rc.d/spawn-fcgi restart
19. Try out Concrete5:
Use a browser and point to your FreeBSD box:
http://freebsdboxipaddress/index.php
You should see this:
20. Before clicking 'Continue to installation', go to MySQL, we need to create a database for Concrete5:
mysql
You'll get the MySQL prompt:
mysql>
Create the database:
create database concrete5;
You should get this as confirmation:
mysql> create database concrete5;
Query OK, 1 row affected (0.00 sec)
20. Go back to the web interface. Click 'Continue to installation'
21. You'll get this screen: