diff --git a/roles/phpmyadmin/tasks/enable-or-disable.yml b/roles/phpmyadmin/tasks/enable-or-disable.yml index 31faa2de3..019d70033 100644 --- a/roles/phpmyadmin/tasks/enable-or-disable.yml +++ b/roles/phpmyadmin/tasks/enable-or-disable.yml @@ -1,9 +1,13 @@ -- name: Enable phpMyAdmin via Apache, if phpmyadmin_enabled - command: a2ensite phpmyadmin.conf +- name: Enable phpMyAdmin via nginx, if phpmyadmin_enabled + template: + src: phpmyadmin.conf.j2 + dest: "{{ nginx_conf_dir }}/phpmyadmin.conf" when: phpmyadmin_enabled #when: apache_installed is defined and phpmyadmin_enabled -- name: Disable phpMyAdmin via Apache, if not phpmyadmin_enabled - command: a2dissite phpmyadmin.conf +- name: Disable phpMyAdmin via nginx, if not phpmyadmin_enabled + file: + path: "{{ nginx_conf_dir }}/phpmyadmin.conf" + state: absent when: not phpmyadmin_enabled #when: apache_installed is defined and not phpmyadmin_enabled diff --git a/roles/phpmyadmin/tasks/install.yml b/roles/phpmyadmin/tasks/install.yml index 5c2bbc567..794bb0df2 100644 --- a/roles/phpmyadmin/tasks/install.yml +++ b/roles/phpmyadmin/tasks/install.yml @@ -1,13 +1,3 @@ -- name: "Set 'apache_install: True' and 'apache_enabled: True'" - set_fact: - apache_install: True - apache_enabled: True - -- name: APACHE - run 'httpd' role - include_role: - name: httpd - - - name: Download {{ phpmyadmin_dl_url }} to {{ downloads_dir }} get_url: url: "{{ phpmyadmin_dl_url }}" # e.g. https://files.phpmyadmin.net/phpMyAdmin/5.0.4/phpMyAdmin-5.0.4-all-languages.zip @@ -55,13 +45,6 @@ # # recurse: yes # # state: directory -- name: Install /etc/{{ apache_conf_dir }}/phpmyadmin.conf from template, if phpmyadmin_enabled - template: - src: phpmyadmin.j2 - dest: "/etc/{{ apache_conf_dir }}/phpmyadmin.conf" - when: apache_installed is defined - - # RECORD phpMyAdmin AS INSTALLED - name: "Set 'phpmyadmin_installed: True'" diff --git a/roles/phpmyadmin/templates/config.inc.php b/roles/phpmyadmin/templates/config.inc.php index 63aaefee2..bbf0d82c2 100644 --- a/roles/phpmyadmin/templates/config.inc.php +++ b/roles/phpmyadmin/templates/config.inc.php @@ -26,4 +26,6 @@ $cfg['DefaultLang'] = 'en'; $cfg['ServerDefault'] = 1; $cfg['UploadDir'] = ''; $cfg['SaveDir'] = ''; -?> \ No newline at end of file +$cfg['Servers'][$i]['auth_type'] = 'http'; +?> + diff --git a/roles/phpmyadmin/templates/mkuser b/roles/phpmyadmin/templates/mkuser new file mode 100644 index 000000000..b7f22aa68 --- /dev/null +++ b/roles/phpmyadmin/templates/mkuser @@ -0,0 +1,3 @@ +CREATE USER 'Admin'@'localhost' IDENTIFIED BY 'changeme'; +GRANT ALL PRIVILEGES ON *.* TO 'Admin'@'localhost' WITH GRANT OPTION; +FLUSH PRIVILEGES; diff --git a/roles/phpmyadmin/templates/phpmyadmin.conf.j2 b/roles/phpmyadmin/templates/phpmyadmin.conf.j2 new file mode 100644 index 000000000..87924c66c --- /dev/null +++ b/roles/phpmyadmin/templates/phpmyadmin.conf.j2 @@ -0,0 +1,15 @@ +location ~ ^/phpmyadmin/(.*)\.php{ + alias /opt/phpmyadmin/$1.php; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + fastcgi_pass php; + fastcgi_index index.php; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + include fastcgi_params; +} +location /phpmyadmin/{ + root /opt/; +} diff --git a/roles/phpmyadmin/templates/phpmyadmin.j2 b/roles/phpmyadmin/templates/phpmyadmin.j2 deleted file mode 100644 index 38254d194..000000000 --- a/roles/phpmyadmin/templates/phpmyadmin.j2 +++ /dev/null @@ -1,5 +0,0 @@ -Alias /phpmyadmin /opt/phpmyadmin - - AllowOverride all - require all granted -