在Debian 9上安裝Fork CMS

Fork是一個用PHP編寫的開源CMS。Fork的源代碼託管在GitHub上。本指南將向您展現如何在一個新的Debian 9 VPS實例上安裝Fork CMS。php

需求html

PHP 7.1或更高版本。mysql

如下PHP擴展:linux

  • cURL
  • libxml
  • DOM
  • SimpleXML
  • SPL
  • PDO (與MySQL驅動程序)
  • mb_string
  • iconv
  • GD2圖形庫
  • json
  • PCRE
  • intl

MySQL 5.0或更高版本。nginx

Nginxgit

檢查Debian版本。web

lsb_release -dssql

# Debian GNU/Linux 9.4 (stretch)shell

確保您的系統是最新的。數據庫

apt update && apt upgrade -y

安裝所須要的包。

apt install -y apt-transport-https sudo curl wget dirmngr

使用sudo訪問建立一個新的non-root賬戶並切換到它。

adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe

注意:用你的用戶名替換johndoe。

設置時區。

timedatectl list-timezones

sudo timedatectl set-timezone Region/City

步驟1 -安裝PHP和所需的PHP擴展,MySQL和Nginx

Debian沒有在其默認軟件庫中提供最新的PHP版本。咱們須要添加一個社區維護的第三方存儲庫。

sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update

安裝PHP 7.2和所需的PHP擴展。

sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-curl php7.2-mbstring php7.2-gd php7.2-intl php7.2-mysql php7.2-xml php7.2-json

檢查版本。

php --version
PHP 7.2.5-1+0~20180505045740.21+stretch~1.gbpca2fa6 (cli) (built: May  5 2018 04:57:44) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.5-1+0~20180505045740.21+stretch~1.gbpca2fa6, Copyright (c) 1999-2018, by Zend Technologies

第二步——MySQL/MariaDB和設置數據庫

安裝MySQL - MariaDB。

sudo apt install -y mysql-server

檢查MySQL / MariaDB版本。

mysql --version
# mysql  Ver 15.1 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

運行mysql_secure安裝腳本以提升MySQL的安全性,並設置MySQL根用戶的密碼。

sudo mysql_secure_installation

做爲根用戶鏈接到MySQL shell。

sudo mysql -u root -p
# Enter password

爲Fork CMS建立一個空的MySQL數據庫和用戶,並記住憑證。

步驟3 -安裝和配置Nginx

安裝Nginx。

sudo apt install -y nginx

檢查版本。

sudo nginx -v
# nginx version: nginx/1.10.3

運行sudo vim /etc/nginx/sit -available/fork。conf併爲Fork配置Nginx。

server {
    listen 80;
    root /var/www/fork;
    index index.php index.html;
    server_name example.com;
    location / {
    # Checks whether the requested url exists as a file $uri or directory $uri/ in the root, else redirect to /index.php.
        try_files $uri $uri/ @redirects;
    }
    location @redirects {
        rewrite ^ /index.php;
    }
    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # Make sure to doublecheck this!
        fastcgi_index index.php;
        fastcgi_read_timeout 60;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    # Don't pollute the logs with common requests
    location = /robots.txt  { access_log off; log_not_found off; }
    location = /favicon.ico { access_log off; log_not_found off; }
    # As Fork CMS has the app_root as doc_root, we need to restrict access to a few things for security purposes!
    location ~* ^/(composer\..*|vendor\/.*|Procfile$|\.git\/.*|src\/Console.*|.*\.gitignore|\.editorconfig|\.travis.yml|autoload\.php|bower\.json|phpunit\.xml\.dist|.*\.md|app\/logs\/.*|app\/config\/.*|src\/Frontend\/Cache\/CompiledTemplates.*|src\/Frontend\/Cache\/Locale\/.*\.php|src\/Frontend\/Cache\/Navigation\/.*\.php|src\/Frontend\/Cache\/Search\/.*|src\/Backend\/Cache\/CompiledTemplates\/.*|src\/Backend\/Cache\/Locale\/.*\.php)$ {
        deny all;
        access_log off;
        log_not_found off;
    }
    # Deny access to dot-files.
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }
}

如下是您將要進行的更改的摘要。

更改根指令的值以指向網站的正確位置,例如/var/www/fork

更改server_name指令的值以指向您的域名或IP地址。

確保正確地設置了fastcgi_pass。

保存文件並退出。

激活新的叉子。經過將文件連接到啓用了站點的目錄來進行conf配置。

sudo ln -s /etc/nginx/sites-available/fork.conf /etc/nginx/sites-enabled/

測試Nginx配置。

sudo nginx -t

從新加載Nginx。

sudo systemctl reload nginx.service

步驟4 -下載和安裝編寫器

下載 Composer dependencies.

sudo apt install -y curl git unzip
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

檢查版本。

composer --version
# Composer version 1.6.5 2018-05-04 11:44:59

步驟5 -經過編寫器下載和安裝Fork CMS

建立一個文檔根目錄。

sudo mkdir -p /var/www/fork

將/var/www/fork目錄的全部權更改成johndoe。

sudo chown -R johndoe:johndoe /var/www/fork

從命令行下載Fork CMS的最新穩定版本。

cd /var/www/fork
composer create-project forkcms/forkcms .

將/var/www/fork目錄的全部權更改成www-data。

sudo chown -R www-data:www-data /var/www/fork

編輯app / config / parameters.yml。分區文件並設置數據庫信息。

sudo vim /var/www/fork/app/config/parameters_install.yml

使用您喜歡的web瀏覽器,打開您的網站並遵循Fork CMS安裝程序。在跟隨安裝程序以後,你應該有一個叉子和運行。要訪問Fork管理區域,只需將/private附加到您的站點URL。

相關文章
相關標籤/搜索