Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
deb13:apache [2026/05/18 15:49] – [PHP Installation] Bernard Condraudeb13:apache [2026/11/15 09:03] (current) – [PHP Extensions] Bernard Condrau
Line 1: Line 1:
-====== Apache 2.4 and PHP 8 ======+====== Apache 2.4 and PHP 8.4 ====== 
 +add the following:<code>RequestHeader set X-Forwarded-Proto "https" env=HTTPS 
 +SetEnvIfNoCase X-Forwarded-Proto https HTTPS=on</code>
 ===== Apache 2.4 Installation ===== ===== Apache 2.4 Installation =====
   - Install apache 2.4<code>$ sudo apt update   - Install apache 2.4<code>$ sudo apt update
Line 9: Line 11:
   - Install and configure [[deb11:certbot|Let's Encrypt Certbot]]   - Install and configure [[deb11:certbot|Let's Encrypt Certbot]]
   - If you are migrating from an old server, follow the [[deb11:migrate#apache_2.4|How to migrate a (web) server]] guide   - If you are migrating from an old server, follow the [[deb11:migrate#apache_2.4|How to migrate a (web) server]] guide
 +  - Run ''apachectl configtest'' before reloading apache
  
 ===== Apache Settings ===== ===== Apache Settings =====
 +==== Basic configuration for your web root ====
 +  * Add your custom configuration file ''/etc/apache2/conf-available/my-webspace'':<code># grant access to bco's web space
 +# * this is a proxied server, check access rules on proxy
 +# * black list is created by bethico.com
 +# (c) bco, 2021-09-26
 +<Directory /home/bco/www/>
 + Options -Indexes +FollowSymLinks
 + AllowOverride None
 +
 + <RequireAll>
 +
 + # allow access
 + Require all granted
 +
 + # block ip addresses
 + Include /home/bco/www/ipblacklist.conf
 + </RequireAll>
 +
 + # block spiders
 + Include conf-available/bco-spiders.conf
 +</Directory>
 +
 +ErrorDocument 403 "<h1>Unusual activity has been detected from this IP address.</h1><p>You don't have permission to access this resource.<br>If you belive this is a mistake please <a href='https://www.condrau.com'>contact me</a>.</p>"
 +</code>
 +  * Enable the configuration:<code>sudo a2enconf my-webspace</code>
 +  * Check the configuration and fix errors if you have any:<code>sudo apache2ctl configtest</code>
 +  * Restart the web server:<code>sudo systemctl restart apache2</code>
  
 ==== Harden apache ==== ==== Harden apache ====
Line 27: Line 57:
  
 ===== PHP Installation ===== ===== PHP Installation =====
-  - Install packages<code>$ sudo apt update +  - Download the GPG key:<code>$ sudo apt update 
-$ sudo apt install -y curl wget gnupg2 ca-certificates lsb-release apt-transport-https software-properties-common</code> +$ sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg</code> 
-  - Download the GPG key:<code>curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg</code>+  - Add the repository to your sources<code>$ echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list</code> 
 +  - Install the desired PHP version, where V is the major and v is the minor version number, for example 8.4<code>$ sudo apt update 
 +$ sudo apt install php8.4</code>
  
-  - Add the SURY repository to your system<code>$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list</code> 
-  - Import the repository key<code>$ wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -</code> 
-  - Install the desired PHP version, where V is the major and v is the minor version number, for example 7.4 or 8.1<code>$ sudo apt update 
-$ sudo apt install phpV.v</code> 
   - Enable modules:<code>$ sudo a2enmod ssl   - Enable modules:<code>$ sudo a2enmod ssl
 $ sudo a2enmod proxy $ sudo a2enmod proxy
Line 46: Line 74:
  
 ===== PHP Extensions ===== ===== PHP Extensions =====
-  * PHP extensions for Joomla:<code>$ sudo apt install phpV.v-{bz2 curl gd mbstring mysql xml zip} phpV.v-{bcmath}</code> +  * PHP extensions for Joomla:<code>$ sudo apt install php- or phpV.v-{bz2 curl gd mbstring mysql xml zip} phpV.v-{bcmath intl}</code> 
-  * PHP extensions for Wiki:<code>$ sudo apt install phpV.v-{bz2 curl gd mbstring mysql xml zip} phpV.v-{sqlite3}</code> +  * PHP extensions for Wiki:<code>$ sudo apt install php- or phpV.v-{bz2 curl gd mbstring mysql xml zip json curl} phpV.v-{sqlite3}</code> 
-  * PHP extensions for phpMyAdmin:<code>$ sudo apt install phpV.v-mbstring</code> +  * PHP extensions for phpMyAdmin:<code>$ sudo apt install php- or phpV.v-{mbstring json curl}</code> 
-  * PHP extensions for vps:<code>$ sudo apt install phpV.v-{curl xml zip}</code> +  * PHP extensions for vps:<code>$ sudo apt install php- or phpV.v-{curl xml zip}</code> 
-  * Required for PHP7:<code>$ sudo apt install phpV.v-json</code> +  * Restart the service:<code>$ sudo systemctl restart apache2</code>
-  * Restart the service with one of the 2 commands below:<code>$ sudo systemctl restart apache2 +
-$ sudo service apache2 restart</code>+
  
 ===== Set or change PHP version ===== ===== Set or change PHP version =====
Line 67: Line 93:
   * [[https://tecadmin.net/switch-between-multiple-php-version-on-debian/|How to Switch between Multiple PHP Version on Debian 9]]   * [[https://tecadmin.net/switch-between-multiple-php-version-on-debian/|How to Switch between Multiple PHP Version on Debian 9]]
  
 +===== Upgrade Sury certificates =====
 +  * If the keyring file was installed via older legacy instructions:<code>sudo rm -f /etc/apt/trusted.gpg.d/php.gpg
 +sudo rm -f /etc/apt/sources.list.d/php.list</code>
 +  * Refresh your package manager:<code>sudo apt update</code>
 +  * Update to the fresh key:<code>curl -sS https://packages.sury.org/php/apt.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/sury-keyring.gpg >/dev/null</code>
 +  * Create the apt list file (debian 11=bullseye, 12=bookworm, 13=trixie):<code>echo "deb [signed-by=/usr/share/keyrings/sury-keyring.gpg] https://packages.sury.org/php/ <bullseye|bookworm|trixie> main" | sudo tee /etc/apt/sources.list.d/php.list</code>
 ===== PHP Settings ===== ===== PHP Settings =====
  
Line 74: Line 106:
  
 ==== php.ini ==== ==== php.ini ====
-  * <code>max_execution_time = 120+  * <code>max_execution_time = 300
 max_input_vars = 2000 max_input_vars = 2000
 memory_limit = 512M memory_limit = 512M