Craft CMS is a flexible and powerful content management system loved by developers and content creators. Its intuitive interface, rich functionality, and extreme customizability make it the tool of choice for website building and management.
To keep the operating system safe and stable, it is important to update the Debian 12 system. Open a terminal and run the command to update your system.
sudo apt update sudo apt upgrade
This will refresh your package list and upgrade all installed software to the latest version.
Step 2. Create non-root user
Operating as a non-root user with sudo privileges is a security best practice. Create a new user and grant them the necessary permissions:
sudo /usr/sbin/adduser craftcms sudo /usr/sbin/usermod -aG sudo craftcms su - craftcms
Step 3. Install the LAMP stack.
Before starting this tutorial, you need to install the LAMP server on your server. If you haven't installed LAMP Stack yet, follow our guide.
Step 4. Create a database for Craft CMS
Craft CMS requires a MySQL database to store its data. To create a new database, log in to MySQL as root:
sudo mysql -u root -p
Next, create a new database and user for Craft CMS:
CREATE DATABASE craftcms; CREATE USER 'craftuser'@'localhost' IDENTIFIED BY 'your-strong-password'; GRANT ALL PRIVILEGES ON craftcms.* TO 'craftuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
Step 5. Install Craft CMS using Composer.
Craft CMS recommends using Composer (PHP’s dependency management tool) for installation. If you don't have Composer installed yet, you can install it using the following command:
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
Next, navigate to the Apache web root directory and install Craft CMS:
cd /var/www/html sudo composer create-project craftcms/craft craftcms
Step 6. Configuring Apache
for Craft CMSTo make Craft CMS accessible via the web, you need to configure Apache. Create a new configuration file for Craft CMS:
sudo nano /etc/apache2/sites-available/craftcms.conf
In the file, add the following configuration:
ServerAdmin admin@your-domain.com DocumentRoot /var/www/html/craftcms/web ServerName your-domain.com ServerAlias www.your-domain.com Options Indexes FollowSymLinks AllowOverride All Require all granted ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
Replace "your-domain.com
' with your domain name. Save and close the file, then enable the new site and rewrite the module:
sudo a2ensite craftcms sudo a2enmod rewrite sudo systemctl restart apache2
Step 7. Secure Craft CMS with SSL.
First, you need to install Certbot, a client package that manages Let’s Encrypt SSL. You can install it using the following command:
sudo apt-get install python3-certbot-apache
Next, you can use Certbot to obtain and install an SSL certificate for your domain. Replace with your domain name. com
Use your actual domain name:
sudo certbot --apache -d your-domain.com
During the installation process, Certbot will prompt you to enter some basic information, including your email address and domain name. Follow the prompts to complete the installation.
Step 8. Configure firewall.
First, you need to install UFW, a user-friendly front-end for managing Linux firewalls. You can install it using the following command:
sudo apt update sudo apt upgrade sudo apt install ufw
Now we set up a simple firewall (UFW) using Apache to allow public access to HTTP and HTTPS on the default web port:
sudo ufw allow 'Apache Full' sudo ufw allow 'Apache Secure'
Step 9. Access the Craft CMS web interface
You can now access the Craft CMS Installation Wizard by navigating to your domain in your web browser. Follow the on-screen instructions to complete the installation.
Thank you for using this tutorial to install the latest version of Craft CMS on Debian 12 Bookworm. For more help or useful information, we recommend checking out the official Craft CMS website.
The above is the detailed content of How to install Craft CMS 12 on Debian. For more information, please follow other related articles on the PHP Chinese website!