〇Drupalの画面
〇インストール方法
1.下準備
~/.ansible.cfgに以下の内容を設定します
[ssh_connection]
pipelining=True
[defaults]
host_key_checking = False
2. インストール対象ホストのユーザやパスワードを環境に合わせてinventoryファイルに記入します
inventory例
[drupal]
192.168.1.61
[all:vars]
ansible_ssh_port=22
ansible_ssh_user=vagrant
ansible_ssh_pass=vagrant
ansible_sudo_pass=vagrant
3.inventory、drupal.ymlを準備し、以下のコマンドを実行します。
ansible-playbook -i inventory drupal.yml
drupal.yml
- hosts: drupal
vars:
- dbname: drupal
- dbuser: drupal
- dbpassword: drupal
- dbhost: localhost
- dbport: 3306
- servername: 192.168.1.61
tasks:
- name: set password for root
shell: echo "mariadb-server-10.1 mysql-server/root_password password root" | sudo debconf-set-selections
become: yes
- name: set password for root
shell: echo "mariadb-server-10.1 mysql-server/root_password_again password root" | sudo debconf-set-selections
become: yes
- name: install mariadb
apt:
name: mariadb-server
state: present
become: yes
- name: enable and start mariadb
systemd:
name: mysql
enabled: yes
state: started
become: yes
- name: Install required software
apt: name={{ item }} state=present
with_items:
- libmysqlclient-dev
- python-pip
become: true
- name: install MySQL-python using pip
pip:
name: "{{ item }}"
state: forcereinstall
with_items:
- pip
- MySQL-python
become: true
- name: create db
mysql_db:
name={{ dbname }}
state=present
encoding=utf8
login_user=root
become: true
- name: create and grant a database user
mysql_user:
name={{ dbuser }}
password={{ dbpassword }}
priv="drupal.*:ALL"
state=present
become: true
- name: Install apache and php modules
apt: name={{ item }} state=present
with_items:
- apache2
- libapache2-mod-php7.2
- php7.2-gd
- php7.2-json
- php7.2-mysql
- php7.2-pdo
- php7.2-curl
- php7.2-mbstring
- php7.2-xml
- php7.2-zip
- php7.2-opcache
become: true
- name: download drupal
get_url:
url: https://ftp.drupal.org/files/projects/drupal-8.5.6.tar.gz
dest: /tmp/
become: true
- name: extract drupal
unarchive:
remote_src: yes
src: /tmp/drupal-8.5.6.tar.gz
dest: /opt/
become: true
- name: change owner
file:
path: /opt/drupal-8.5.6
owner: www-data
group: www-data
recurse: yes
become: true
- name: clean up
file:
state: absent
path: /tmp/drupal-8.5.6.tar.gz
become: yes
- name: configure virtual host
blockinfile:
dest: /etc/apache2/sites-available/drupal.conf
create: yes
block: |
<VirtualHost *:80>
ServerName {{ servername }}
DocumentRoot /opt/drupal-8.5.6
<Directory "/opt/drupal-8.5.6">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
</VirtualHost>
become: true
- name: enable mod_rewrite
apache2_module:
state: present
name: rewrite
become: yes
- name: disable default site
command: a2dissite 000-default.conf
become: true
- name: enablee a site
command: a2ensite drupal.conf
become: true
- name: start apache2.service
systemd:
name: apache2
state: restarted
become: yes
4.ブラウザからhttp://<対象ホスト>/にアクセスします。「Save and continue」ボタンをクリックします。
5.「標準」を選択して「保存して次へ」をクリックします
6.データベース名・ユーザー名・パスワードに「drupal」を入力して「保存して次へ」ボタンをクリックします
7.サイト名・管理者の情報を入力します
8.インストール完了画面
○関連情報
・Drupalに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