Skip to content

Commit 4dc6ea8

Browse files
committed
fix: Linux User's Permissions
1 parent a56b719 commit 4dc6ea8

File tree

5 files changed

+61
-33
lines changed

5 files changed

+61
-33
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
### App ###
22
database/
3-
certificates/
43

54
# Created by https://www.toptal.com/developers/gitignore/api/linux,windows,macos,code,netbeans,phpstorm,composer
65
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,windows,macos,code,netbeans,phpstorm,composer

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,10 @@ Add `:8900` to view **PHPMyAdmin**
3939

4040
### Enable HTTPS (only to phpserver)
4141
To enable the HTTPS Protocol, *before running docker-compose*, create the path `app/certificates` and put your SSL Certificates there.
42-
Then, uncomment the SSL Section on `app/Dockerfile` (make sure that the certificate file names are the same as in the Dockerfile). Also uncomment the "HTTPS Port" (`# HTTPS Port`) and "HTTPS Configuration FIle" (`# HTTPS Conf. File`) on `docker-compose.yml`.
42+
Then, uncomment the SSL Section in `app/Dockerfile` (make sure that the certificate file names are the same as in the Dockerfile). Also uncomment the "HTTPS Port" (`# HTTPS Port`) and "HTTPS Configuration FIle" (`# HTTPS Conf. File`) in `docker-compose.yml`.
4343
After running the docker-compose you should be able to access [https://localhost](https://localhost).
44+
45+
### Fix Linux User's Permissions
46+
To correct user permission issues on Linux, uncoment the `USER_ID` and `GROUP_ID` arguments in `docker-compose.yml`.
47+
Make sure this values are the same as your user values, you can check these values in the terminal using the `id -u` (to view `USER_ID`) & `id -g` (to view `GROUP_ID`) commands.
48+
Also uncomment the "USER'S PERMISSION" section in `app/Dockerfile`, as well as the arguments at the top of the file (`USER_ID` and `GROUP_ID`).

README.pt-BR.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ Adicione `:8900` para visualizar o **PHPMyAdmin**
4141
Para habilitar o protocolo HTTPS, *antes de executar o docker-compose*, crie o diretório `app/certificates` e coloque seus certificados SSL lá.
4242
Então, descomente a seção SSL no `app/Dockerfile` (certifique-se de que os nomes dos arquivos de certificado sejam iguais aos do Dockerfile). Também descomente as linhas da "Porta HTTPS" (`# HTTPS Port`) e do "Arquivo de configuração HTTPS" (`# HTTPS Conf. File`) em `docker-compose.yml`.
4343
Depois de executar o docker-compose, você deve conseguir acessar [https://localhost](https://localhost).
44+
45+
### Corrigir problemas com permissões do usuário do Linux
46+
Para corrigir problemas de permissão do usuário no Linux, descomente os argumentos `USER_ID` e `GROUP_ID` em `docker-compose.yml`.
47+
Certifique-se de que esses valores são iguais aos seus valores de usuário, você pode verificar esses valores no terminal usando os comandos `id -u` (para visualizar `USER_ID`) e `id -g` (para visualizar `GROUP_ID`).
48+
Também remova o comentário da seção "PERMISSÃO DO USUÁRIO" em `app/Dockerfile`, bem como os argumentos na parte superior do arquivo (`USER_ID` e `GROUP_ID`).

app/Dockerfile

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
FROM php:7.4-apache
22

3-
ARG php_ini_model
4-
ARG php_ini_lampp
3+
ARG PHP_INI_MODEL
4+
ARG PHP_INI_LAMPP
5+
#ARG USER_ID
6+
#ARG GROUP_ID
57

68
RUN apt-get update && apt-get upgrade -y && \
79
apt-get install zlib1g-dev libpng-dev -y && \
@@ -18,23 +20,23 @@ RUN apt-get update && apt-get upgrade -y && \
1820
pecl install xdebug-2.8.1 && \
1921
docker-php-ext-enable xdebug && \
2022
a2enmod rewrite headers && \
21-
cp ${php_ini_model} ${php_ini_lampp} && \
22-
sed -i '/\[PHP\]/a y2k_compliance = On' ${php_ini_lampp} && \
23-
sed -i 's/serialize_precision = .*/serialize_precision = 100/g' ${php_ini_lampp} && \
24-
sed -i 's/;realpath_cache_size = .*/realpath_cache_size = 4096k/g' ${php_ini_lampp} && \
25-
sed -i 's/;realpath_cache_ttl = .*/realpath_cache_ttl = 120/g' ${php_ini_lampp} && \
26-
sed -i 's/max_execution_time = .*/max_execution_time = 5/g' ${php_ini_lampp} && \
27-
sed -i 's/max_input_time = .*/max_input_time = 60/g' ${php_ini_lampp} && \
28-
sed -i 's/;max_input_nesting_level = .*/max_input_nesting_level = 64/g' ${php_ini_lampp} && \
29-
sed -i 's/memory_limit = .*/memory_limit = 64M/g' ${php_ini_lampp} && \
30-
sed -i 's/;html_errors = On/html_errors = On/g' ${php_ini_lampp} && \
31-
sed -i 's/;docref_root = "\/phpmanual\/"/docref_root = "\/phpmanual\/"/g' ${php_ini_lampp} && \
32-
sed -i 's/post_max_size = .*/post_max_size = 25M/g' ${php_ini_lampp} && \
33-
sed -i 's/upload_max_filesize = .*/upload_max_filesize = 40M/g' ${php_ini_lampp} && \
34-
sed -i 's/max_file_uploads = .*/max_file_uploads = 3/g' ${php_ini_lampp} && \
35-
# sed -i '/;date.timezone =/a date.timezone = America/Fortaleza' ${php_ini_lampp} && \
36-
sed -i '/\[Pdo_mysql\]/a pdo_mysql.cache_size = 2000' ${php_ini_lampp} && \
37-
sed -i 's/mail.add_x_header = .*/mail.add_x_header = On/g' ${php_ini_lampp}
23+
cp ${PHP_INI_MODEL} ${PHP_INI_LAMPP} && \
24+
sed -i '/\[PHP\]/a y2k_compliance = On' ${PHP_INI_LAMPP} && \
25+
sed -i 's/serialize_precision = .*/serialize_precision = 100/g' ${PHP_INI_LAMPP} && \
26+
sed -i 's/;realpath_cache_size = .*/realpath_cache_size = 4096k/g' ${PHP_INI_LAMPP} && \
27+
sed -i 's/;realpath_cache_ttl = .*/realpath_cache_ttl = 120/g' ${PHP_INI_LAMPP} && \
28+
sed -i 's/max_execution_time = .*/max_execution_time = 5/g' ${PHP_INI_LAMPP} && \
29+
sed -i 's/max_input_time = .*/max_input_time = 60/g' ${PHP_INI_LAMPP} && \
30+
sed -i 's/;max_input_nesting_level = .*/max_input_nesting_level = 64/g' ${PHP_INI_LAMPP} && \
31+
sed -i 's/memory_limit = .*/memory_limit = 64M/g' ${PHP_INI_LAMPP} && \
32+
sed -i 's/;html_errors = On/html_errors = On/g' ${PHP_INI_LAMPP} && \
33+
sed -i 's/;docref_root = "\/phpmanual\/"/docref_root = "\/phpmanual\/"/g' ${PHP_INI_LAMPP} && \
34+
sed -i 's/post_max_size = .*/post_max_size = 25M/g' ${PHP_INI_LAMPP} && \
35+
sed -i 's/upload_max_filesize = .*/upload_max_filesize = 40M/g' ${PHP_INI_LAMPP} && \
36+
sed -i 's/max_file_uploads = .*/max_file_uploads = 3/g' ${PHP_INI_LAMPP} && \
37+
# sed -i '/;date.timezone =/a date.timezone = America/Fortaleza' ${PHP_INI_LAMPP} && \
38+
sed -i '/\[Pdo_mysql\]/a pdo_mysql.cache_size = 2000' ${PHP_INI_LAMPP} && \
39+
sed -i 's/mail.add_x_header = .*/mail.add_x_header = On/g' ${PHP_INI_LAMPP}
3840

3941
#
4042
# uncoment the section below to enable external ssl certificate
@@ -43,14 +45,29 @@ RUN apt-get update && apt-get upgrade -y && \
4345
#RUN a2enmod ssl
4446
#COPY ./certificates/my_ssl.crt /etc/ssl/certs/ssl.crt
4547
#COPY ./certificates/my_ssl.key /etc/ssl/private/ssl.key
46-
#ARG apache_conf_file
47-
#RUN sed -i '$ a <VirtualHost *:443>' ${apache_conf_file} && \
48-
# sed -i '$ a SSLEngine on' ${apache_conf_file} && \
49-
# sed -i '$ a SSLCertificateFile "/etc/ssl/certs/ssl.crt"' ${apache_conf_file} && \
50-
# sed -i '$ a SSLCertificateKeyFile "/etc/ssl/private/ssl.key"' ${apache_conf_file} && \
51-
# sed -i '$ a </VirtualHost>' ${apache_conf_file} && \
48+
#ARG APACHE_CONF_FILE
49+
#RUN sed -i '$ a <VirtualHost *:443>' ${APACHE_CONF_FILE} && \
50+
# sed -i '$ a SSLEngine on' ${APACHE_CONF_FILE} && \
51+
# sed -i '$ a SSLCertificateFile "/etc/ssl/certs/ssl.crt"' ${APACHE_CONF_FILE} && \
52+
# sed -i '$ a SSLCertificateKeyFile "/etc/ssl/private/ssl.key"' ${APACHE_CONF_FILE} && \
53+
# sed -i '$ a </VirtualHost>' ${APACHE_CONF_FILE} && \
5254
# update-ca-certificates
5355
#------------------------------------------------------------------------
5456

57+
#
58+
# uncoment the section below to fix linux users permission issue
59+
#
60+
#---------------------------USER'S PERMISSIONS---------------------------
61+
#RUN userdel -f www-data &&\
62+
# if getent group www-data ; then groupdel www-data; fi &&\
63+
# groupadd -g ${GROUP_ID} www-data &&\
64+
# useradd -l -u ${USER_ID} -g www-data www-data &&\
65+
# install -d -m 0755 -o www-data -g www-data /home/www-data &&\
66+
# chown --changes --silent --no-dereference --recursive \
67+
# --from=33:33 ${USER_ID}:${GROUP_ID} \
68+
# /home/www-data \
69+
# /var/www/html/
70+
#------------------------------------------------------------------------
71+
5572
EXPOSE 80
5673
EXPOSE 443

docker-compose.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ services:
55
context: ./app
66
dockerfile: Dockerfile
77
args:
8-
php_ini_model: '/usr/local/etc/php/php.ini-development'
9-
php_ini_lampp: '/usr/local/etc/php/conf.d/docker-lampp-dev.ini'
10-
# apache_conf_file: '/etc/apache2/sites-available/000-default.conf' # HTTPS Conf. File
8+
# USER_ID: 1000 # find yours with `id -u`
9+
# GROUP_ID: 1000 # find yours with `id -u`
10+
PHP_INI_MODEL: '/usr/local/etc/php/php.ini-development'
11+
PHP_INI_LAMPP: '/usr/local/etc/php/conf.d/docker-lampp-dev.ini'
12+
# APACHE_CONF_FILE: '/etc/apache2/sites-available/000-default.conf' # HTTPS Conf. File
1113
container_name: 'phpserver'
1214
environment:
1315
- ALLOW_OVERRIDE=true
@@ -22,9 +24,9 @@ services:
2224
image: mariadb
2325
container_name: 'phpserver-database'
2426
restart: always
25-
volumes:
26-
- ./database/data/mysql:/var/lib/mysql
27-
- ./database/logs/mysql:/var/log/mysql
27+
# volumes:
28+
# - ./database/data/mysql:/var/lib/mysql
29+
# - ./database/logs/mysql:/var/log/mysql
2830
environment:
2931
MYSQL_ROOT_PASSWORD: 'rootpass'
3032
MYSQL_DATABASE: test_db

0 commit comments

Comments
 (0)