User Tools

Site Tools


Writing /home/user/smartcj.com/wiki/data/cache/c/c805393073dd095e93aa073397b93b8f.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /home/user/smartcj.com/wiki/data/cache/c/c805393073dd095e93aa073397b93b8f.metadata failed
tcms_install

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tcms_install [2016/10/18 20:16] – created admintcms_install [2026/03/21 10:12] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Thumb CMS ======+====== Trade CMS ======
  
-Thumb CMS - is the next step in development of SmartCJ.+Thumb CMS - this is the next step in the development of SmartCJ.
  
-It'been almost 10 years since the first version of SmartCJ was released and it's time to move ahead and adopt new technologies. New version uses php 5.3+ and mysql 5+, please, be aware of it +We have always tried to support all possible server configurations, including those running on PHP 4 and MySQL 3.23, despite the fact that support for these versions has been discontinued ten years ago. Now it's time to take the next step in many ways.
  
 ===== What's new ===== ===== What's new =====
  
-New version has a lot of improvements +The new branch has a number of quality changes for all aspects of the script.
  
-  * DB scheme has been changed to support large Dbs with categories having 100-200-300k galleries in each category. It doesn't matter how many galleries you have in your categories - it will be really fast now+  * The database was optimized to enable fast work with databases of 200-300k thumbs in each category. Previously this was a problem, as groups with a large number of thumbs seriously slowed down the site
-  * you can run cron jobs as often as you want optimizing server load, of course you have to understand that all actions will be executed as often as you run cronjobsSo if you do that every 5 minutes - all stats we be updated only once every 5 minutes+  * Crons can be run as often as you likethis will only affect the speed of statistics updates and history saves. At the same time, crons control their own execution to avoid running duplicatesHowever, due to point 1, this may not be necessary
-  * All Db queries are optimized +  * Database selections and updates have been optimized
  
-Now the script is absolutely invisible from outside :+The script has become completely "invisible":
  
-  * you can install the script into any folder  +  * You can place the script in any folder 
-  * rewrites are simple and you can have any links  +  * Rewrites are simplified, you can make any links on the site 
-  * you can cookieless mode and script won'send any cookies to users and save cookies into internal cache. That adds a bit of load and the script can not be tracked.  +  * The script doesn'set any cookies in Cookie Engine = Cache mode or sets encoded ones in Cookie Engine = MD5 mode 
-  * You can remove [[TCMS Rotation Parameter]] and still  the script can count hits even if galleries have more that 1 rotation thumb per gallery + [[Cell K]]+  * You can remove [[TCMS Rotation Parameter]] and the script will still be able to count thumb statistics, even if there are multiple on a gallery + [[Cell K]]
  
-Also there are some brand new features+Thus the question of ranking sites by Google depending on the script will be completely removed.
  
-  * [[Thumb Split]] - that's a way to make your thumb unique by splitting an image into pieces  +A number of unique features have been added:
-  * [[FaceDetect]] - make sure that if a face has a face it won't be cut out +
  
 +  * [[Thumb Split]] - uniquification of thumbs by cutting them into multiple parts
 +  * [[FaceDetect]] - automation of thumb cutting, taking into account the position of the face to create higher quality thumbs automatically
  
  
 ===== Installation ===== ===== Installation =====
  
-Now it really easy to install the script. You don'even have to download an install file, just run the following command in SSH +Installation has become even simpler and should please admins. Now you don'need to download anything, just give the command in the shell
  
 <code> <code>
Line 36: Line 36:
 </code> </code>
  
-and the script will be installed in few seconds+and the script will be installed in interactive mode. 
 +PS yes, two dashes at the end are required
  
-PS yes , those two dashes are obligatory  +you can also specify all parameters directly in the command line
- +
-Also there are optional parameter +
  
 <code> <code>
Line 58: Line 57:
 RewriteRule ^([^/]{2})/(.*)$ $2?force_lng=$1&%{QUERY_STRING} [L] RewriteRule ^([^/]{2})/(.*)$ $2?force_lng=$1&%{QUERY_STRING} [L]
  
