# Installer Apache/PHP via opkg (Entware)



### Apache

```

```

#### Configuration:

```bash
sudo nano /opt/etc/apache2/apache2.conf
```

```http
Listen 81

User http
Group http

ServerName clicclac.synology.me:81

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
<VirtualHost *:*>
   ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9000/opt/homebrew/local/var/www/$1"
</VirtualHost>
<FilesMatch \.php$>
    # 2.4.10+ can proxy to unix socket
    # SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
    # Else we can just use a tcp socket:
    SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>


DocumentRoot "/opt/share/apache2/htdocs"
```

```bash
sudo /opt/etc/init.d/S80apache restart
```

#### Liste des modules:

```bash
apachectl -M
```



### PHP

#### Installer PHP 8.2:

```bash
sudo opkg install php8 php8-cgi php8-cli php8-fastcgi
```

```bash
/opt/etc $ cd init.d/
total 16
drwxr-xr-x 1 root root   74 May 29 07:40 .
drwxr-xr-x 1 root root  390 Feb 27 08:44 ..
-rw-r--r-- 1 root root 2822 Apr 19  2021 rc.func
-rwxr-xr-x 1 root root  966 Apr 19  2021 rc.unslung
-rwxr-xr-x 1 root root  241 Feb 27 08:44 S79php8-fpm
lrwxrwxrwx 1 root root   19 May 29 07:40 S80apache -> /opt/sbin/apachectl
```

#### Installer des modules PHP:

```bash
sudo opkg install php8-mod-bcmath php8-mod-ctype php8-mod-curl php8-mod-dom php8-mod-exif php8-mod-fileinfo php8-mod-filter php8-mod-ftp php8-mod-gd php8-mod-gettext php8-mod-gmp php8-mod-iconv php8-mod-imap php8-mod-intl
icu-full-data php8-mod-mbstring php8-mod-mysqli php8-mod-mysqlnd php8-mod-opcache php8-mod-openssl php8-mod-pcntl php8-mod-pdo php8-mod-pdo-mysql php8-mod-pdo-sqlite php8-mod-phar php8-mod-session php8-mod-sysvsem php8-mod-tokenizer php8-mod-xml php8-mod-xmlwriter php8-mod-zip php8-pecl-imagick php8-pecl-redis

```

#### PHP via opkg:

```bash
/opt/bin
-rwxr-xr-x 1 root root 4322256 Feb 27 08:44 php8-cgi
-rwxr-xr-x 1 root root 4392192 Feb 27 08:44 php8-cli
lrwxrwxrwx 1 root root       8 May 29 09:50 php8-fcgi -> php8-cgi
-rwxr-xr-x 1 root root 4439296 Feb 27 08:44 php8-fpm
lrwxrwxrwx 1 root root       8 May 29 09:50 php-cgi -> php8-cgi
lrwxrwxrwx 1 root root       8 May 29 08:05 php-cli -> php8-cli
lrwxrwxrwx 1 root root       9 May 29 09:50 php-fcgi -> php8-fcgi
```

#### Paquet Synology PHP:

```bash
/usr/local/bin
lrwxrwxrwx  1 root root      47 May 28 09:22 php80 -> /var/packages/PHP8.0/target/usr/local/bin/php80
lrwxrwxrwx  1 root root      51 May 28 09:22 php80-cgi -> /var/packages/PHP8.0/target/usr/local/bin/php80-cgi
lrwxrwxrwx  1 root root      51 May 28 09:22 php80-fpm -> /var/packages/PHP8.0/target/usr/local/bin/php80-fpm
```



#### Démarrer PHP

```bash
bruno@DS916:/opt/etc/init.d $ ./S79php8-fpm start
 Starting php8-fpm...              done.
```

#### Statut de PHP

```bash
bruno@DS916:/opt/etc/init.d $ ./S79php8-fpm status
 Usage: ./S79php8-fpm (start|stop|restart|check|kill|reconfigure)
```

#### Configuration:

```bash
sudo nano /opt/etc/php.ini
```

```ini
post_max_size = 500M
display_errors = Off
error_log = /opt/var/log/php_errors.log
output_buffering = Off

; Resource Limits

max_execution_time = 30 ; Maximum execution time of each script, in seconds.
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data.
;max_input_nesting_level = 64
memory_limit = 32M ; Maximum amount of memory a script may consume.

; Paths and Directories

;doc_root = "/opt/share/www/lighttpd"
;user_dir =
extension_dir = "/opt/lib/php"
enable_dl = On
;cgi.force_redirect = 1
;cgi.nph = 1
;cgi.redirect_status_env = ;
cgi.fix_pathinfo=1

; File Uploads

file_uploads = O
upload_tmp_dir = "/opt/tmp"
upload_max_filesize = 500M
max_file_uploads = 50
```



#### Apache:

```bash
/opt/lib/apache2/libphp.so
```

