(Quick guide) Update from Mautic 4 to 5.1 when installed by softaculous

Hello, I had some issues updating my Mautic when it was installed on softaculous so learnt how to solve this issues and here is a small guide of how to achieve this:


  1. Save local.php Configuration ← everything, copy all the file content in a text file
  2. Clear Cache
    php bin/console cache:clear
    
  3. Delete All But Some var Files
  4. Replace Old Mautic with New Mautic Files
  5. Replace local.php Config File
  6. Clear Cache
    php bin/console cache:clear
    
  7. Run Update Command
    php bin/console mautic:update:apply --finish
    
  8. Clear Cache Again
    php bin/console cache:clear
    
  9. Check .htaccess File
  10. Modify permissions
    chmod +x /bin/console
    find /path/to/your/mautic -type d -exec chmod 755 {} \;
    find /path/to/your/mautic -type f -exec chmod 644 {} \;
  1. Reconfigure the Email SMTP Configuration in Mautic
    • Navigate to Mautic > Configuration > Email Settings
    • Reconfigure the SMTP settings as needed

Check the PHP version, 8.1 works great.
Also htaccess can be your friend or your enemy, this is the configuration I am using (still have to do some tweaks)


# Use the front controller as index file.
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Set Authorization header for OAuth2 for when PHP is running under fcgi
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Determine the RewriteBase automatically and set it as environment variable.
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    # Redirect to URI without front controller to prevent duplicate content
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    # If the requested filename exists, simply serve it.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    # Rewrite all other queries to the front controller.
    RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, redirect the start page to the front controller
        RedirectMatch 302 ^(?!/(index\.php|app|addons|plugins|media|upgrade))(/(.*))$ /index.php$2
    </IfModule>
</IfModule>

# Prevent directory listing
Options -Indexes

# Deny access to .htaccess itself
<Files .htaccess>
    Require all denied
</Files>

# Protect configuration files
<FilesMatch "(^\.|wp-config\.php|php\.ini|php5\.ini|\.user\.ini|\.htaccess|\.htpasswd)">
    Require all denied
</FilesMatch>

# Deny access to certain file extensions
<FilesMatch "\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|swp|sh)$">
    Require all denied
</FilesMatch>

# Allow access to PHP files only within the application directories
<FilesMatch "\.php$">
    <If "-f %{REQUEST_FILENAME}">
        Require all granted
    </If>
    <If "-d %{REQUEST_FILENAME}">
        Require all denied
    </If>
</FilesMatch>

# Deny access to sensitive directories
<IfModule mod_autoindex.c>
    IndexIgnore *
</IfModule>

# Enable Deflate compression for specified types
<IfModule mod_deflate.c>
    <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
        AddOutputFilterByType DEFLATE application/x-font
        AddOutputFilterByType DEFLATE application/x-font-opentype
        AddOutputFilterByType DEFLATE application/x-font-otf
        AddOutputFilterByType DEFLATE application/x-font-truetype
        AddOutputFilterByType DEFLATE application/x-font-ttf
        AddOutputFilterByType DEFLATE application/x-javascript
        AddOutputFilterByType DEFLATE font/opentype
        AddOutputFilterByType DEFLATE font/otf
        AddOutputFilterByType DEFLATE font/ttf
        AddOutputFilterByType DEFLATE image/svg+xml
        AddOutputFilterByType DEFLATE image/x-icon
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE text/javascript
        <IfModule mod_setenvif.c>
            <IfModule mod_header.c>
                # Remove browser bugs (only needed for really old browsers)
                BrowserMatch ^Mozilla/4 gzip-only-text/html
                BrowserMatch ^Mozilla/4\.0[678] no-gzip
                BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
                Header append Vary User-Agent
            </IfModule>
        </IfModule>
    </IfModule>
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php82” package as the default “PHP” programming language.
<IfModule mime_module>
    AddHandler application/x-httpd-ea-php82 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

Blockquote


Hope this helps people that use softaculous.

BTW, I install a new softaculous version of mautic and then move all the content (step 4), that makes this extremely quick and easy.

If you have any issue, let me know.

Also, if you are in doubt, clone your mautic installation. The hardest part is the DB part, specially if it’s big. You can do it with mysql line commands but it can be easy using “bigdump”

This file inserts in small chunks big databases. Is like it cut the SQL insert statements in small pieces, so the process won’t crash.

Just need some tweaking

Lines per session is important, 1,000 to 5,000, no more


// OPTIONAL SETTINGS 

$filename           = 'brandvw_mautbvw.sql';     // Specify the dump filename to suppress the file selection dialog
$ajax               = true;   // AJAX mode: import will be done without refreshing the website
$linespersession    = 1000;   // Lines to be executed per one import session
$delaypersession    = 100;      // You can specify a sleep time in milliseconds after each session
                              // Works only if JavaScript is activated. Use to reduce server overrun

Blockquote


Also max query lines, keep this big.


> // How many lines may be considered to be one query (except text lines)
> 
> $max_query_lines = 10000;

Then update this version and test it.

1 Like