Others

Last modified by Yu Pang Law on 2022/12/14 04:12

3 posts

Dec 14 2022

Drupal Update with Drush

  1. cd to Drupal installation Directory
  1. Backup Drupal
    drush archive-dump
  2. Check Drupal Update and get the list of modules that have update
    drush ups
    {{code}}
    1. Set Drupal Website to maintenance mode
    {{code}}
    drush sset system.maintenance_mode 1
    {{code}}
    1. Clear Drupal Cache
    {{code}}
    drush cr
    {{/code}}
    1. Update Drupal and press "Y" when asked
    {{code}}
    drush up drupal
    {{/code}}
    1. Update Drupal Database
    {{code}}
    drush updb
    {{/code}}
    1. Update Drupal modules
    {{code}}
    drush up XXXX XXXX
    {{/code}}
    where XXXX is the module name (the string inside the bracket in step 2)

    1. Set Drupal Website back to live mode
    {{code}}
    drush sset system.maintenance_mode 0
    {{/code}}
    1. Clear Drupal Cache Again
    {{code}}
    drush cr
    {{/code}}

Dec 14 2022

Running Custom php script within Drupal Directory

By default, Drupal will not allow running of any other PHP scripts within Drupal directory. It will return "403 Forbidden", if anybody trying to access the PHP scripts.

To by pass this constraint, we will need to add 2 lines in .htaccess.htaccess is in Drupal root directory.

  1. Open .htaccess with a text editor
  1. Find the section below:
      RewriteCond %{REQUEST_FILENAME} !-f
      
    RewriteCond %{REQUEST_FILENAME} !-d
      
    RewriteCond %{REQUEST_URI} !=/favicon.ico
      
    RewriteRule ^ index.php [L]

      Before RewriteRule, add
    RewriteCond %{REQUEST_URI} !script
    where "script" is the directory name or file name of your custom php script.

 3. Find the section below:
  RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
  
RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
  
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
  
RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]

  Before RewriteRule, add
RewriteCond %{REQUEST_URI} !script
where "script" is the directory name or file name of your custom php script.

4. Save the file and exit.

5. You will need to add the lines back every time you upgrade Drupal.

What does the changes mean?

RewriteCond means the condition for the RewriteRule to execute.

So, by adding a "RewriteCond %{REQUEST_URI} !script", we add a new condition that tells the web server to skip this rule, if the URI has the word "script" in it. So, the "script" directory or file will no longer be managed by Drupal.

See how it works:

https://worria.com/script/trace.php

https://worria.com/

*not Drupal anymore

Dec 14 2022

Cacti Graph no data randomly for some graphs

Symptom
cacti_blank.png

Cause:

Data Collector reachs max run time (polling interval). Remaining SNMP data will not be collected.

Solution:

1. Use spine instead of cmd.php

2. Increase "Processes" and "Threads" setting under "Data Collection" --> "Data Collectors"

Recommend Setting for

"Processes" = 2 * no. Of Cores available

"Threads" = 10 - 15

Tags:
 
Copyrighted by Pangnet.net