[LINUX] How to change Apache's Document Root in Elastic Beanstalk's .ebextensions

When launching EC2 on Elastic Beanstalk, Apache's Document Root

httpd.conf



      DocumentRoot "/var/www/html/"

It has become. I tried to change this, but I did something a little tricky, so I'll leave it.

environment

64bit Amazon Linux/2.9.3 Apache/2.4.41

manner

Put the following files in the .ebextensions folder.

apache.config


files:
  /etc/httpd/conf/myhttpd.conf:
    content: |
      ##The contents of the conf file with the Docment Root changed are described below.
      ##For example ↓↓
      DocumentRoot "/var/www/html/public"

      #### End of AWS Settings ####
container_commands:
  00-rm-httpd-conf:
    command: "sudo rm /etc/httpd/conf/httpd.conf"
  01-cp-conf-file:
    command: "sudo cp /etc/httpd/conf/myhttpd.conf /etc/httpd/conf/httpd.conf"
  02-httpd-restart:
    command: "sudo httpd -k restart"

In this file (1) Place the configuration file myhttpd.conf with the changed Document Root in EC2. (2) After starting Apache with the original configuration file httpd.conf, delete httpd.conf ③ Replace myhttpd.conf with httpd.conf ④ Restart Apache I am following the procedure.

Why you are following this procedure

Originally I tried to overwrite httpd.conf before the first Apache launch, but for some reason Document Root was rewritten to the default. So I took a little tricky procedure.

Recommended Posts

How to change Apache's Document Root in Elastic Beanstalk's .ebextensions
How to change editor color in PyCharm
How to write a named tuple document in 2020
How to change static directory from default in Flask
[Work efficiency] How to change file names in Python
How to change Jupyter layout
How to change Python version
[Python] How to change EXCEL file saved in xlsb to xlsx
How to develop in Python
How to change the color of just the button pressed in Tkinter
How to handle session in SQLAlchemy
How to use classes in Theano
How to write soberly in pandas
How to collect images in Python
How to update Spyder in Anaconda
How to use SQLite in Python
[Ansible] How to prevent forced change
How to convert 0.5 to 1056964608 in one shot
How to reflect CSS in Django
How to kill processes in bulk
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to change vim color scheme
How to use PubChem in Python
How to run TensorFlow 1.0 code in 2.0
How to handle Japanese in Python
How to log in to Docker + NGINX
How to call PyTorch in Julia
How to change multiple columns of csv in Pandas (Unixtime-> Japan Time)
How to use calculated columns in CASTable
[Introduction to Python] How to use class in Python?
How to suppress display error in matplotlib
How to dynamically define variables in Python
How to do R chartr () in Python
How to convert csv to tsv in CLI
How to write Python document comments (Docstrings)
How to delete expired sessions in Django
How to use Google Test in C
How to implement nested serializer in drf-flex-fields
How to work with BigQuery in Python
How to execute commands in jupyter notebook
How to do'git fetch --tags' in GitPython
How to get a stacktrace in python
How to display multiplication table in python
How to extract polygon area in Python
How to reassign index in pandas dataframe
How to check opencv version in python
How to enable SSL (TLS) in Apache
How to install your own (root) CA
How to specify non-check target in Flake8
How to handle consecutive values in MySQL
How to switch python versions in cloud9
How to adjust image contrast in Python
How to use __slots__ in Python class
How to dynamically zero pad in Python
How to do Server-Sent Events in Django
How to use regular expressions in Python
How to implement Scroll View in pythonista 1
How to convert DateTimeField format in Django
How to use Map in Android ViewPager