Skip to content

kaufmajo/web1

simple-timeline

alt text

Server

Debian Bookworm

Install rsync

$ dpkg -s rsync # check if packet is already installed
$ apt-get install rsync

Install lsb-release

$ dpkg -s lsb-release # check if packet is already installed
$ apt-get install lsb-release

Webserver

Install Apache Webserver

$ apt-get install apache2

Activate Apache Rewrite Module

$ a2enmod rewrite

VHOSTS Example

<VirtualHost *:8888>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName web1.dev.dev

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/web1/public

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf


        <Directory /var/www/web1/public>
                DirectoryIndex index.php
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

Apache (de)activate VHOST

Activate

$ a2ensite 020-web1.conf

Deactivate

$ a2dissite 020-web1.conf 

Activate SSL for website

See instructions on https://letsencrypt.org/de/

Dev WSL Configuration

Don't forget to change listen port on WSL

If dev machine cant listen on port 80, just use another port:

In my case, I use ports from this scope 888x

$ vi /etc/apache2/ports.conf 

Add ...

Listen 80
Listen 8888

Activate German locale on WSL

Check if local is already installed:

$ locale -a

Show all supported locales:

$ less /usr/share/i18n/SUPPORTED

If local is missing, you have to generate it:

$ sudo locale-gen de_CH.UTF-8

PHP

Version: 8.3

Install PHP

$ apt-get install php libapache2-mod-php

Install PHP Modules for Apache

$ apt-get install php8.3-mbstring
$ apt-get install php8.3-curl
$ apt-get install php8.3-mysql
$ apt-get install php8.3-gd
$ apt-get install php8.3-intl
$ apt-get install php8.3-tidy
$ apt-get install php8.3-xml
$ apt-get install php8.3-zip
$ apt-get install php8.3-xdebug # only required on dev server

Update php.ini

php.ini

post_max_size = 50M
upload_max_filesize = 50M
# max_execution_time 300

or you can set these values within the ".htaccess" file, which is located in the "public" folder:

php_value post_max_size 50M
php_value upload_max_filesize 50M
#php_value max_execution_time 300

PHP Versions

If you have to switch your php version:

Show installed versions on OS:

$ sudo update-alternatives --list php

Change default php version on OS:

sudo update-alternatives --config php

Activate and change default php version on Apache:

sudo a2dismod php8.2 
sudo a2enmod php8.3 
sudo service apache2 restart 

Git

Install git on Debian

$ apt install git
$ git config --global user.email "[email protected]"
$ git config --global user.name "Your Name"

Composer

Install composer on Dev

See instructions on https://getcomposer.org/

To update composer:

$ php composer.phar self-update

To update the application:

$ php composer.phar self-update
$ php composer.phar update

Database

$ ./script/sql/database
$ ./script/sql/trigger
$ ./script/sql/proc

Mariadb Version

How to check mariadb version:

$ mariadb -V

Mariadb OS log entries

How to check mariadb OS log entries:

$ journalctl -u mariadb -f

Application

Repository

Clone Repository in current directory

$ git clone https://github.com/kaufmajo/web1.git .

Duplicate config files

Duplicate (don't rename) the *.dist files and adapt the config settings

$ cd /var/www/web1/config
$ cd /var/www/web1/config/autoload

File-Persmission on Dev-Server

https://stackoverflow.com/questions/30639174/how-to-set-up-file-permissions-for-laravel

With Your user as owner

$ cd /var/www/web1/
$ sudo chown -R $USER:www-data .

Then I give both myself and the webserver permissions:

$ sudo find . -type f -exec chmod 664 {} \;   
$ sudo find . -type d -exec chmod 775 {} \;

Set permission for special folders

$ chown www-data /var/www/web1/data/cache -R
$ chown www-data /var/www/web1/data/log -R
$ chown www-data /var/www/web1/data/media -R
$ chown www-data /var/www/web1/data/temp -R

Set execution permission for scripts

$ chmod u+x /var/www/web1/script/sync/stage_to_provider.sh

Password

<?php
/**
 * We just want to hash our password using the current DEFAULT algorithm.
 * This is presently BCRYPT, and will produce a 60 character result.
 *
 * Beware that DEFAULT may change over time, so you would want to prepare
 * By allowing your storage to expand past 60 characters (255 would be good)
 */
$mypassword = password_hash("rasmuslerdorf", PASSWORD_DEFAULT);
?>
INSERT INTO `tajo1_user` (`user_id`, `user_name`, `user_email`, `user_password`, `user_role`) VALUES (2, 'admin', '[email protected]', 'mypassword', 'admin');

Misc

Adapt console prompt

$ cp ~/.bashrc ~/.bashrc.bak
$ vi ~/.bashrc

Example - change line:

PS1='debian_10_dev ${debian_chroot: ...

Tcp Udp ports listening

How to show listening tcp udp ports:

$ ss -tulw | grep LISTEN

Managing remote repositories

https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories

Why is .gitignore not ignoring my files?

The .gitignore file ensures that files not tracked by Git remain untracked.

Just adding folders/files to a .gitignore file will not untrack them -- they will remain tracked by Git.

To untrack files, it is necessary to remove from the repository the tracked files listed in .gitignore file. Then re-add them and commit your changes.

The easiest, most thorough way to do this is to remove and cache all files in the repository, then add them all back. All folders/files listed in .gitignore file will not be tracked. From the top folder in the repository run the following commands:

$ git rm -r --cached .
$ git add .

Then commit your changes:

$ git commit -m "Untrack files in .gitignore"

AuthUserFile für .htaccess Auth-Configuration

Auth type = "Basic Auth"

$ cd /srv/scripts/apache/passwd/basic

Example

soapme:$xxx1$xxxx.xxx$xxx

.htaccess example
AuthType basic
AuthName "Authentication Required"
AuthBasicProvider file
AuthUserFile /srv/scripts/apache/passwd/basic
Order deny,allow
Deny from all
Satisfy All
Options -Indexes

Secure copy Example (scp)

If it is a shell script, there is normally no need to configure the permission again

$ scp -r root@server:/var/www/web1/data/media/* /var/www/web1/data/media/
$ scp -r user1@server:/var/www/web1/data/* /var/www/web1/data/
$ scp user1@server:/var/www/web1/config/autoload/production.local.php /var/www/web1/config/autoload/production.local.php

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published