Skip to content

svw.info

tranmh edited this page Apr 23, 2023 · 9 revisions

Server

configured with https://scp.strato.de/
Name: svw.info 
IP: 212.227.75.118
Core: 1 vCore 
RAM: 0.5 GB 
SSD: 40 GB	
OS: Ubuntu 20.04

Packages

apt-get update
apt-get install php apache2 mysql-server htop sendmail vim php-mysql -y
systemctl enable mysql
systemctl status apache2
systemctl enable apache2
apt-get install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y
systemctl restart apache2

MySQL create database and user

mysql> create database cms;
mysql> create user 'cms'@'localhost' IDENTIFIED BY 'XXX'; # /var/www/html/configuration.php
mysql> grant all privileges on cms.* to 'cms'@'localhost';
mysql> flush privileges;

php.ini

mkdir /var/www/tmp
chown -R www-data:www-data /var/www/tmp

root@localhost:/etc/php/7.4/apache2# diff php.ini php.ini.orig_2021-12-30
215c215
< output_buffering = Off
---
> output_buffering = 4096
694c694
< post_max_size = 200M
---
> post_max_size = 8M
842c842
< upload_tmp_dir = /var/www/tmp
---
> ;upload_tmp_dir =
846c846
< upload_max_filesize = 200M
---
> upload_max_filesize = 2M

systemctl restart apache2

htaccess

root@localhost:/var/www/html# apache2ctl -M
# "rewrite_module (shared)" was not seen
root@localhost:/var/www/html# a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
  systemctl restart apache2
root@localhost:/var/www/html# systemctl restart apache2
root@localhost:/var/www/html# apache2ctl -M
# "rewrite_module (shared)" is now listed

vi /etc/apache2/sites-enabled/000-default.conf
<Directory /var/www/html>
        Options +Includes -Indexes +MultiViews
        AllowOverride All
</Directory>

<VirtualHost *:80>
        RewriteEngine on

ssh authorized_keys from Idefix

scp /root/.ssh/authorized_keys [email protected]:/root/.ssh/

Apache2 log rotation

The default one seems to be good enough:

cat /etc/logrotate.d/apache2
/var/log/apache2/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    create 640 root adm
    sharedscripts
    postrotate
                if invoke-rc.d apache2 status > /dev/null 2>&1; then \
                    invoke-rc.d apache2 reload > /dev/null 2>&1; \
                fi;
    endscript
    prerotate
        if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
            run-parts /etc/logrotate.d/httpd-prerotate; \
        fi; \
    endscript
}

Mail forwarding of root user

 echo "[email protected], /root/mailbox" > /root/.forward

Time

date
#timedatectl list-timezones
timedatectl set-timezone Europe/Berlin
date

systemctl status systemd-timesyncd
vi /etc/systemd/timesyncd.conf
# add 
# NTP=ntp.uni-osnabrueck.de
# FallbackNTP=ntp.ubuntu.com
timedatectl set-ntp 1
systemctl restart systemd-timesyncd
sleep 10
systemctl status systemd-timesyncd

Backup

TODO, need to check cyber proctection console.

Apache with PHP-FPM

see also https://tecadmin.net/setup-apache-php-fpm-ubuntu-20-04/

sudo apt update 
sudo apt install apache2 libapache2-mod-fcgid -y

sudo apt install php7.4 php7.4-fpm -y
a2enmod proxy_fcgi setenvif
a2enconf php7.4-fpm

vim /etc/apache2/sites-available/000-default.conf
#add the following lines:
<FilesMatch \.php$>
	# 2.4.10+ can proxy to unix socket
	SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>

# we use the php.ini, which was already configured with apache2
mv /etc/php/7.4/fpm/php.ini /etc/php/7.4/fpm/php.ini_orig_2021-12-30
ln -s /etc/php/7.4/apache2/php.ini /etc/php/7.4/fpm/php.ini

systemctl restart php7.4-fpm
systemctl restart apache2

# tests:
systemctl status php7.4-fpm
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
# you should see "Server API FPM/FastCGI"

Resize / from 20GB to 40GB

using https://www.strato.de/faq/server/was-ist-beim-veraendern-der-block-storage-groesze-zu-beachten/#LVM-Ubuntu

Database and files from Idefix (Joomla 3.10.x)

scp -rp /var/mysqlbackup/cms/j25svw_*.sql [email protected]:/var/mysqlbackup/cms/

scp -rp /var/www/j25svw/htdocs.tar.gz [email protected]:/var/www/
mkdir -p /var/mysqlbackup/cms/
root@localhost:/var/www# tar xfvz htdocs.tar.gz
root@localhost:/var/www# mv htdocs html
root@localhost:/var/www# chown -R www-data:www-data html

