Running test Docker containers
sudo docker network create --subnet=172.20.0.0/16 legacy_net
sudo docker network ls
NETWORK ID NAME DRIVER SCOPE
61aa4a19ec0c bridge bridge local
7c0ebcfd4e3a dockovpn_default bridge local
79ed9c355254 host host local
99d8bde8e488 legacy_net bridge local
086455f026a8 none null local
sudo docker run --rm --name mysql5 --net legacy_net --net-alias mysql5 --ip 172.20.0.2 -e MYSQL_ROOT_PASSWORD=$MROOTPASS -d mysql:5.7
telnet 172.20.0.2 3306
sudo docker run -d --rm --name php53 --net legacy_net --net-alias php53 --ip 172.20.0.3 -v /home/beauty/www:/home/beauty/www u12php53fix2
telnet 172.20.0.3 9000
PHP-FPM configuration
PHP-FPM does not contain IP addresses, because Jooma configuration file is on the host machine.
sudo docker exec -it php53 bash
cat /etc/php5/fpm/common.conf
listen = 9000
;listen.allowed_clients = 172.17.0.1
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
cat /etc/php5/fpm/pool.d/beauty.conf
[beauty]
user = nobody
group = beauty
include=/etc/php5/fpm/common.conf
access.log = /var/log/php-fpm/$pool.access.log
catch_workers_output = yes
#php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/php-fpm/$pool.error.log
php_admin_flag[log_errors] = on
pm = dynamic
pm.max_children = 10
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 2
pm.max_requests = 500
listen.backlog = -1
pm.status_path = /status
slowlog = /var/log/php-fpm/$pool.slow.log
request_slowlog_timeout = 5s
request_terminate_timeout = 300s
rlimit_files = 131072
rlimit_core = unlimited
chdir = /
su - beauty
mysql -u beauty -h172.20.0.2 -p
mysql -u beauty -h mysql5 -p
Nginx configuration
sudo nano /etc/nginx/sites-available/beauty
server {
root /home/beauty/www;
index index.php index.html index.htm default.html default.htm;
access_log /var/log/nginx/beauty.access.log;
error_log /var/log/nginx/beauty.error.log info;
server_name milomag.ru www.milomag.ru;
server_name xn--80agwdbl3g.xn--p1ai www.xn--80agwdbl3g.xn--p1ai;
set $mirror 0;
if ($http_host != milomag.ru) {
set $mirror 1;
}
if ($request_uri = /robots.txt) {
set $mirror 0;
}
if ($mirror = 1)
{
rewrite ^ http://milomag.ru$request_uri permanent;
}
if ($request_uri = /home) {
rewrite ^ http://milomag.ru permanent;
}
rewrite ^/images/stories/(.*)\.(jpg|jpeg|png|gif) /libraries/shared/text-watermark/beauty-watermark.php?$request_filename;
rewrite ^/components/com_virtuemart/shop_image/product/(.*)\.(jpg|jpeg|png|gif) /libraries/shared/text-watermark/virtuemart-watermark.php?$request_filename;
rewrite ^/oplata http://$http_host/store?page=account.index;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ /private {
deny all;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 172.20.0.3:9000;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SHARED_WWW /home/beauty/www/libraries/shared/;
}
location ~ /\.ht {
deny all;
}
}
server {
#milomag.ru shows "your cart is empty" message when opening a category with SSL front end, but back end works fine, this should be fixed before enabling SSL
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/milomag.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/milomag.ru/privkey.pem;
root /home/beauty/www;
index index.php index.html index.htm default.html default.htm;
access_log /var/log/nginx/beauty-ssl.access.log;
error_log /var/log/nginx/beauty-ssl.error.log info;
server_name milomag.ru www.milomag.ru;
server_name xn--80agwdbl3g.xn--p1ai www.xn--80agwdbl3g.xn--p1ai;
location / {
rewrite ^ http://milomag.ru$request_uri permanent;
}
location /administrator {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /xmlrpc {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
#Tiny MCE includes advcode script from this folder
location /plugins/editors {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /private {
try_files $uri $uri/;
}
location /livezilla {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ ^/(administrator|private|livezilla|xmlrpc)/.*\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 172.20.0.3:9000;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param HTTPS on;
}
}
Restoring the website
sudo su - beauty
cd bak/
read -s MROOTPASS
export MROOTPASS
export MHOST=172.20.0.2
export CREATE_REMOTE_USER=1
resite.sh beauty.2022-10-04-2141.tar.gz
nano ~/www/configuration.php
var $host = '172.20.0.2';
sudo docker restart php53
Make the files read-only for PHP:
find www -perm /g=w
chmod -R g-w www
Running production Docker containers
cd /var/lib
sudo mkdir legacy
sudo docker run -d --restart always --name mysql5 -v /var/lib/legacy/mysql:/var/lib/mysql --net legacy_net --net-alias mysql5 --ip 172.20.0.2 -e MYSQL_ROOT_PASSWORD=$MROOTPASS mysql:5.7
mysql -u root -h 172.20.0.2 -p$MROOTPASS
sudo docker run -d --restart always --name php53 --net legacy_net --net-alias php53 --ip 172.20.0.3 -v /home/beauty/www:/home/beauty/www u12php53fix2
telnet 172.20.0.3 9000
Amount of space used by database
sudo du -ha --max-depth 1 | sort -h
0 ./mysql.sock
4.0K ./auto.cnf
4.0K ./ca-key.pem
4.0K ./ca.pem
4.0K ./client-cert.pem
4.0K ./client-key.pem
4.0K ./ib_buffer_pool
4.0K ./private_key.pem
4.0K ./public_key.pem
4.0K ./server-cert.pem
4.0K ./server-key.pem
680K ./sys
1.1M ./performance_schema
12M ./ibtmp1
25M ./mysql
48M ./ib_logfile0
48M ./ib_logfile1
76M ./ibdata1
2.4G ./beauty
2.6G .
Deleting spam users
mysql -u beauty -h 172.20.0.2 -p
select count(*) from jos_users;
+----------+
| count(*) |
+----------+
| 22935 |
+----------+
1 row in set (0.01 sec)
select count(*) from jos_users where usertype = 'Registered';
+----------+
| count(*) |
+----------+
| 22949 |
+----------+
1 row in set (0.00 sec)
delete from jos_users where usertype = 'Registered';
My experiments
mysql -u root -h 172.20.0.2 -p$MROOTPASS
SHOW VARIABLES WHERE Variable_Name LIKE "%dir";
+---------------------------+----------------------------+
| Variable_name | Value |
+---------------------------+----------------------------+
| basedir | /usr/ |
| character_sets_dir | /usr/share/mysql/charsets/ |
| datadir | /var/lib/mysql/ |
| innodb_data_home_dir | |
| innodb_log_group_home_dir | ./ |
| innodb_tmpdir | |
| lc_messages_dir | /usr/share/mysql/ |
| plugin_dir | /usr/lib64/mysql/plugin/ |
| slave_load_tmpdir | /tmp |
| tmpdir | /tmp |
+---------------------------+----------------------------+
10 rows in set (0.01 sec)
Resolve containers from host by network-alias or container name or host
https://forums.docker.com/t/resolve-containers-from-host-by-network-alias-or-container-name-or-host/23861/5
Take a look at this answer, this make possible to run a container and solve it by hostname at host machine, it would be helpful for development
docker run --rm --hostname dns.mageddo --name dns-proxy-server -p 5380:5380 \
-v /opt/dns-proxy-server/conf:/app/conf \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/resolv.conf:/etc/resolv.conf \
defreitas/dns-proxy-server
docker: run mysql container with specific uid:gid
https://stackoverflow.com/questions/61119964/docker-run-mysql-container-with-specific-uidgid
[mysqld]
user=app
How to delete spam users in Joomla/mysql
https://stackoverflow.com/questions/13881772/how-to-delete-spam-users-in-joomla-mysql
delete from jos_users where usertype = ‘Registered’;