Running TYPO3 6.2 On Nginx (LEMP) On Debian Wheezy/Ubuntu 13.10

This tutorial exists for these OS versions

    On this page

    1. 1 Preliminary Note
    2. 2 Installing APC
    3. 3 Installing TYPO3
    4. 4 Links
    5. About The Author

    This tutorial shows how you can install and run a TYPO3 (version 6.2) web site on a Debian Wheezy or Ubuntu 13.10 system that has nginx installed instead of Apache (LEMP = Linux + nginx (pronounced "engine x") + MySQL + PHP). nginx is a HTTP server that uses much less resources than Apache and delivers pages a lot of faster, especially static files.

    I do not issue any guarantee that this will work for you!


    1 Preliminary Note

    I want to install TYPO3 in a vhost called here with the document root /var/www/

    You should have a working LEMP installation.

    A note for Ubuntu users:

    Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing

    sudo su


    2 Installing APC

    APC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and XCache. It is strongly recommended to have one of these installed to speed up your PHP page.

    APC can be installed as follows:

    apt-get install php-apc

    If you use PHP-FPM as your FastCGI daemon, restart it as follows:

    /etc/init.d/php5-fpm restart

    If you use lighttpd's spawn-fcgi program as your FastCGI daemon, we must kill the current spawn-fcgi process (running on port 9000) and create a new one. Run

    netstat -tap

    to find out the PID of the current spawn-fcgi process:

    root@server1:~# netstat -tap
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 *:sunrpc                *:*                     LISTEN      734/portmap
    tcp        0      0 *:www                   *:*                     LISTEN      2987/nginx
    tcp        0      0 *:ssh                   *:*                     LISTEN      1531/sshd
    tcp        0      0 *:57174                 *:*                     LISTEN      748/rpc.statd
    tcp        0      0 localhost.localdom:smtp *:*                     LISTEN      1507/exim4
    tcp        0      0 localhost.localdom:9000 *:*                     LISTEN      1542/php5-cgi
    tcp        0      0 localhost.localdo:mysql *:*                     LISTEN      1168/mysqld
    tcp        0     52      ESTABLISHED 1557/0
    tcp6       0      0 [::]:www                [::]:*                  LISTEN      2987/nginx
    tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1531/sshd
    tcp6       0      0 ip6-localhost:smtp      [::]:*                  LISTEN      1507/exim4

    In the above output, the PID is 1542, so we can kill the current process as follows:

    kill -9 1542

    Afterwards we create a new spawn-fcgi process:

    /usr/bin/spawn-fcgi -a -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/


    3 Installing TYPO3

    The document root of my web site is /var/www/ - if it doesn't exist, create it as follows:

    mkdir -p /var/www/

    Next we download TYPO3 6.2 as a .tar.gz file from and place it in our document root:

    cd /tmp
    tar xvfz typo3_src-6.2.1.tar.gz
    cd typo3_src-6.2.1/
    mv * /var/www/

    It is recommended to make the document root and the TYPO3 files in it writable by the nginx daemon which is running as user www-data and group www-data:

    chown -R www-data:www-data /var/www/

    If you haven't already created a MySQL database for TYPO3 (including a MySQL TYPO3 user), you can do that as follows (I name the database typo3 in this example, and the user is called typo3_admin, and his password is typo3_admin_password):

    mysqladmin -u root -p create typo3

    mysql -u root -p

    GRANT ALL PRIVILEGES ON typo3.* TO 'typo3_admin'@'localhost' IDENTIFIED BY 'typo3_admin_password';
    GRANT ALL PRIVILEGES ON typo3.* TO 'typo3_admin'@'localhost.localdomain' IDENTIFIED BY 'typo3_admin_password';



    Next we create an nginx vhost configuration for our vhost in the /etc/nginx/sites-available/ directory as follows:

    vi /etc/nginx/sites-available/

    server {
           listen 80;
           root /var/www/;
           if ($http_host != "") {
                     rewrite ^$request_uri permanent;
           index index.php index.html;
           location = /favicon.ico {
                    log_not_found off;
                    access_log off;
           location = /robots.txt {
                    allow all;
                    log_not_found off;
                    access_log off;
           # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
           location ~ /\. {
                    deny all;
                    access_log off;
                    log_not_found off;
            location ~ \.php$ {
                            try_files $uri =404;
                            include /etc/nginx/fastcgi_params;
                            fastcgi_pass unix:/var/run/php5-fpm.sock;
                            fastcgi_index index.php;
                            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                            fastcgi_intercept_errors on;
                            fastcgi_buffer_size 128k;
                            fastcgi_buffers 256 16k;
                            fastcgi_busy_buffers_size 256k;
                            fastcgi_temp_file_write_size 256k;
                            fastcgi_read_timeout 1200;
            client_max_body_size 100M;
            location ~ /\.(js|css)$ {
                    expires 604800s;
            if (!-e $request_filename){
                    rewrite ^/(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ /$1.$3 last;
            location ~* ^/fileadmin/(.*/)?_recycler_/ {
                    deny all;
            location ~* ^/fileadmin/templates/.*(\.txt|\.ts)$ {
                    deny all;
            location ~* ^/typo3conf/ext/[^/]+/Resources/Private/ {
                    deny all;
            location ~* ^/(typo3/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) {
            location / {
                            if ($query_string ~ ".+") {
                                    return 405;
                            if ($http_cookie ~ 'nc_staticfilecache|be_typo_user|fe_typo_user' ) {
                                    return 405;
                            } # pass POST requests to PHP
                            if ($request_method !~ ^(GET|HEAD)$ ) {
                                    return 405;
                            if ($http_pragma = 'no-cache') {
                                    return 405;
                            if ($http_cache_control = 'no-cache') {
                                    return 405;
                            error_page 405 = @nocache;
                            try_files /typo3temp/tx_ncstaticfilecache/$host${request_uri}index.html @nocache;
            location @nocache {
                            try_files $uri $uri/ /index.php$is_args$args;

    This configuration already contains everything that is needed for clean URLs (because of the try_files $uri $uri/ /index.php$is_args$args; line in the @nocache location).

    Next make sure you have the following line in /etc/nginx/mime.types:

    vi /etc/nginx/mime.types

            text/x-component                        htc;

    To enable the vhost, we create a symlink to it from the /etc/nginx/sites-enabled/ directory:

    cd /etc/nginx/sites-enabled/
    ln -s /etc/nginx/sites-available/

    Reload nginx for the changes to take effect:

    /etc/init.d/nginx reload

    Now we can launch the web-based TYPO3 installer by going to - you will be prompted to create the file FIRST_INSTALL in the document root first so that the installation can proceed:

    cd /var/www/
    chown www-data:www-data FIRST_INSTALL

    Now reload the page. The installer checks if all prerequisites are fulfilled - if you just see the warning that /typo3_src should be a link, you can continue by clicking on I know what I'm doing, continue! - if there are other warnings, you should try to fix them now:

    Next fill in the database details (user: typo3_admin; password: typo3_admin_password from when we created the typo3 database) and click on Continue:

    On the next page choose Use an existing empty database and pick typo3 from the drop-down menu. Then click on Continue:

    Next provide a username and password for the TYPO3 admin user. Click on Continue afterwards:

    The installation is now finished. If you want to start with a demo website instead of a completely empty system, leave the Yes, download the list of distributions checkbox checked (this will not install demo data immediately, but just make a demo website available in the backend from where you can choose to install it). Then click on Open the backend:

    The admin area can be found under Log in with the username admin and the password you defined during installation:

    Now the list of available demo websites is being downloaded:

    If you wish to install one of them, click on the appropriate Install button:

    After successful installation, you will see the following screen. You can ignore the RealURL warning:

    If you leave the backend, the demo site looks as follows. If you browse it, you will notice that clean URLs work by default:



    About The Author

    Falko Timme is the owner of nginx WebhostingTimme Hosting (ultra-fast nginx web hosting). He is the lead maintainer of HowtoForge (since 2005) and one of the core developers of ISPConfig (since 2000). He has also contributed to the O'Reilly book "Linux System Administration".

    Share this page:

    1 Comment(s)

    Add comment


    From: Martin Bless

    Hi Falko, thank you very much - especially for obviously trying to be complete. This howto really looks good. I'm thinking of moving to nginx for quite a while. Now I'm going to give it a try. Perfect!