Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgaspar committed Apr 13, 2023
1 parent 0244a44 commit 4753388
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 66 deletions.
2 changes: 2 additions & 0 deletions conf/example-custom-nginx-config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file
#client_max_body_size 1G;
10 changes: 10 additions & 0 deletions conf/nginx-php.conf
Original file line number Diff line number Diff line change
@@ -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;
}
5 changes: 2 additions & 3 deletions conf/nginx_no_php.conf → conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ 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;
Expand All @@ -28,6 +25,8 @@ location __PATH__/ {
deny all;
}

include conf.d/__DOMAIN__.d/__APP__.d/*.conf;

# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
44 changes: 0 additions & 44 deletions conf/nginx_with_php.conf

This file was deleted.

2 changes: 2 additions & 0 deletions doc/DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

**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).
2 changes: 2 additions & 0 deletions doc/DESCRIPTION_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

**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).
1 change: 1 addition & 0 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -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.d"

#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
Expand Down
37 changes: 27 additions & 10 deletions scripts/change_url
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
source _common.sh
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
#=================================================
Expand All @@ -25,14 +40,7 @@ ynh_maintenance_mode_ON
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2

nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf

# Prepare nginx.conf
if [ $phpversion != "none" ]
then
cp ../conf/nginx{_with_php,}.conf
else
cp ../conf/nginx{_no_php,}.conf
fi
nginx_extra_conf_dir=/etc/nginx/conf.d/$old_domain.d/$app.d

# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
Expand All @@ -53,10 +61,19 @@ if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
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
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

#=================================================
Expand Down
7 changes: 5 additions & 2 deletions scripts/config
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ ynh_app_config_apply() {
# ^ ynh_add_config replaces __PHPVERSION__ by __PHP_YNH_VERSION__...
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" ]
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
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_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
# ^ the helper takes care of ynh_app_setting_set the phpversion
Expand Down
10 changes: 6 additions & 4 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ fi
#=================================================
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" ]
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"
else
cp ../conf/nginx{_no_php,}.conf
fi

# Create a dedicated 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
Expand Down
1 change: 1 addition & 0 deletions scripts/remove
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --

# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d"

#=================================================
# REMOVE PHP-FPM CONFIGURATION
Expand Down
1 change: 1 addition & 0 deletions scripts/restore
Original file line number Diff line number Diff line change
Expand Up @@ -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.d/"

#=================================================
# RESTORE THE MYSQL DATABASE
Expand Down
10 changes: 7 additions & 3 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,20 @@ ynh_maintenance_mode_ON
ynh_script_progression --message="Upgrading NGINX web server configuration..." --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" ]
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"
else
cp ../conf/nginx{_no_php,}.conf
fi

# Create a dedicated 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
Expand Down

0 comments on commit 4753388

Please sign in to comment.