chmod -R 777 /var/lib/php/sessions

configuration.php

root@localhost:/var/www# mkdir logs
root@localhost:/var/www# chown -R www-data:www-data logs

root@localhost:/var/www/html# vi configuration.php
        public $log_path = '/var/www/logs';
        public $tmp_path = '/var/www/tmp';
        public $force_ssl = '0'; # hot advice from Holger

MySQL database import

root@localhost:/var/mysqlbackup/cms# cat j25svw_*.sql > all.sql

mysql> use cms;
mysql> SET autocommit=0 ;
mysql> source /var/mysqlbackup/cms/all.sql; commit;

	Zeile 1: ERROR 1062 (23000): Duplicate entry 'meldeschluss' for key 'j25svw_finder_terms.idx_term'
	Zeile 2: ERROR 1062 (23000): Duplicate entry 'weiss' for key 'j25svw_finder_terms.idx_term'
	Zeile 6: ERROR 1062 (23000): Duplicate entry '1 wei�' for key 'j25svw_finder_terms.idx_term'
	Zeile 7: ERROR 1062 (23000): Duplicate entry 'der meldeschluss' for key 'j25svw_finder_terms.idx_term'
	Zeile 8: ERROR 1062 (23000): Duplicate entry 'an alexander geilfuss' for key 'j25svw_finder_terms.idx_term'
	Zeile 9: ERROR 1062 (23000): Duplicate entry '3 h�ussler' for key 'j25svw_finder_terms.idx_term'
	Zeile 13: ERROR 1062 (23000): Duplicate entry 'bu�' for key 'j25svw_finder_terms.idx_term'
	Zeile 14: ERROR 1062 (23000): Duplicate entry 'biberach riss' for key 'j25svw_finder_terms.idx_term'
	Zeile 15: ERROR 1062 (23000): Duplicate entry '19 weiss' for key 'j25svw_finder_terms.idx_term'
	Zeile 22: ERROR 1062 (23000): Duplicate entry 'aussenseiter' for key 'j25svw_finder_terms.idx_term'
	Zeile 23: ERROR 1062 (23000): Duplicate entry 'verstoss' for key 'j25svw_finder_terms.idx_term'
	Zeile 24: ERROR 1062 (23000): Duplicate entry 'beratung und beschlu�fassung' for key 'j25svw_finder_terms.idx_term'
	Zeile 25: ERROR 1062 (23000): Duplicate entry 'strauss martin 1' for key 'j25svw_finder_terms.idx_term'
	Zeile 26: ERROR 1062 (23000): Duplicate entry 'mu�te leider' for key 'j25svw_finder_terms.idx_term'
	Zeile 33: ERROR 1062 (23000): Duplicate entry 'hoffen dass' for key 'j25svw_finder_terms.idx_term'
	Zeile 34: ERROR 1062 (23000): Duplicate entry 'ordnungsgem�ss' for key 'j25svw_finder_terms.idx_term'
	Zeile 35: ERROR 1062 (23000): Duplicate entry '6 wei�' for key 'j25svw_finder_terms.idx_term'
	Zeile 36: ERROR 1062 (23000): Duplicate entry 'hinzu dass' for key 'j25svw_finder_terms.idx_term'
	Zeile 37: ERROR 1062 (23000): Duplicate entry 'pa�-nr' for key 'j25svw_finder_terms.idx_term'
	Zeile 38: ERROR 1062 (23000): Duplicate entry 'de anmeldeschluss' for key 'j25svw_finder_terms.idx_term'
	Zeile 39: ERROR 1062 (23000): Duplicate entry 'jakob fessler' for key 'j25svw_finder_terms.idx_term'
	Zeile 40: ERROR 1062 (23000): Duplicate entry 'soda�' for key 'j25svw_finder_terms.idx_term'
	Zeile 41: ERROR 1062 (23000): Duplicate entry 'schlu�bestimmungen' for key 'j25svw_finder_terms.idx_term'
	Zeile 45: ERROR 1062 (23000): Duplicate entry '12 weiss' for key 'j25svw_finder_terms.idx_term'
	Zeile 49: ERROR 1062 (23000): Duplicate entry 'reuss herbert' for key 'j25svw_finder_terms.idx_term'
	Zeile 50: ERROR 1062 (23000): Duplicate entry 'bsl klaus fu�' for key 'j25svw_finder_terms.idx_term'
	Zeile 51: ERROR 1062 (23000): Duplicate entry 'freundlichen schachgr�ssen' for key 'j25svw_finder_terms.idx_term'
	Zeile 52: ERROR 1062 (23000): Duplicate entry 'stoll sc wei�e' for key 'j25svw_finder_terms.idx_term'
	Zeile 56: ERROR 1062 (23000): Duplicate entry 'gru�wort zum' for key 'j25svw_finder_terms.idx_term'
	Zeile 57: ERROR 1062 (23000): Duplicate entry 'und beschlu�fassung �ber' for key 'j25svw_finder_terms.idx_term'
	Zeile 61: ERROR 1062 (23000): Duplicate entry '1 fu�' for key 'j25svw_finder_terms.idx_term'
	Zeile 65: ERROR 1062 (23000): Duplicate entry 'beachten dass jeder' for key 'j25svw_finder_terms.idx_term'
	Zeile 69: ERROR 1062 (23000): Duplicate entry '00 uhr anmeldeschlu�' for key 'j25svw_finder_terms.idx_term'
	Zeile 70: ERROR 1062 (23000): Duplicate entry 'von klaus fuss' for key 'j25svw_finder_terms.idx_term'
	Zeile 74: ERROR 1062 (23000): Duplicate entry 'gro�-sachsenheim 4' for key 'j25svw_finder_terms.idx_term'
	Zeile 75: ERROR 1062 (23000): Duplicate entry '0 1 fu�' for key 'j25svw_finder_terms.idx_term'
	Zeile 76: ERROR 1062 (23000): Duplicate entry 'wem im v�hlinschloss' for key 'j25svw_finder_terms.idx_term'
	Zeile 77: ERROR 1062 (23000): Duplicate entry '8 eissler' for key 'j25svw_finder_terms.idx_term'
	Zeile 81: ERROR 1062 (23000): Duplicate entry 'tromso' for key 'j25svw_finder_terms.idx_term'
	Zeile 82: ERROR 1062 (23000): Duplicate entry 'dre�ler' for key 'j25svw_finder_terms.idx_term'

