Setting up PrestaShop on Windows using Windows Subsystem for Linux (WSL) offers a seamless way to develop and test your e-commerce store locally without needing a dedicated Linux server. This guide walks you through each step to install PrestaShop on WSL, enabling a smooth development environment on your Windows machine. Before you begin, ensure your Windows system supports WSL 2 and that you have administrative rights to install and configure software.
What You’ll Need
- Windows 10 (version 2004 or later) or Windows 11 with WSL 2 enabled
- Administrative access to your Windows machine
- Internet connection for downloading necessary packages
- Basic familiarity with command line operations
Step-by-Step
- Enable WSL and Install WSL 2
- Install a Linux Distribution (Ubuntu)
- Update and Upgrade Ubuntu Packages
- Install LAMP Stack Components
- Configure MySQL for PrestaShop
- Download and Install PrestaShop
- Configure Apache Virtual Host
- Complete PrestaShop Installation via Browser
First, verify if WSL is enabled. Open PowerShell as Administrator and run:
wsl --install
If WSL 2 isn’t set as default, run:
wsl --set-default-version 2
This command installs WSL 2 and sets it as the default version. Restart your computer when prompted.
Download Ubuntu from the Microsoft Store. Search for “Ubuntu” and click Install. Once installed, launch Ubuntu from the Start menu, and set up a username and password when prompted.
In the Ubuntu terminal, run:
sudo apt update && sudo apt upgrade -y
This ensures all packages are current, reducing compatibility issues later.
PrestaShop requires a web server, PHP, and a database. Install Apache, PHP, and MySQL with:
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-xml php-gd php-curl php-mbstring php-zip php-intl -y
> During MySQL installation, set a root password and secure your database server.
Secure MySQL with:
sudo mysql_secure_installation
Follow prompts to set a root password, remove anonymous users, and disable remote root login.
Then, create a database and user for PrestaShop:
sudo mysql -u root -p
CREATE DATABASE prestashop_db;
CREATE USER 'prestashop_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON prestashop_db.* TO 'prestashop_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Navigate to the web root directory:
cd /var/www/html
Download the latest PrestaShop package:
wget https://www.prestashop.com/download/old/prestashop_1.7.8.8.zip
Unzip and set permissions:
sudo apt install unzip -y
sudo unzip prestashop_1.7.8.8.zip -d prestashop
sudo chown -R www-data:www-data prestashop
Create a symbolic link for easier access:
sudo ln -s /var/www/html/prestashop /var/www/html/prestashop_site
Create a new configuration file:
sudo nano /etc/apache2/sites-available/prestashop.conf
Add the following:
<VirtualHost *:80>
ServerName prestashop.local
DocumentRoot /var/www/html/prestashop
<Directory /var/www/html/prestashop>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/prestashop_error.log
CustomLog ${APACHE_LOG_DIR}/prestashop_access.log combined
</VirtualHost>
Enable the site and rewrite module:
sudo a2ensite prestashop.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Update your Windows hosts file to map the domain:
sudo nano /etc/hosts
Add:
127.0.0.1 prestashop.local
Open your browser and navigate to http://prestashop.local. Follow the on-screen instructions to select language, enter database details (using the database and user you created), and configure your store. Once completed, you’ll have a working PrestaShop instance on your WSL environment.
Common Mistakes
- Not enabling Apache rewrite module, causing URL issues.
- Forgetting to assign correct permissions to the PrestaShop directory.
- Using incorrect database credentials during setup.
- Failing to update the Windows hosts file for custom domain access.
- Not securing MySQL properly, leading to potential security risks.
Tips
- Use a dedicated directory for PrestaShop to keep things organized.
- Regularly update your WSL and Linux packages for security and compatibility.
- Backup your database before making major changes.
- Use SSL if deploying publicly; for local testing, HTTP is sufficient.
- Consider installing phpMyAdmin for easier database management.
Troubleshooting
If PrestaShop does not load or installation fails, check the following:
- Ensure Apache is running: run
sudo systemctl status apache2> - Verify your hosts file contains the correct mapping to localhost.
- Check Apache error logs at
/var/log/apache2/error.logfor clues. - Confirm database connection details are correct and the database user has privileges.
- Make sure all required PHP extensions are installed and enabled.
- Clear your browser cache or try accessing via incognito mode.
Frequently Asked Questions
Can I run PrestaShop on Windows without WSL?
Yes, but it’s more complex and less efficient. WSL provides a Linux environment that closely matches a production server, making development smoother.
Is WSL 2 necessary for this setup?
While WSL 2 is recommended for better performance and compatibility, WSL 1 can work but may cause issues with certain PHP or database features.
How do I access my PrestaShop store from other devices?
You need to configure your Windows firewall and network settings to allow incoming connections on port 80, and ensure your hosts file or DNS points to your Windows machine’s IP.
Can I install additional modules and themes?
Yes, once PrestaShop is installed, you can upload modules and themes through the admin panel or directly into the filesystem.
How do I update PrestaShop in WSL?
Download the latest version, back up your store, and replace core files carefully to avoid losing customizations or data.
This comprehensive guide ensures you can successfully set up and run PrestaShop on Windows WSL, creating a powerful local development environment for your e-commerce projects.
Related
- How to Install JDK on Windows 11 Easily and Quickly
- How to Install Java on Windows 10 Easily and Quickly
- How to Install IPA on iPhone 15 Easily and Safely