-RewriteRule ^category/([^/]+)/$ /script_folder_name/cgi/out.php?url=content&p=100&dont_count_in_trade=true&skip_sell=true&group_name=$1&order=ctr&%{QUERY_STRING} [L] + 
-RewriteRule ^category/([^/]+)/([^/]+)/([^/]+)/$ /script_folder_name/cgi/out.php?url=content&p=100&dont_count_in_trade=true&skip_sell=true&group_name=$1&order=$2&page=$3&%{QUERY_STRING} [L]+# add &dont_count_in_trade=true if you dont want to count these clicks 
 +RewriteRule ^category/([^/]+)/$ /script_folder_name/cgi/out.php?url=content&p=100&skip_sell=true&group_name=$1&order=ctr&%{QUERY_STRING} [L] 
 +RewriteRule ^category/([^/]+)/([^/]+)/([^/]+)/$ /script_folder_name/cgi/out.php?url=content&p=100&skip_sell=true&group_name=$1&order=$2&page=$3&%{QUERY_STRING} [L]
  
 #slug galleries #slug galleries
Line 66: Line 67:
  
 #tags #tags
-RewriteRule ^tag/([^/]+)/([^/]+)/([^/]+)/$ /script_folder_name/tube/index.php?tag=$1&page=$3&order=$2&%{QUERY_STRING} [L] +RewriteRule ^tag/([^/]+)/([^/]+)/([^/]+)/$ /?tag=$1&page=$3&order=$2&%{QUERY_STRING} [L] 
-RewriteRule ^tag/([^/]+)/([^/]+)/$ /script_folder_name/tube/index.php?tag=$1&page=$2&%{QUERY_STRING} [L] +RewriteRule ^tag/([^/]+)/([^/]+)/$ /?tag=$1&page=$2&%{QUERY_STRING} [L] 
-RewriteRule ^tag/([^/]+)/$ /script_folder_name/tube/index.php?tag=$1&%{QUERY_STRING} [L]+RewriteRule ^tag/([^/]+)/$ /?tag=$1&%{QUERY_STRING} [L]
  
 #model galleries #model galleries
-RewriteRule ^model_galleries/([^/]+)//script_folder_name/tube/?model_slug=$1&force_template=model_galleries [L] +RewriteRule ^model_galleries/([^/]+)/$ /?model_slug=$1&force_template=model_galleries [L] 
-RewriteRule ^model_galleries/([^/]+)/([^/]+)//script_folder_name/tube/?model_slug=$1&page=$2&force_template=model_galleries [L]+RewriteRule ^model_galleries/([^/]+)/([^/]+)/$ /?model_slug=$1&page=$2&force_template=model_galleries [L]
  
-RewriteRule ^model/([^/]+)//script_folder_name/tube/?model_slug=$1&force_template=model_galleries&%{QUERY_STRING} [L] +RewriteRule ^model/([^/]+)/$ /?model_slug=$1&force_template=model_galleries&%{QUERY_STRING} [L] 
-RewriteRule ^model/([^/]+)/([^/]+)/([^/]+)//script_folder_name/tube/?model_slug=$1&force_template=model_galleries&order=$2&page=$3&%{QUERY_STRING} [L]+RewriteRule ^model/([^/]+)/([^/]+)/([^/]+)/$ /?model_slug=$1&force_template=model_galleries&order=$2&page=$3&%{QUERY_STRING} [L]
  
-RewriteRule ^search/([^/]+)/([^/]+)/$ /script_folder_name/tube/index.php?search=$1&page=$2&%{QUERY_STRING} +RewriteRule ^search/([^/]+)/([^/]+)/$ /?search=$1&page=$2&%{QUERY_STRING} 
-RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)/$ /script_folder_name/tube/index.php?search=$1&order=$2&page=$3&%{QUERY_STRING}+RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)/$ /?search=$1&order=$2&page=$3&%{QUERY_STRING}
  
 </code>  </code> 
  
  
-For NGINX+For nginx
  
 <code>  <code> 
