FreeBSD : Installation de Apache, PHP et MySQL

Installation de Apache, PHP et MySQL.

Lien : https://linuxhint.com/install-apache-php-mysql-on-freebsd/

1/ Installation de Apache.

  • Installation :
root@station66:~ # pkg install -y apache24
...
New packages to be INSTALLED:
    apache24: 2.4.48
...
  • Activation :
root@station66:~ # sudo sysrc apache24_enable=yes
apache24_enable:  -> yes
  • Démarrage :
root@station66:~ # service apache24 start
...
Starting apache24.
...
  • Etat :
root@station66:~ # service apache24 status
apache24 is running as pid 69214.

2/ Installation de MySQL.

  • Installation :
root@station66:~ # pkg install -y mysql80-client mysql80-server
...
    mysql80-client: 8.0.25_1
    mysql80-server: 8.0.25_1
...
  • Version :
root@station66:~ # mysql --version
mysql  Ver 8.0.25 for FreeBSD13.0 on amd64 (Source distribution)
  • Activation :
root@station66:~ # sysrc mysql_enable=yes
mysql_enable:  -> yes
  • Démarrage :
root@station66:~ # service mysql-server start
Starting mysql. 
  • Etat :
root@station66:~ # service mysql-server status
mysql is running as pid 70587.
  • Sécurisation :
root@station66:~ # mysql_secure_installation

3/ Installation de PHP.

  • Installation :
root@station66:~ # pkg install -y php74 php74-mysqli mod_php74
  • Version :
root@station66:~ # php --version
PHP 7.4.22 (cli) (built: Aug  1 2021 01:13:47) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
  • Configuration :
root@station66:~ # cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
  • Activation :
root@station66:~ # sysrc php_fpm_enable=yes
php_fpm_enable:  -> yes
  • Démarrage :
root@station66:~ # service php-fpm start
Performing sanity check on php-fpm configuration:
[05-Aug-2021 20:18:49] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful

Starting php_fpm.
  • Etat :
root@station66:~ # service php-fpm status
php_fpm is running as pid 70669.

4/ Configuration de PHP pour Apache.

  • Configuration :

Ouvrir :

/usr/local/etc/apache24/modules.d/001_mod-php.conf

Ajouter :

<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>
  • Test :
root@station66:~ # apachectl configtest
Performing sanity check on apache24 configuration:
AH00557: httpd: apr_sockaddr_info_get() failed for station66.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
  • Démarrage :
root@station66:~ # apachectl restart
Performing sanity check on apache24 configuration:
AH00557: httpd: apr_sockaddr_info_get() failed for station66.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
Stopping apache24.
Waiting for PIDS: 69214.
Performing sanity check on apache24 configuration:
AH00557: httpd: apr_sockaddr_info_get() failed for station66.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
Starting apache24.
AH00557: httpd: apr_sockaddr_info_get() failed for station66.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

5/ Test.

  • Fichier de test :

Ouvrir :

/usr/local/www/apache24/data/info.php

Ajouter :

<?php phpinfo(); ?>
  • Test :
$ links 127.0.0.1/info.php