CentOS 7 上安装 Drupal 8

蒲公英 提交于 周四, 08/17/2017 - 21:44
CentOS 7 上安装 Drupal 8

说明:本文也适用于 Drupal 7

安装 Drupal 8 之前,你需要在 CentOS 7 上安装 LEMP ,没有安装的话请参考《CentOS7 上安装 LEMP》

第一步: 下载 Drupal

  • 从官方站点直接下载 Drupal,当前版本 8.2.2。
    wget  http://ftp.drupal.org/files/projects/drupal-8.2.2.tar.gz
  • 解压
    tar zxvf drupal-8.2.2.tar.gz
  • 把解压后文件移动到默认 web 目录
    sudo mv drupal-8.2.2  /usr/share/nginx/html

第二步: 配置

  • 切换到 Drupal 目录
    cd /usr/share/nginx/html/drupal-8.2.2
  • 基于 default.settings.php 创建 settings.php
    cp sites/default/default.settings.php sites/default/settings.php
  • 为配置文件及 default 目录增加写权限
    chmod a+w sites/default/settings.php
    chmod a+w sites/default

第三步: 创建 Drupal 数据库和用户

  • 进入 Mysql
    mysql -u root -p
  • 创建 drupal 数据库
    CREATE DATABASE drupal;
  • 创建用户
    CREATE USER druser@localhost;
  • 对新用户设置密码
    SET PASSWORD FOR druser@localhost= PASSWORD("password");
  • 赋予新用户权限
    GRANT ALL PRIVILEGES ON drupal.* TO druser@localhost IDENTIFIED BY 'password';
  • 刷新 Mysql
    FLUSH PRIVILEGES;
  • 退出 Mysql Shell
    exit

第四步: 配置 Nginx Server

  • 创建 Server 将以下内容保存为 drupal.conf 文件,放置在 /etc/nginx/conf.d 目录。
    server {
        server_name www.xxx.cn;
        listen 80;
        
        root /usr/share/nginx/html/drupal-8.2.2;
        
        access_log /var/log/nginx/xxx.cn-access.log;
        error_log /var/log/nginx/xxx.cn-error.log;
        
        index index.php;
    
        location / {
            try_files  $uri $uri/ /index.php?$args;
        }
    
        location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
            access_log    off;
            log_not_found off;
            expires       10d;
        }
        
        location ~ /\.ht {
            deny  all;
        }
        
        location ~ \.php {
            try_files $uri = 404;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME     $fastcgi_script_name;
            
            fastcgi_buffer_size 128k;
            fastcgi_buffers 256 16k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
            
            include /etc/nginx/fastcgi_params; 
        }
        
        location /_db_ {
            auth_basic "Admin Login";
            auth_basic_user_file /etc/nginx/pma_pass;
        }
        
        # Compression
        gzip  on;
        gzip_vary on;
        gzip_min_length 10240;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
        gzip_disable "MSIE [1-6]\.";
        
        # Filehandle Cache
        open_file_cache          max=2000 inactive=20s;
        open_file_cache_valid    60s;
        open_file_cache_min_uses 5;
        open_file_cache_errors   off;
    }
  • 重启 Nginx
    sudo systemctl enable nginx

第五步: 访问 Drupal,具体安装。

http://www.xxx.cn/drupal-8.2.2

 

Blog tags

博客评论

teluk kiluan (未验证) 提交于 周三, 09/27/2017 - 13:31

永久连接

You could definitely see your skills within the article you write.
The arena hopes for even more passionate writers like you who aren’t afraid to say how they believe.