Line 118: Line 119:
  
  location /tag {   location /tag { 
- rewrite ^/tag/([^/]+)/([^/]+)/([^/]+)/$ /script_folder_name/tube/index.php?tag=$1&page=$3&order=$2&$query_string ;  + rewrite ^/tag/([^/]+)/([^/]+)/([^/]+)/$ /?tag=$1&page=$3&order=$2&$query_string ;  
- rewrite ^/tag/([^/]+)/([^/]+)/$ /script_folder_name/tube/index.php?tag=$1&page=$2&$query_string ;  + rewrite ^/tag/([^/]+)/([^/]+)/$ /?tag=$1&page=$2&$query_string ;  
- rewrite ^/tag/([^/]+)/$ /script_folder_name/tube/index.php?tag=$1&$query_string ; + rewrite ^/tag/([^/]+)/$ /?tag=$1&$query_string ; 
  }  }
  
  
  location /model_galleries {   location /model_galleries { 
- rewrite ^/model_galleries/([^/]+)//script_folder_name/tube/?model_slug=$1&force_template=model_galleries ;  + rewrite ^/model_galleries/([^/]+)/$ /?model_slug=$1&force_template=model_galleries ;  
- rewrite ^/model_galleries/([^/]+)/([^/]+)//script_folder_name/tube/?model_slug=$1&page=$2&force_template=model_galleries ; + rewrite ^/model_galleries/([^/]+)/([^/]+)/$ /?model_slug=$1&page=$2&force_template=model_galleries ; 
  
   
  location /model {   location /model { 
- rewrite ^/model/([^/]+)//script_folder_name/tube/?model_slug=$1&force_template=model_galleries&$query_string ;  + rewrite ^/model/([^/]+)/$ /?model_slug=$1&force_template=model_galleries&$query_string ;  
- rewrite ^/model/([^/]+)/([^/]+)/([^/]+)//script_folder_name/tube/?model_slug=$1&force_template=model_galleries&order=$2&page=$3&$query_string ; + rewrite ^/model/([^/]+)/([^/]+)/([^/]+)/$ /?model_slug=$1&force_template=model_galleries&order=$2&page=$3&$query_string ; 
  
   
  location /search {   location /search { 
- rewrite ^/search/([^/]+)/([^/]+)/$ /script_folder_name/tube/index.php?search=$1&page=$2&$query_string;  + rewrite ^/search/([^/]+)/([^/]+)/$ /?search=$1&page=$2&$query_string;  
- rewrite ^/search/([^/]+)/([^/]+)/([^/]+)/$ /script_folder_name/tube/index.php?search=$1&order=$2&page=$3&$query_string; + rewrite ^/search/([^/]+)/([^/]+)/([^/]+)/$ /?search=$1&order=$2&page=$3&$query_string; 
  }  }
  
Line 145: Line 146:
 ===== Search ===== ===== Search =====
  
-There are a few ways to search: regular mysql LIKE statement, mysql MATCH statement.+By default, the search uses a construct like WHERE description LIKE '%search_term%'In the rotation settings there is an item
  
-There's a new setting in Rotation setting  
- 
- 
-  
 Search fields Search fields
 If you don't use Sphinx the script will use Mysql If you don't use Sphinx the script will use Mysql
 built-in functionality. It's slower so we limit amount of fields built-in functionality. It's slower so we limit amount of fields
-Please, read the last WIKI about the last option.  +Please, read the last WIKI about the last option.
- +
- +
-What you need to know is when we use a regular LIKE option - it's works out-of-the-box, so you don't have to  do anything about it. But it's slow and you'll feel it if you have a big DB.+
  
-So we have 2 suboptions - seatch in Alt (title) only, description only or both title+description. The latter only is a bit slower of course. 
  
 +By default the script searches in description, in this item you can configure search in Title (Alt), or in both fields at once, which of course creates somewhat more load.
  
-Mysql MATCH is better but it works with new versions of Mysql only (5.6+)> It's called FullText Search. Actually it was introduced long time ago but InnoDB table type can do that only since version 5.6+The best option is to configure Sphinx which is described below.
  
-It'good option, not as fast as Sphinx but worth a shot.+But there is compromise option: FullText Search for Mysql (the last of the Search fields option items). Its point is that Mysql also knows how to search taking into account morphology, but before version 5.6 it did this only for MyISAM tables.
  
-If you'd like to use this option you need to add an index to all rot_gallery_data* tables +So if you want to use this option, which is somewhat simpler than the Sphinx option in the setup, you need to add an index for the rot_gallery_data* tables
  
 <code> <code>
Line 175: Line 169:
 </code> </code>
  
 +And switch the option in settings to FullText search.
  
  
-And the best option so far is Sphinx. 
  
 ===== Sphinx Config ===== ===== Sphinx Config =====
  
-Note that most likely in Sphinx Settings в you need to type 127.0.0.1 (not localhost)+Please note that in Sphinx Settings in 99% of cases you need to write 127.0.0.1
  
-Config example+Example config
  
 <code> <code>
  
 +You need to make changes in the section
  
 searchd searchd
Line 192: Line 187:
  listen      = your_port:mysql41  listen      = your_port:mysql41
  
-addition of mysql41 is the most important part. It's called SphinxQL +the main thing here is adding mysql41, a new way for sphinx to listen over the mysql protocol
  
 +Next is an example for the database
  
 source your_name_source source your_name_source
Line 214: Line 209:
  (SELECT group_concat(tag_id) FROM rot_gal2tag g2t \  (SELECT group_concat(tag_id) FROM rot_gal2tag g2t \
  WHERE g2t.gallery_id = gi.gallery_id) as tag_ids, \  WHERE g2t.gallery_id = gi.gallery_id) as tag_ids, \
 + (SELECT group_concat(name) FROM rot_groups  \
 + WHERE rot_groups.id in (SELECT group_id FROM rot_gallery_stats1 WHERE rot_gallery_stats1.gallery_id = gi.gallery_id AND group_id != 0) ) as group_names, \
 +                                                                  \
 + (SELECT group_concat(name) FROM rot_groups  \
 + WHERE rot_groups.id in (SELECT group_id FROM rot_gallery_stats1 WHERE rot_gallery_stats1.gallery_id = gi.gallery_id AND group_id != 0) ) as group_names, \
 +
  (SELECT group_concat(gss.group_id) FROM rot_gallery_stats1 as gss \  (SELECT group_concat(gss.group_id) FROM rot_gallery_stats1 as gss \
  WHERE gss.gallery_id = gi.gallery_id AND group_id != 0) as categories \  WHERE gss.gallery_id = gi.gallery_id AND group_id != 0) as categories \
Line 220: Line 221:
  JOIN rot_gallery_stats1 AS gs ON gs.gallery_id = gi.gallery_id \  JOIN rot_gallery_stats1 AS gs ON gs.gallery_id = gi.gallery_id \
  WHERE gallery_status = 'active' and gallery_type = 0 \  WHERE gallery_status = 'active' and gallery_type = 0 \
- and gs.best_thumb = 'yes' and gs.group_id = 0+ and gs.best_thumb = 'yes' and gs.group_id = 0 AND gs.group_id NOT IN (SELECT group_id FROM rot_groups_data WHERE status != 1)
  
  
Line 245: Line 246:
  
 </code> </code>
 +
 +
  
  
 ===== Sphinx Delta Config ===== ===== Sphinx Delta Config =====
  
-This part make sense only if you have really big DB (1M+ for example demo version bigbase.smartcj.com has 12M+ galleries)+When creating an index sphinx creates an index of the current state of the database and if there were any changes in the database after indexing, sphinx won't find new data because it was added after indexing. 
 + 
 +The logical conclusion from this: we need to re-index after each change in the database, however the problem is that if the database is large enough, indexing can take long time. And indexing is a resource-intensive process. 
 + 
 +To solve this problemdelta index was invented - this is an index in which changes that occurred from the moment of full indexing to the moment of delta index creation will fall. Since small amount of data is indexed, the operation is very fast. 
 + 
 +When searching, sphinx will search both in the main index and in the delta index, and thus will see all changes. Creating a delta index can be done as often as you like.
  
-When Sphinx creates an index it takes a snapshot of a current state of a DB. So if something has been changed since then - it won't be reflected in index. And if you have a big DB it takes a lot of time to reindex it. 
  
-So the good idea is to just reindex those parts that have been changed. That's why you need so called delta index+So:
  
-To make use of it you need to add after +in the main part that you already have, you need to add after
  
   sql_query_pre = SET NAMES utf8   sql_query_pre = SET NAMES utf8
  
-a new line+line
  
   sql_query_pre = UPDATE rot_settings SET value = (SELECT MAX(gallery_id) FROM rot_gallery_info) WHERE name = 'sphinx_max_gallery_id'   sql_query_pre = UPDATE rot_settings SET value = (SELECT MAX(gallery_id) FROM rot_gallery_info) WHERE name = 'sphinx_max_gallery_id'
  
  
-And add a new source +Now you need to add the creation of delta index
  
 <code> <code>
Line 272: Line 280:
     sql_query_pre = SET NAMES utf8     sql_query_pre = SET NAMES utf8
  
- sql_query = SELECT gi.gallery_id, UNIX_TIMESTAMP(gi.activation_date) as date, alt, description, gi.duration, sponsor_id, gs.total_ctr, gi.content_type,+ sql_query = SELECT gi.gallery_id, UNIX_TIMESTAMP(gi.activation_date) as date, 
- (SELECT group_concat(tag_name) FROM rot_gal2tag g2t \ +                                                                                 \ 
- LEFT JOIN rot_tags as t on t.tag_id = g2t.tag_id \ + gd.alt, gd.description, gi.duration, gi.sponsor_id, gs.total_ctr, gi.content_type, rot_sponsors.sponsor_name, rot_sponsors.sponsor_site,
- WHERE g2t.gallery_id = gi.gallery_id) as tags, \ +                          \ 
- (SELECT group_concat(gss.group_id) FROM rot_gallery_stats1 as gss \ +                                                                                 \ 
- WHERE gss.gallery_id = gi.gallery_id AND group_id != 0) as categories \ + (SELECT group_concat(tag_id) FROM rot_gal2tag g2t                               \ 
- FROM rot_gallery_info AS gi \ + WHERE g2t.gallery_id = gi.gallery_id) as tag_ids,                               \ 
- JOIN rot_gallery_data1 AS gd ON gi.gallery_id = gd.gallery_id \ +                                                                                 \ 
- JOIN rot_gallery_stats1 AS gs ON gs.gallery_id = gi.gallery_id \ + # TAGS START you can remove this part up to TAG END                             \ 
- WHERE gi.gallery_id > ( SELECT value FROM rot_settings WHERE name = 'sphinx_max_gallery_id' ) \ + # this part indexes tags, if you remove it - tags wont be indexed               \ 
- AND gallery_status = 'active' and gallery_type = 0 \ + # ligther index = less memory usage and faster search                           
- and gs.best_thumb = 'yes' and gs.group_id = 0+ (SELECT group_concat(tag_name) FROM rot_gal2tag g2t                             
 + LEFT JOIN rot_tags as t on t.tag_id = g2t.tag_id                                
 + WHERE g2t.gallery_id = gi.gallery_id) as tags,                                  \ 
 +                                                                 \ 
 + # TAGS END                                                                      \ 
 +                                                                                 \ 
 +                                                                                 \ 
 + # GROUP START you can remove this part up to TAG END                            \ 
 + # this part indexes group names, if you remove it - it  wont be indexed         \ 
 + # ligther index = less memory usage and faster search                           
 + (SELECT group_concat(name) FROM rot_groups                                      \ 
 + WHERE rot_groups.id in (SELECT group_id FROM rot_gallery_stats1                \ 
 + WHERE rot_gallery_stats1.gallery_id = gi.gallery_id AND group_id != 0)         \ 
 + ) as group_names,                                                              \ 
 +                                                                                 \ 
 +                                                               \ 
 + # GROUP END                                                                     \ 
 +                                                                                 \ 
 + # Models START you can remove this part up to MODEL END                         \ 
 + # this part indexes model names, if you remove it - it  wont be indexed         \ 
 + # ligther index = less memory usage and faster search                           \ 
 + (SELECT group_concat(model_name) FROM rot_models                                \ 
 + WHERE rot_models.model_id in (SELECT model_id FROM rot_gal2model               \ 
 + WHERE rot_gal2model.gallery_id = gi.gallery_id)                                \ 
 + ) as model_names,                                                              \ 
 +                                                                                 \ 
 + # MODEL END                                                                     \ 
 +                                                                                 \ 
 +                                                                                 \ 
 + (SELECT group_concat(distinct(gss.group_id)) FROM rot_gallery_stats1 as gss     
 + WHERE gss.gallery_id = gi.gallery_id AND group_id != 0) as categories           \ 
 +                                                                                 
 + FROM rot_gallery_info AS gi                                                     \ 
 + JOIN rot_sponsors on rot_sponsors.sponsor_id = gi.sponsor_id                    
 + JOIN rot_gallery_data1 AS gd ON gi.gallery_id = gd.gallery_id                   \ 
 +                                                              \ 
 +                                                                                 
 + JOIN rot_gallery_stats1 AS gs ON gs.gallery_id = gi.gallery_id                  
 + WHERE gallery_status = 'active' and gallery_type = 0                            
 + and gs.best_thumb = 'yes' and gs.group_id = 0                                   \ 
 + AND gs.group_id NOT IN (SELECT group_id FROM rot_groups_data WHERE status != 1) and gi.gallery_id > ( SELECT value FROM rot_settings WHERE name = 'sphinx_max_gallery_id' )
          
 } }
Line 298: Line 346:
  
  
-You can note that it has the same query with an addition of sphinx_max_gallery_id.+As you can see the query is the same, the only difference is the presence of sphinx_max_gallery_id in the selection.
  
-Now you have to add new crontab task that will reindex new parts+After this you need to add indexing of new records to the cron as often as you like with the line
  
   indexer --rotate delta   indexer --rotate delta
  
-Now you have to add 'delta' into  Sphinx Delta Index  (Rotation settings)+After creating the index, you need to specify delta in the Sphinx Delta Index settings of the rotation.
  
-once a day you can marge main index and delta index+and once a day for example you can attach the delta index to the main one
  
   indexer --rotate --merge your_name_index delta   indexer --rotate --merge your_name_index delta
  
  
-That's it.+Done. 
tcms_install.1476821794.txt.gz · Last modified: by admin