Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lampserver
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Daniel González Peña
lampserver
Commits
0de6a6c5
Commit
0de6a6c5
authored
Sep 22, 2017
by
Daniel González Peña
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
0 deletions
+113
-0
Dockerfile
Dockerfile
+3
-0
README.md
README.md
+46
-0
run.sh
run.sh
+64
-0
No files found.
Dockerfile
0 → 100644
View file @
0de6a6c5
FROM
mattrayner/lamp:latest-1604
ADD
run.sh /run.sh
README.md
0 → 100644
View file @
0de6a6c5
# LAMP (Linux/Apache/MySQL/PHP)
This LAMP docker image is based on
`mattrayner/lamp:latest-1604`
image.
You have more detailed information at https://hub.docker.com/r/mattrayner/lamp/
# Build the image
First, you have to build the docker image. This process has to be done only once.
```
git clone https://www.sing-group.org/dt/gitlab/dgpena/lampserver
cd lampserver
docker build . -t lampserver
```
# Running the server
Go to the directory
**where your web files are placed**
, and run:
```
docker run -it -e PHP_DISPLAY_ERRORS=On -e DOCKER_USER_ID=`id -u \`whoami\`` \
-p "80:80" -v ${PWD}:/app -v ${PWD}/mysql:/var/lib/mysql --name lampserver-1 \
--rm lampserver
```
`lampserver-1`
is the name of the docker
*container*
, i.e, a running instance
of the
`lampserver`
image.
The first time you run the server in your directory, a MySQL data folder will
be created inside your web directory under
`./mysql`
(you can change this if you want changing
`-v <directory_for_mysql_data>:/var/lib/mysql`
).
A password for the
`admin`
user of MySQL is shown the first time.
Your server is available at: http://localhost (if you want to use another port
of your host machine, change
`-p "80:80"`
by
`-p "<another_port>:80"`
)
# Using MySQL
1.
You can use PHPMyAdmin by going to http://localhost/phpmyadmin. You have
to login with the
`admin`
user.
2.
Alternatively, you can use the MySQL client for a running instance by issuing:
```
docker exec -it lampserver-1 mysql -uroot
```
# Backup a database
You can get an SQL dump of a given database in your running instance by issuing:
```
docker exec -it lampserver-1 mysqldump -uroot [yourdatabasename] > db.sql
```
run.sh
0 → 100755
View file @
0de6a6c5
#!/bin/bash
VOLUME_HOME
=
"/var/lib/mysql"
sed
-ri
-e
"s/^upload_max_filesize.*/upload_max_filesize =
${
PHP_UPLOAD_MAX_FILESIZE
}
/"
\
-e
"s/^post_max_size.*/post_max_size =
${
PHP_POST_MAX_SIZE
}
/"
/etc/php/5.6/apache2/php.ini
if
[
"
$PHP_DISPLAY_ERRORS
"
==
"On"
]
;
then
sed
-ri
-e
"s/^display_errors.*/display_errors = On/"
/etc/php/5.6/apache2/php.ini
fi
sed
-i
"s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=staff/"
/etc/apache2/envvars
if
[
-n
"
$APACHE_ROOT
"
]
;
then
rm
-f
/var/www/html
&&
ln
-s
"/app/
${
APACHE_ROOT
}
"
/var/www/html
fi
sed
-i
-e
"s/cfg
\[
'blowfish_secret'
\]
= ''/cfg['blowfish_secret'] = '
`
date
|
md5sum
`
'/"
/var/www/phpmyadmin/config.inc.php
mkdir
-p
/var/run/mysqld
usermod
-u
$DOCKER_USER_ID
www-data
if
[
-n
"
$VAGRANT_OSX_MODE
"
]
;
then
groupmod
-g
$((
$DOCKER_USER_GID
+
10000
))
$(
getent group
$DOCKER_USER_GID
|
cut
-d
:
-f1
)
groupmod
-g
${
DOCKER_USER_GID
}
staff
chmod
-R
770 /var/lib/mysql
chmod
-R
770 /var/run/mysqld
chown
-R
www-data:staff /var/lib/mysql
chown
-R
www-data:staff /var/run/mysqld
else
# Tweaks to give Apache/PHP write permissions to the app
chown
-R
www-data:staff /var/www
chown
-R
www-data:staff /app
chown
-R
www-data:staff /var/lib/mysql
chown
-R
www-data:staff /var/run/mysqld
chmod
-R
770 /var/lib/mysql
chmod
-R
770 /var/run/mysqld
fi
rm
/var/run/mysqld/mysqld.sock
sed
-i
"s/bind-address.*/bind-address = 0.0.0.0/"
/etc/mysql/my.cnf
sed
-i
"s/user.*/user = www-data/"
/etc/mysql/my.cnf
if
[[
!
-d
$VOLUME_HOME
/mysql
]]
;
then
echo
"=> An empty or uninitialized MySQL volume is detected in
$VOLUME_HOME
"
echo
"=> Installing MySQL ..."
# Try the 'preferred' solution
mysqld
--initialize-insecure
>
/dev/null 2>&1
# IF that didn't work
if
[
$?
-ne
0
]
;
then
# Fall back to the 'depreciated' solution
mysql_install_db
>
/dev/null 2>&1
fi
echo
"=> Done!"
/create_mysql_users.sh
else
echo
"=> Using an existing volume of MySQL"
fi
exec
supervisord
-n
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment