Setting up Magento on your Ubuntu 24.04 server with Apache allows you to create a powerful e-commerce platform tailored to your business needs. This guide walks you through each step, from initial preparations to troubleshooting common issues, ensuring you can deploy Magento efficiently and securely. Before you begin, ensure your server meets the minimum requirements for Magento, including sufficient RAM, CPU, and disk space. Also, having root or sudo access is essential to install and configure the necessary components.
What You’ll Need
- Ubuntu 24.04 server (fresh install recommended)
- Root or sudo privileges
- Domain name pointing to your server’s IP (optional but recommended)
- Basic knowledge of Linux command line
- At least 8GB RAM, 4 CPU cores, and 50GB disk space (recommended for production)
- SSL certificate (optional but recommended for security)
Step-by-Step
- Update your system packages
- Install Apache web server
- Install MySQL server and create a database for Magento
- Install PHP and required extensions
- Configure PHP settings for Magento
- memory_limit = 2G
- max_execution_time = 1800
- zlib.output_compression = On
- file_uploads = On
- upload_max_filesize = 50M
- post_max_size = 50M
- Download Magento
- Extract Magento files to your web directory
- Set permissions for Magento directories
- Create an Apache virtual host configuration
- Enable the site and rewrite module
- Run Magento setup through the web installer
- How to Hide Time and Date in Windows 11 System Tray
- How to Hide Users on Windows 11 Sign for Privacy and Security
- How to Hide Virus & Threat Protection Section in Windows 11 Security
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
sudo apt install mysql-server -y
sudo mysql_secure_installation
Follow the prompts to secure your MySQL installation. Then, log in to MySQL and create a database and user for Magento:
sudo mysql -u root -p
CREATE DATABASE magento;
CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON magento.* TO 'magento_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
sudo apt install php php-cli php-common php-curl php-mysql php-xml php-mbstring php-intl php-zip php-soap php-bcmath php-gd -y
sudo nano /etc/php/8.2/apache2/php.ini
Adjust the following settings to recommended values:
Visit the official Magento website to download the latest version or use wget:
wget https://magento.com/tech-resources/download -O magento.zip
sudo apt install unzip -y
sudo mkdir -p /var/www/html/magento
sudo unzip magento.zip -d /var/www/html/magento
sudo chown -R www-data:www-data /var/www/html/magento
sudo chmod -R 755 /var/www/html/magento
sudo nano /etc/apache2/sites-available/magento.conf
Insert the following configuration, replacing yourdomain.com with your actual domain or server IP:
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/html/magento
<Directory /var/www/html/magento>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/magento_error.log
CustomLog ${APACHE_LOG_DIR}/magento_access.log combined
</VirtualHost>
sudo a2ensite magento.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Open your browser and navigate to Related