Как настроить среду Apache 2.4 при развертывании через Ansible в AWS?

Используя приведенную ниже книгу, я обнаружил, что / etc / apache2 / envvars не устанавливаются должным образом. Я нашел ссылки на то, что Apache 2.4 должен запускаться через модуль apache2ctl, и попытался использовать его для запуска службы. После запуска экземпляра EC2 я обнаружил, что служба Apache2.4 не работает из-за ошибок. Все делается с помощью этого учебника:

--- # Build Web Server
- name: Install Apache
hosts: localhost
become: yes
connection: local
gather_facts: yes
tasks:

- name: Add Repository for PHP 5.6
  apt_repository:
    repo: ppa:ondrej/php
    state: present

- name: Install Web Server Package
  apt:
    pkg: "{{ item }}"
    state: present
    update_cache: yes
  with_items:
  - "apache2"
  - "php5.6"
  - "php5.6-mbstring"
  - "php5.6-mcrypt"
  - "php5.6-mysql"
  - "php5.6-xml"
  - "php5.6-cli"
  - "libapache2-mod-php5.6"

- name: enable modules
  command: "a2enmod {{item}}"
  with_items:
  - rewrite
  - ssl


- name: Update Apache Config
  copy:
    src: /data/000-default.conf
    dest: /etc/apache2/sites-available
    owner: root
    group: root
    mode: 0644

- name: Enable Default website
  command: "a2ensite 000-default.conf"

- name: Update PHP CLI php.ini
  lineinfile:
    dest: /etc/php/5.6/cli/php.ini
    state: present
    insertbefore: EOF
    regexp: '^error_reporting'
    line: 'error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED'

  notify:
    - StartHttpd
  tags:
  - installapache
  handlers:
  - name: StartHttpd
    command: "apache2ctl restart"

После запуска описанного выше сценария ...

ubuntu@ip-10-250-0-62:~$ sudo apache2 -S
[Thu Jun 01 20:53:02.524073 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_LOCK_DIR} is not defined
[Thu Jun 01 20:53:02.524158 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_PID_FILE} is not defined
[Thu Jun 01 20:53:02.524231 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_RUN_USER} is not defined
[Thu Jun 01 20:53:02.524272 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_RUN_GROUP} is not defined
[Thu Jun 01 20:53:02.524311 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_LOG_DIR} is not defined
[Thu Jun 01 20:53:02.532379 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_RUN_DIR} is not defined
[Thu Jun 01 20:53:02.532637 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_LOG_DIR} is not defined
[Thu Jun 01 20:53:02.532830 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_LOG_DIR} is not defined
[Thu Jun 01 20:53:02.532886 2017] [core:warn] [pid 29832] AH00111: Config 
variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

ubuntu@ip-10-250-0-62:~$ sudo apache2ctl restart

ubuntu@ip-10-250-0-62:~$ sudo apache2 -S
[Thu Jun 01 20:53:14.440314 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_LOCK_DIR} is not defined
[Thu Jun 01 20:53:14.440398 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_PID_FILE} is not defined
[Thu Jun 01 20:53:14.440476 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_RUN_USER} is not defined
[Thu Jun 01 20:53:14.440519 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_RUN_GROUP} is not defined
[Thu Jun 01 20:53:14.440568 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_LOG_DIR} is not defined
[Thu Jun 01 20:53:14.448516 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_RUN_DIR} is not defined
[Thu Jun 01 20:53:14.448807 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_LOG_DIR} is not defined
[Thu Jun 01 20:53:14.448979 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_LOG_DIR} is not defined
[Thu Jun 01 20:53:14.449035 2017] [core:warn] [pid 29844] AH00111: Config 
variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

ubuntu@ip-10-250-0-62:~$ sudo su -

root@ip-10-250-0-62:~# . /etc/apache2/envvars

root@ip-10-250-0-62:/root# apache2ctl restart

root@ip-10-250-0-62:/root# apache2 -S
VirtualHost configuration: *:80 ip-10-250-0-62.us-west-2.compute.internal (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
0
задан 2 June 2017 в 00:03
1 ответ

Используйте service: name = apache ( name может отличаться в зависимости от дистрибутива). apache2ctl жалуется на то, что переменные среды не установлены. Эти параметры, скорее всего, будут установлены при запуске с помощью диспетчера инициализации (который вызывается с помощью модуля службы ).

0
ответ дан 5 December 2019 в 08:06

Теги

Похожие вопросы