How to Install PrestaShop on NixOS Latest
PrestaShop is an open-source e-commerce platform that allows you to create an online store and manage it from a web browser. In this tutorial, we will guide you on how to install PrestaShop on NixOS Latest.
Prerequisites
- NixOS Latest installed on your system. If you haven't installed it yet, you can follow our NixOS installation tutorial.
Step 1: Install Required Packages
To start with, we need to install some required packages for the PrestaShop installation. Open the terminal and run the following command to update the package list:
sudo nix-channel --update
Then, run the following command to install the required packages:
sudo nix-env -i php php-fpm nginx mysql
Step 2: Configure PHP and Nginx
Once the packages are installed, we need to configure PHP and Nginx to work with each other. Run the following command to open the php-fpm configuration file:
sudo nano /etc/php-fpm.conf
In the configuration file, find the following line:
listen = /run/php-fpm/php-fpm.sock
Uncomment the line and change it to the following:
listen = 127.0.0.1:9000
Save and close the file.
Then, run the following command to open the nginx configuration file:
sudo nano /etc/nginx/nginx.conf
In the configuration file, find the following line:
# include /etc/nginx/conf.d/*.conf;
Uncomment the line.
Save and close the file.
Step 3: Download and Install PrestaShop
Now, we are ready to download and install PrestaShop. Open the terminal, and run the following command to download the latest version of PrestaShop:
curl -o prestashop.zip -L https://www.prestashop.com/download/old/prestashop_1.7.7.4.zip
Then, create a new directory under /var/www/ to store PrestaShop files:
sudo mkdir /var/www/prestashop
Extract the downloaded PrestaShop files to the newly created directory:
sudo unzip -q prestashop.zip -d /var/www/prestashop
Next, change the ownership of the prestashop directory to the www-data user and group:
sudo chown -R www-data:www-data /var/www/prestashop
Step 4: Configure MySQL
Now, we need to configure MySQL for PrestaShop. Run the following command to start the MySQL service:
sudo systemctl start mysql
Then, run the following command to log in to the MySQL server:
sudo mysql -u root
In the MySQL prompt, run the following commands to create a new database for PrestaShop:
CREATE DATABASE prestashop;
GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashopuser'@'localhost' IDENTIFIED BY 'yourpassword';
FLUSH PRIVILEGES;
exit;
Replace yourpassword with your own password.
Step 5: Configure Nginx for PrestaShop
The last step is to configure Nginx to serve the PrestaShop files. Run the following command to create a new Nginx configuration file:
sudo nano /etc/nginx/conf.d/prestashop.conf
Paste the following content into the file:
server {
listen 80;
server_name example.com;
root /var/www/prestashop;
index index.php;
location / {
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Replace example.com with your own domain name.
Save and close the file.
Finally, run the following command to restart the Nginx service:
sudo systemctl restart nginx
Step 6: Access PrestaShop
Now, you can access your PrestaShop installation by visiting your server's IP address or domain name in your web browser. The installation wizard should start automatically, and you can follow the on-screen instructions to complete the installation process.
Congratulations! You have successfully installed PrestaShop on NixOS Latest.