How to install Craft CMS 12 on Debian

王林
Release: 2024-02-19 16:50:02
forward
786 people have browsed it

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.

如何在 Debian 上安装 Craft CMS 12

Installing Craft CMS 12 on Debian Bookworm

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
Copy after login

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
Copy after login

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
Copy after login

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;
Copy after login

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
Copy after login

Next, navigate to the Apache web root directory and install Craft CMS:

cd /var/www/html
sudo composer create-project craftcms/craft craftcms
Copy after login

Step 6. Configuring Apache

for Craft CMS

To 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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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'
Copy after login

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.

如何在 Debian 上安装 Craft CMS 12

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!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template