Create an admin account

INSERT INTO `j25svw_users`
   (`name`, `username`, `password`, `params`, `registerDate`, `lastvisitDate`, `lastResetTime`)
VALUES ('Administrator2', 'admin2',
    'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199', '', NOW(), NOW(), NOW());
INSERT INTO `j25svw_user_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');

login with password secret and change the password for admin2:

http://212.227.75.118/administrator/index.php?option=com_admin&view=profile&layout=edit

Copy Apache conf and ssl certificate and use the same paths

root@localhost:/etc/apache2/sites-available# mv 000-default.conf 000-default.conf.orig_2021-12-30
root@localhost:/etc/apache2/sites-available# mv default-ssl.conf default-ssl.conf.orig_2021-12-30
root@localhost:/etc/apache2/sites-available# scp -p [email protected]:/etc/apache2/sites-available/000-default.conf .
root@localhost:/etc/apache2/sites-available# scp -p [email protected]:/etc/apache2/sites-available/000-default-ssl.conf .
root@localhost:/etc/apache2/sites-enabled# ln -s ../sites-available/000-default-ssl.conf

root@localhost:/etc/apache2# scp -rp [email protected]:/etc/apache2/ssl .

root@localhost:/var/www# mv html htdocs
root@localhost:/var/www# mkdir j25svw
root@localhost:/var/www# mv htdocs logs tmp j25svw/

root@localhost:/var/www/j25svw/htdocs# vi configuration.php
        public $log_path = '/var/www/j25svw/logs';
        public $tmp_path = '/var/www/j25svw/tmp';

sudo a2enmod ssl
#sudo a2enmod suexec
#apt-get install libapache2-mod-ruid2
#apt-get install apache2-suexec-custom
# disable line 'SuexecUserGroup portal webuser' in 000-default.conf and 000-default-ssl.conf

# disable the following lines in 000-default.conf and 000-default-ssl.conf
#Alias /fcgi-bin/php5-fpm /fcgi-bin-php5-fpm-svw-ssl
#FastCgiExternalServer /fcgi-bin-php5-fpm-svw-ssl -socket /var/run/php-fpm-svw-ssl.sock -idle-timeout 6000 -flush -pass-header Authorization
# and replace it with
        <FilesMatch \.php$>
                # 2.4.10+ can proxy to unix socket
                SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost"
        </FilesMatch>

# disable the following lines in 000-default.conf for testing purpose. FIXME: revert this change, if changing dns to new server
#        RewriteCond %{HTTPS} off
#        RewriteRule ^(.*)$ https://www.svw.info$1 [R=301,L]
#    RewriteCond %{REQUEST_URI} !=/server-status
#    RewriteCond %{HTTP_HOST} !^www.svw.info$
#    RewriteRule ^(.*)$ http://www.svw.info$1 [R=301]
systemctl restart apache2

Useful links