Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

How to Install MODX CMS with Apache on Ubuntu 24.04

How to Install MODX CMS with Apache on Ubuntu 24.04

Setting up MODX CMS on an Ubuntu 24.04 server with Apache allows you to create a flexible, powerful content management system tailored to your needs. This guide walks you through each step to ensure a smooth installation process, whether you’re a developer or a website owner looking to deploy MODX efficiently. Before starting, ensure you have a fresh Ubuntu 24.04 server, root or sudo access, and a basic understanding of command-line operations. You will also need an active internet connection to download necessary packages and files.

What You’ll Need

  • Ubuntu 24.04 server with root or sudo privileges
  • Domain name pointing to your server’s IP (optional but recommended)
  • Basic knowledge of Linux command line
  • Access to a terminal or SSH client (like PuTTY or Terminal)
  • Internet connection for downloading packages and files

Step-by-Step

  1. Update Your System
    Open your terminal and run:

    sudo apt update && sudo apt upgrade -y

    This ensures all system packages are current and reduces potential conflicts during installation.

  2. Install Apache Web Server
    To serve your MODX site, install Apache:

    sudo apt install apache2 -y

    After installation, enable and start Apache:

    sudo systemctl enable apache2
    sudo systemctl start apache2
  3. Install PHP and Required Modules
    MODX requires PHP 8.0+ and certain modules. Install PHP and extensions:

    sudo apt install php php-mysql php-xml php-mbstring php-curl php-zip php-gd libapache2-mod-php -y

    Restart Apache to load PHP modules:

    sudo systemctl restart apache2
  4. Install and Configure MySQL
    Install MySQL server:

    sudo apt install mysql-server -y

    Run the security script:

    sudo mysql_secure_installation

    Follow prompts to set a root password and secure your database.
    Then, log into MySQL:

    sudo mysql -u root -p

    Create a database and user for MODX:

    CREATE DATABASE modxdb;
    CREATE USER 'modxuser'@'localhost' IDENTIFIED BY 'your_secure_password';
    GRANT ALL PRIVILEGES ON modxdb.* TO 'modxuser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
  5. Download MODX Revolution
    Visit the official MODX website to get the latest version link:

    wget https://downloads.modx.com/downloads/revolution/2.x.x/modx-2.x.x.zip

    Replace the URL with the latest version available. Download to your server, then unzip:

    sudo apt install unzip -y
    unzip modx-2.x.x.zip -d /var/www/html/modx
  6. Configure Permissions
    Set correct permissions for MODX:

    sudo chown -R www-data:www-data /var/www/html/modx
    sudo chmod -R 755 /var/www/html/modx
  7. Create a Virtual Host for MODX
    Create a new Apache configuration file:

    sudo nano /etc/apache2/sites-available/modx.conf

    Add the following configuration, replacing ‘yourdomain.com’ with your actual domain or server IP:

    
        ServerName yourdomain.com
        ServerAdmin admin@yourdomain.com
        DocumentRoot /var/www/html/modx
        
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        
        ErrorLog ${APACHE_LOG_DIR}/modx_error.log
        CustomLog ${APACHE_LOG_DIR}/modx_access.log combined
    

    Enable the site and rewrite module:

    sudo a2ensite modx.conf
    sudo a2enmod rewrite
    sudo systemctl reload apache2
  8. Complete the Installation via Web Browser
    Open your browser and navigate to http://yourdomain.com (or your server’s IP). You should see the MODX installation wizard. Follow the on-screen instructions: accept license, check requirements, configure database connection with the database, user, and password you set earlier, then complete the setup. After installation, delete the setup folder for security:

    sudo rm -rf /var/www/html/modx/setup

Common Mistakes

  • Forgetting to restart Apache after installing PHP modules
  • Using incorrect permissions, leading to 403 errors
  • Not updating the database connection details during setup
  • Failing to enable Apache rewrite module, which causes URL issues
  • Skipping the removal of the setup directory after installation

Tips

  • Always keep your server and software updated for security and stability
  • Use strong, unique passwords for database and admin accounts
  • Configure your firewall to only allow necessary ports (80, 443)
  • Set up SSL certificates (Let’s Encrypt) for HTTPS to secure your site
  • Regularly back up your MODX files and database

Troubleshooting

  • Apache won’t start or throws errors: Check syntax with sudo apache2ctl configtest. Review error logs in /var/log/apache2/error.log.
  • Permissions issues: Ensure www-data owns the MODX directory. Run sudo chown -R www-data:www-data /var/www/html/modx.
  • MODX setup page not loading or errors during installation: Verify your database connection details, PHP modules, and permissions. Clear browser cache or try incognito mode.
  • 404 errors after installation: Confirm your virtual host configuration is enabled and Apache is reloaded.
  • SSL setup issues: Use Certbot to install Let’s Encrypt SSL certificates for HTTPS.

Frequently Asked Questions

Can I install MODX without a domain name?
Yes, you can access MODX via your server’s IP address, but a domain name is recommended for production environments.
Is Ubuntu 24.04 stable enough for hosting MODX?
Yes, Ubuntu 24.04 is a stable, long-term support release suitable for web hosting.
Do I need to secure my MODX site with SSL?
It is highly recommended to enable SSL to protect data and improve SEO rankings.
Can I upgrade MODX later?
Yes, MODX provides upgrade paths. Always back up before upgrading to prevent data loss.
What performance optimizations can I do?
Implement caching, optimize database queries, and consider using a CDN for static assets to boost performance.

Following these steps carefully will help you successfully install MODX CMS on your Ubuntu 24.04 server with Apache. With your CMS up and running, you can now customize your website, add content, and leverage MODX’s powerful features to build a dynamic web presence.

Related

How to Install MODX CMS with Apache on Ubuntu 24.04
Scroll to top