Installing Craft CMS on your VPS server running Debian 12 is a straightforward process. Follow the steps below to set it up.
Step 1: Update Your System
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Dependencies
Install necessary packages such as PHP, MySQL, and Composer:
sudo apt install nginx mysql-server php php-fpm php-mysql php-xml php-mbstring php-curl php-zip php-gd -y
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Step 3: Set Up MySQL Database
Log in to MySQL to create a database and user for Craft CMS:
sudo mysql -u root -p
In the MySQL shell, execute the following commands:
CREATE DATABASE craft;
CREATE USER 'craftuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON craft.* TO 'craftuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4: Download Craft CMS
Change to the web root directory and download Craft CMS:
cd /var/www/html
composer create-project craftcms/craft craft
Step 5: Configure Nginx
Create a new configuration file for Craft CMS:
sudo nano /etc/nginx/sites-available/craft
Add the following configuration:
server {
listen 80;
server_name your_domain.com; # Change this to your domain
root /var/www/html/craft/web;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust PHP version if needed
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Enable the new site and test the configuration:
sudo ln -s /etc/nginx/sites-available/craft /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Step 6: Complete Craft CMS Installation
Open your web browser and navigate to http://your_domain.com. Follow the on-screen instructions to complete the installation, entering the database credentials when prompted.
Conclusion
By following these steps, you have successfully installed Craft CMS on your VPS server. You can now start building your website!