Changes between Initial Version and Version 1 of TutorialHowToInstallDolphinOnNginx


Ignore:
Timestamp:
Oct 7, 2010, 2:59:48 AM (14 years ago)
Author:
AlexT
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TutorialHowToInstallDolphinOnNginx

    v1 v1  
     1 
     2= How to setup Dolphin on Nginx webserver = 
     3 
     4 
     5[http://nginx.org/ Nginx] is great web-server, many high performance sites are using Nginx. Dolphin can perform better on it too. 
     6 
     7First you need to setup Nginx and configure it as usual. [http://wiki.nginx.org/Main This] is great documentation resource where you can find all the information about Nginx and how to setup it.   
     8 
     9Second step is to turn on serving PHP pages, you can configure it as any other php application using many tutorials [http://wiki.nginx.org/Configuration here]. 
     10 
     11The difference in dolphin setup is in rewrite rules, use the following rewrite rules: 
     12 
     13{{{ 
     14        # blogs rewrite 
     15        rewrite "^/path_to_dolphin/blogs[/]{0,1}$"   /path_to_dolphin/modules/boonex/blogs/blogs.php last;        rewrite "^/path_to_dolphin/blogs/all[/]{0,1}$"  /path_to_dolphin/modules/boonex/blogs/blogs.php?action=all last; 
     16        rewrite "^/path_to_dolphin/blogs/all/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?page=$2&per_page=$1 last; 
     17        rewrite "^/path_to_dolphin/blogs/top[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=top_blogs last;        rewrite "^/path_to_dolphin/blogs/top/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=top_blogs&page=$2&per_page=$1 last; 
     18        rewrite "^/path_to_dolphin/blogs/top_posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=top_posts last; 
     19        rewrite "^/path_to_dolphin/blogs/top_posts/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=top_posts&page=$2&per_page=$1 last; 
     20        rewrite "^/path_to_dolphin/blogs/tag/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=search_by_tag&tagKey=$1 last; 
     21        rewrite "^/path_to_dolphin/blogs/tag[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=search_by_tag&tagKey= last; 
     22        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)/tag/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=search_by_tag&tagKey=$2&ownerName=$1 last; 
     23        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)/category/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2 last; 
     24        rewrite "^/path_to_dolphin/blogs/entry/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_post&postUri=$1 last; 
     25        rewrite "^/path_to_dolphin/blogs/entry[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_post&postUri= last; 
     26        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName=$1 last; 
     27        rewrite "^/path_to_dolphin/blogs/posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName= last; 
     28        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName=$1&page=$3&per_page=$2 last; 
     29        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)/category/([^/.]+)/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2&page=$4&per_page=$3 last; 
     30        rewrite "^/path_to_dolphin/blogs/home[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=home last; 
     31        rewrite "^/path_to_dolphin/blogs/all_posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=all_posts last; 
     32        rewrite "^/path_to_dolphin/blogs/popular_posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=popular_posts last; 
     33        rewrite "^/path_to_dolphin/blogs/featured_posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=featured_posts last; 
     34        rewrite "^/path_to_dolphin/blogs/tags[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=tags last; 
     35        rewrite "^/path_to_dolphin/blogs/show_calendar[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_calendar last; 
     36        rewrite "^/path_to_dolphin/blogs/my_page[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=my_page&mode=main last; 
     37        rewrite "^/path_to_dolphin/blogs/my_page/add[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=my_page&mode=add last; 
     38        rewrite "^/path_to_dolphin/blogs/my_page/manage[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=my_page&mode=manage last; 
     39        rewrite "^/path_to_dolphin/blogs/my_page/pending[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=my_page&mode=pending last; 
     40        rewrite "^/path_to_dolphin/blogs/my_page/edit/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=edit_post&EditPostID=$1 last; 
     41        rewrite "^/path_to_dolphin/blogs/member_posts/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerID=$1 last; 
     42        rewrite "^/path_to_dolphin/blogs/category/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=category&uri=$1 last; 
     43 
     44        # ads rewrite 
     45        rewrite "^/path_to_dolphin/ads(/|)$" /path_to_dolphin/modules/boonex/ads/classifieds.php?Browse=1 last; 
     46        rewrite "^/path_to_dolphin/ads/my_page[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page last; 
     47        rewrite "^/path_to_dolphin/ads/my_page/add[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=add last; 
     48        rewrite "^/path_to_dolphin/ads/my_page/edit/([0-9]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=add&EditPostID=$1 last; 
     49        rewrite "^/path_to_dolphin/ads/my_page/edit/([0-9]+)/dimg/([0-9]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=add&EditPostID=$1&dimg=$2 last; 
     50        rewrite "^/path_to_dolphin/ads/my_page/manage[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=manage last; 
     51        rewrite "^/path_to_dolphin/ads/my_page/pending[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=pending last; 
     52        rewrite "^/path_to_dolphin/ads/my_page/disapproved[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=disapproved last; 
     53        rewrite "^/path_to_dolphin/ads/cat/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?catUri=$1 last; 
     54        rewrite "^/path_to_dolphin/ads/all/cat/([0-9]+)/([0-9]+)/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?catUri=$3&page=$2&per_page=$1 last; 
     55        rewrite "^/path_to_dolphin/ads/subcat/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?scatUri=$1 last; 
     56        rewrite "^/path_to_dolphin/ads/all/subcat/([0-9]+)/([0-9]+)/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?scatUri=$3&page=$2&per_page=$1 last; 
     57        rewrite "^/path_to_dolphin/ads/entry/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?entryUri=$1 last; 
     58        rewrite "^/path_to_dolphin/ads/tag/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds_tags.php?tag=$1 last; 
     59        rewrite "^/path_to_dolphin/ads/calendar[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_calendar last; 
     60        rewrite "^/path_to_dolphin/ads/categories[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_categories last; 
     61        rewrite "^/path_to_dolphin/ads/tags[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=tags last; 
     62        rewrite "^/path_to_dolphin/ads/all_ads[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_all_ads last; 
     63        rewrite "^/path_to_dolphin/ads/top_ads[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_top_rated last; 
     64        rewrite "^/path_to_dolphin/ads/popular_ads[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_popular last; 
     65        rewrite "^/path_to_dolphin/ads/featured_ads[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_featured last; 
     66 
     67        # search by tag rewrite 
     68        rewrite "^/path_to_dolphin/search/tag/([^/.]+)[/]*$" /path_to_dolphin/search.php?Tags=$1 last; 
     69 
     70        # browse members rewrite 
     71        rewrite "^/path_to_dolphin/browse/([^/.]+)/([^/.]+)/([^/.]+)$" /path_to_dolphin/browse.php?sex=$1&age=$2&country=$3 last; 
     72 
     73        # forum rewrite 
     74        rewrite "^/path_to_dolphin/forum/groups/(.*)$" /path_to_dolphin/forum/$1?orca_integration=groups; 
     75        rewrite "^/path_to_dolphin/forum/events/(.*)$" /path_to_dolphin/forum/$1?orca_integration=events; 
     76        rewrite "^/path_to_dolphin/forum/store/(.*)$" /path_to_dolphin/forum/$1?orca_integration=store; 
     77        rewrite "^/path_to_dolphin/forum/$" /path_to_dolphin/modules/boonex/forum/index.php last; 
     78        rewrite "^/path_to_dolphin/forum/(.*)$" /path_to_dolphin/forum/$1; 
     79 
     80        rewrite "^/path_to_dolphin/forum/group/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&cat_id=$1 last; 
     81        rewrite "^/path_to_dolphin/forum/forum/(.+)-([0-9]+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&forum_id=$1&start=$2 last; 
     82        rewrite "^/path_to_dolphin/forum/forum/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&forum_id=$1&start=0 last; 
     83        rewrite "^/path_to_dolphin/forum/topic/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&topic_id=$1 last; 
     84        rewrite "^/path_to_dolphin/forum/user/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&user=$1 last; 
     85 
     86        rewrite "^/path_to_dolphin/forum/rss/forum/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=rss_forum&forum=$1 last; 
     87        rewrite "^/path_to_dolphin/forum/rss/topic/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=rss_topic&topic=$1 last; 
     88        rewrite "^/path_to_dolphin/forum/rss/user/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=rss_user&user=$1 last; 
     89        rewrite "^/path_to_dolphin/forum/rss/all\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=rss_all&sort= last; 
     90 
     91        rewrite "^/path_to_dolphin/forum/(.*)$" /path_to_dolphin/modules/boonex/forum/$1 last; 
     92 
     93        # pages rewrite 
     94        rewrite "^/path_to_dolphin/page/(.*)$" /path_to_dolphin/viewPage.php?ID=$1 last; 
     95 
     96        # modules rewrite  
     97        rewrite ^/path_to_dolphin/m/(.*)$ /path_to_dolphin/modules/index.php?r=$1 last; 
     98 
     99        # profile rewrite 
     100        if (!-e $request_filename ) { 
     101            rewrite  ^/path_to_dolphin/([^/]+)$  /path_to_dolphin/profile.php?ID=$1  last; 
     102            break; 
     103        } 
     104}}} 
     105 
     106Now everything should work, but some optimisation is needed. 
     107Add the following rules to tell Nginx to server static files directly, it will also tell user's browser to cache them for 1 month: 
     108 
     109{{{ 
     110    # serve static files directly 
     111    location ~* ^\/path_to_dolphin.+(templates|flash|media|plugins)\/.+\.(jpg|jpeg|gif|css|png|js|ico)$ { 
     112        access_log        off; 
     113        expires           30d; 
     114    } 
     115}}} 
     116 
     117If you don't have below lines in your Nginx configuration it is better to add it too: 
     118 
     119{{{ 
     120    # deny access to .htaccess files, if Apache's document root 
     121    # concurs with nginx's one 
     122    # 
     123    location ~ /\.ht { 
     124        deny  all; 
     125    } 
     126}}} 
     127 
     128Replace '''path_to_dolphin''' to your real path in all above configurations, or if Dolphin is installed in root folder of your domain then just remove '''/path_to_dolphin''' part from every rule. Place above rules to '''location {''' clause for your particular Dolphin folder. 
     129 
     130Some more optimisation is possible, add these lines to '''http {''' clause of Nginx configuration file to enable on the fly compression: 
     131 
     132{{{ 
     133    gzip_http_version 1.1; 
     134    gzip_min_length 200; 
     135    gzip_vary on; 
     136    gzip_comp_level 6; 
     137    gzip_proxied any; 
     138    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 
     139    gzip_buffers 16 8k; 
     140}}} 
     141 
     142All the optimisation steps described [http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Web-server here] are already applied in above configurations.  
     143 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
Fork me on GitHub