Do you want to improve this question?Edit your post to clarify the issue you are trying to resolve by adding details.
Closed 4 years ago.
4 years agoI would like to automate the LAMP environment with shell scripts in the Ubuntu container of Docker.
It seems that the following steps will be used to build the environment, but there are some parts that have been omitted or modified (...) to ask some questions.
Question Items
Environment building procedures
Installing the Basic System
%apt-get install php composer apache2 mysql-server supervisor
Launch daemon
%service apache2start
% service supervisor start
Install PHP Add-On
%apt-get install php 7.0-mysql, etc.
Apache module enabled
%a2enmod ssl
% a2enmod php 7.0
% a2enmod rewrite
% service apache2 restart
Change /etc/apache2/apache2.conf
to the following parts
<Directory/var/www/>
AllowOverride All
</Directory>
Install nodejs
%curl-sL https://deb.nodesource.com/xxxxxx.x | bash-
% apt-get install nodejs
Install xvfb-related libraries
%apt-get install libgtk xvfb
Launch xvfb
$Xvfb...
Install various libraries
$cd/var/www/...
$ npm install
$ cd/var/www/...
$ composer install
Create env file
$cd/var/www/...
$ cp.env.example.env
Set temporary folder permissions
Go to cd and set to different directories
$chmod1777
Supervisor Configuration (Link?)
%ln-s...larvel-worker.conf
Change Apache Document Route
/etc/apache2/sites-available/default-ssl.conf
How to change the appropriate part
DocumentRoot/var/www/...
I will write as far as I can answer.
·Difference between % and $ of each code
The difference between the running user and the regular user.The root is % and the general user $.
·Is it necessary to start xvfb of daemon activation の of の?(Is there any inconvenience if I don't start it?)
If you do not start the daemon program, it will not work when you use it.
·I don't understand what ⑩⑪ の is doing due to lack of knowledge
ch Change the execution permissions in chmod.Enable writing and execution.
·Regarding と and に, please tell me the usual method with code (whether to overwrite the configuration file separately or rewrite only the relevant part)
I will use both.Use the sed command for partial rewrite and the cat command for file replacement.
Sites that might help you with sed
https://www.ibm.com/support/knowledgecenter/ja/ssw_aix_72/com.ibm.aix.genprogc/manip_strings_sed.htm
Sites that might be helpful across scripts
http://blog.hitsujin.jp/entry/2011/03/09/140329
You want to create a configuration file with a shell script.
You can create a file using cat.
cat<<EOF> Filename to create
Describe the contents of the file
::::
::::
EOF
Shell Script Sample:
#!/bin/bash
# Set the full path of the filename you want to create to the variable
NEW_FILE=/var/hoge/foo/bar.txt
# Extract the directory of the file and set it to a variable
DIRECTORY="$(dirname$NEW_FILE)"
# Create Directory
mkdir-p "$DIRECTORY"
# Go to Directory
cd "$DIRECTORY"
# Create file (overwrite if already present)
cat<<EOF>$NEW_FILE
!! Write the contents of the configuration file here.!!
!! The variable expands to a value by writing:!!
${NEW_FILE}
!! The file is written up to the last minute (i.e., this line) of the EOF for this ↓.!!
EOF
# Return to the last directory
cd-
When you actually run the script and view the created file, you should see the following:
$bash./sample.sh
$ cat/var/hoge/foo/bar.txt
!! Write the contents of the configuration file here.!!
!! The variable expands to a value by writing:!!
/var/hoge/foo/bar.txt
!! The file is written up to the last minute (i.e., this line) of the EOF for this ↓.!!
(Additional)
Is it necessary to start xvfb of daemon activation の of の?(Is there any inconvenience if I don't start it?)
If apache2 is not started, the LAMP environment will not work.
I don't know what xvfb is for, but maybe it's for browser testing.If you want to use it, please move it.
⑩ I don't understand what ⑪⑫ の is doing because I don't know enough
: : Copying the .env.example file to /var/www/...I don't know the contents, so please check the contents of the .env.example file.
⑪ —Configuring directory permissions, where 1777
grants read/write permissions to all users, but only the owner can delete them.(called sticky bits)
⑫ —Creating symbolic links.
Regarding と and に, please tell me the usual method with code (whether to create a separate configuration file and overwrite it or rewrite only the relevant part)
:: I think there are many ways to do it, so I can't say which one is better, so I personally prefer to create a new configuration file because I think it's a bit troublesome to rewrite multiple lines.Also, I'm going to turn it off because I can't get in the way of commenting out.
cat<<EOF>/etc/apache2/apache.conf
Mutex file: ${APACHE_LOCK_DIR} default
PidFile${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout5
User${APACHE_RUN_USER}
Group${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog${APACHE_LOG_DIR}/error.log
LogLevel warn
Include Optional mods-enabled/*.load
Include Optional mods-enabled/*.conf
Include ports.conf
<Directory/>
Options FollowSymlinks
AllowOverride None
Require all denied
</Directory>
<Directory/usr/share>
AllowOverride None
Require all graded
</Directory>
<Directory/var/www/>
AllowOverride All
</Directory>
AccessFileName.htaccess
<FilesMatch "^\.ht" >
Require all denied
</FilesMatch>
LogFormat"%v:%p%h%l%u%t\"%r\"%>s%O\"%{Refer}i\"\"%{User-Agent}i\""vhost_combined
LogFormat "%h%l%u%t\"%r\"%>s%O\"%{Refer}i\"%{User-Agent}i\""combined
LogFormat "%h%l%u%t\"%r\"%>s%O" common
LogFormat "%{Refer} i->%U" referrer
LogFormat"%{User-agent}i"agent
IncludeOptional conf-enabled/*.conf
IncludeOptionsites-enabled/*.conf
EOF
cat<<EOF>/etc/apache2/sites-available/default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost_default_:443>
ServerAdmin webmaster@localhost
ServerName 1.2.3.4:443
DocumentRoot/var/www/........
ErrorLog${APACHE_LOG_DIR}/error.log
CustomLog${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile/etc/apache2/ssl/apache.crt
SSLCertificateKeyFile/etc/apache2/ssl/apache.key
<FilesMatch"\.(cgi|shtml|phtml|php)$">
SSLOptions + StdEnvVars
</FilesMatch>
<Directory/usr/lib/cgi-bin>
SSLOptions + StdEnvVars
</Directory>
BrowserMatch "MSIE[2-6]"\
no keepalive ssl-unclean-shutdown\
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
<Location/devbox>
ProxyPass http://localhost:4200/
</Location>
</IfModule>
EOF
Regarding docker, in what order do you usually use it when developing it as a team? (Create -> Distribute images to members -> Create containers using the images -> Save changes in containers as separate images in commit -> I don't understand the flow from here.Also, is the flow so far correct?) How do you integrate the changes (merge in Git?)
It's written by yourself, but I think it's common to use version control software such as git to separate branches and merge them.
© 2024 OneMinuteCode. All rights reserved.