1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/my_webapp_ynh.git synced 2024-09-03 19:46:26 +02:00
This commit is contained in:
Éric Gaspar 2023-04-13 11:11:30 +02:00
parent 0244a4408e
commit 47533880be
13 changed files with 66 additions and 66 deletions

View file

@ -0,0 +1,2 @@
# Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file
#client_max_body_size 1G;

10
conf/nginx-php.conf Normal file
View file

@ -0,0 +1,10 @@
# Execute and serve PHP files
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}

View file

@ -4,9 +4,6 @@ location __PATH__/ {
# Path to source # Path to source
alias __INSTALL_DIR__/www/; alias __INSTALL_DIR__/www/;
# Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file
client_max_body_size 500M;
# Default indexes and catch-all # Default indexes and catch-all
index index.html index.php; index index.html index.php;
try_files $uri $uri/ __PATH__/index.php?$args; try_files $uri $uri/ __PATH__/index.php?$args;
@ -28,6 +25,8 @@ location __PATH__/ {
deny all; deny all;
} }
include conf.d/__DOMAIN__.d/__APP__.d/*.conf;
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -1,44 +0,0 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __INSTALL_DIR__/www/;
# Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file
client_max_body_size 500M;
# Default indexes and catch-all
index index.html index.php;
try_files $uri $uri/ __PATH__/index.php?$args;
# Prevent useless logs
location = __PATH__/favicon.ico {
log_not_found off;
access_log off;
}
location = __PATH__/robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny access to hidden files and directories
location ~ ^__PATH__/(.+/|)\.(?!well-known\/) {
deny all;
}
# Execute and serve PHP files
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -5,3 +5,5 @@ It can also create a MySQL database - which will be backed up and restored with
PHP-FPM version can also be selected among `none`, `7.4`, `8.0`, `8.1` and `8.2`. PHP-FPM version can also be selected among `none`, `7.4`, `8.0`, `8.1` and `8.2`.
**Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside. **Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside.
If you want to add customized nginx configuration, put it in `/etc/nginx/conf.d/YOUR_DOMAIN.d/my_webapp.d/WHATEVER_NAME.conf` (ensure that the file has the `.conf` extension, and change `my_webapp.d` to `my_webapp__xx.d` if you want to change the configuration of the second or more installation of my_webapp).

View file

@ -5,3 +5,5 @@ Elle peut également créer une base de données MySQL - qui sera sauvegardée e
La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1` et `8.2`. La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1` et `8.2`.
**Une fois installé, rendez-vous sur l'URL choisie pour connaître l'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP.** Le mot de passe est celui que vous avez choisi lors de l'installation. Sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur. **Une fois installé, rendez-vous sur l'URL choisie pour connaître l'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP.** Le mot de passe est celui que vous avez choisi lors de l'installation. Sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur.
Si vous voulez ajouter une configuration personnalisée de nginx, mettez-la dans `/etc/nginx/conf.d/votre_domaine.d/my_webapp.d/WHATEVER_NAME.conf` (assurez-vous que le fichier a l'extension `.conf`, et changez `my_webapp.d` en `my_webapp__xx.d` si vous voulez changer la configuration de la deuxième installation ou plus de my_webapp).

View file

@ -34,6 +34,7 @@ ynh_backup --src_path="$install_dir"
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION

View file

@ -9,6 +9,21 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=5
# Backup the current version of the app
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.d"
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
@ -25,14 +40,7 @@ ynh_maintenance_mode_ON
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
nginx_extra_conf_dir=/etc/nginx/conf.d/$old_domain.d/$app.d
# Prepare nginx.conf
if [ $phpversion != "none" ]
then
cp ../conf/nginx{_with_php,}.conf
else
cp ../conf/nginx{_no_php,}.conf
fi
# Change the path in the NGINX config file # Change the path in the NGINX config file
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
@ -53,10 +61,19 @@ if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path" ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf"
path_url="$new_path"
domain="$old_domain"
ynh_remove_nginx_config
domain="$new_domain"
ynh_add_nginx_config
mv $nginx_extra_conf_dir /etc/nginx/conf.d/$new_domain.d/$app.d
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/php.conf"
fi fi
#================================================= #=================================================

View file

@ -119,11 +119,14 @@ ynh_app_config_apply() {
# ^ ynh_add_config replaces __PHPVERSION__ by __PHP_YNH_VERSION__... # ^ ynh_add_config replaces __PHPVERSION__ by __PHP_YNH_VERSION__...
ynh_app_setting_set --app=$app --key=phpversion --value="$phpversion" ynh_app_setting_set --app=$app --key=phpversion --value="$phpversion"
nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"
if [ "$phpversion" == "none" ] if [ "$phpversion" == "none" ]
then then
cp ../conf/nginx{_no_php,}.conf ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf"
ynh_secure_remove --file="$nginx_extra_conf_dir/php.conf"
else else
cp ../conf/nginx{_with_php,}.conf ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
ynh_install_app_dependencies "php${phpversion}-fpm" ynh_install_app_dependencies "php${phpversion}-fpm"
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
# ^ the helper takes care of ynh_app_setting_set the phpversion # ^ the helper takes care of ynh_app_setting_set the phpversion

View file

@ -58,17 +58,19 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2 ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Prepare nginx.conf nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"
# Prepare nginx extra conf
if [ $phpversion != "none" ] if [ $phpversion != "none" ]
then then
cp ../conf/nginx{_with_php,}.conf ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$phpversion" YNH_PHP_VERSION="$phpversion"
else
cp ../conf/nginx{_no_php,}.conf
fi fi
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER

View file

@ -39,6 +39,7 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d"
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION

View file

@ -23,6 +23,7 @@ password=$(ynh_app_setting_get --app=$app --key=password)
#================================================= #=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.d/"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE

View file

@ -79,16 +79,20 @@ ynh_maintenance_mode_ON
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Prepare nginx.conf # Prepare nginx.conf
nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"
# Prepare nginx extra conf
if [ $phpversion != "none" ] if [ $phpversion != "none" ]
then then
cp ../conf/nginx{_with_php,}.conf ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$phpversion" YNH_PHP_VERSION="$phpversion"
else
cp ../conf/nginx{_no_php,}.conf
fi fi
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER