Difference between revisions of "FreeBSD Installation"

From Joomla! Documentation

(updated PHP version references to 8.1)
 
(198 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Tutorials]]
+
<noinclude><languages /></noinclude>
[[Category:Installation]]
+
<translate>This article is a guide detailing how to install Joomla! Content Management System on a FreeBSD based system.<br />
Tested and found to work on FreeBSD 9.0 and Joomla! 2.5.8
+
This guide details installation of the following application versions of the FAMP stack:<br />
==Pre-requisites==
+
<br />
:*Computer running FreeBSD.
+
FreeBSD 13.1<br />
:*Ports directory downloaded from CVSUP or Portsnap.
+
Apache 2.4<br />
:*Knowledge on installing ports.
+
MySQL 8.0<br />
:*Desktop Environment installed.
+
PHP 8.1<br />
:*Logged on to your DE as regular user.
+
Joomla! 3.9.x<br />
 +
<br />
 +
NOTE: Intended as a quick-start installation guide, this article does not address optimal [[S:Mylanguage/Security_Checklist|security settings]], performance tuning, etc.<br />
 +
<br />
 +
==Preparations== <!--T:53-->
  
==Notes==
+
<!--T:54-->
:*This is just a quickstart guide; it does not deal with security settings, performance tuning, etc and therefore should not be used to set up a production server.
+
Open a terminal and log on to the FreeBSD system as root.
:*This will be a local install.
 
:*You MUST install via the ports because several packages lack vital settings.
 
  
==Preperations==
+
<!--T:55-->
Open a terminal and log on as root.
+
If you will be installing the required ports using <code>pkg</code> then skip to the next section to begin the installation.
  
==Installing Apache Server==
+
<!--T:56-->
:Execute the following commands to install your webserver.
+
If you intend to compile the ports from sources then ensure the file <code>/etc/make.conf</code> exists and contains DEFAULT_VERSIONS that reflect the versions you intend to install on the system.<br />
:<code>cd /usr/ports/www/apache22<code>
+
<source lang="php">
:<code>make config</code>
+
DEFAULT_VERSIONS+= php=8.1 python=3.9 python3=3.9 perl5=5.32 mysql=8.0</source>
:Make any configuration changes you need to here. You need to enable MYSQL.
+
<br />
:<code>make install clean</code>
 
:Other options dialogs may pop up, make changes as you need. In most cases the defaults are just fine.
 
  
When done, add the following line to /etc/rc.conf
+
==Installing Apache Web Server== <!--T:57-->  
:<code>apache22_enable="YES"</code>
 
And add the next line to /boot/loader.conf (if the file doesn't exist, create it)
 
:<code>accf_http_load="YES"</code>
 
  
Next you need to modify your hosts file to reflect the hostname for your box. To find out the current hostname you can either read /etc/rc.conf and look for a line called hostname, or you can issue the command <code>hostname</code>.
+
<!--T:58-->
NOTE: the hostname MUST be a fully qualified name, e.g.
+
Execute the following command to install apache24 as your webserver.<br />
:joomla-server1 is NOT OK <----- change it
+
<code>pkg install apache24</code> or<br />
:joomla-server1.free.bsd is OK <---- leave it
+
<code>make -C /usr/ports/www/apache24/ install clean -DBATCH</code>
  
Open /etc/hosts with the editor and change the lines starting with ::1 and 127.0.0.1 so that they become
+
<!--T:59-->
:<code>::1              joomla-server1.free.bsd localhost</code>
+
Add the following lines to <code>/etc/rc.conf</code>:
:<code>127.0.0.1        joomla-server1.free.bsd localhost</code>
+
<source lang="php">
 +
apache24_enable="YES"
 +
apache24_http_accept_enable="YES"</source>
  
If you had to modify the hostname in /etc/rc.conf, you MUST reboot now. Otherwise you may start the apache server by issuing the following commands
+
<!--T:60-->
:<code>kldload accf_http</code>
+
Start the apache server.<br />
:<code>/usr/local/sbin/apachectl start</code>
+
<code>service apache24 start</code><br />
 +
<br />
  
==Installing PHP==
+
== Installing PHP== <!--T:61-->  
:The following commands will install PHP5 to your computer.
 
:<code>cd /usr/ports/lang/php5</code>
 
:<code>make config</code>
 
:Make any configuration changes you need here, You must enable APACHE
 
:<code>make install clean</code>
 
  
When done, open /usr/local/etc/apache22/httpd.conf in a text editor and locate a line called <IfModule mime_module>. Then add the following lines (anywhere you like, yet above the first </IfModule>)
+
<!--T:62-->
:<code>AddType application/x-httpd-php .php</code>
+
The following commands will install PHP 8.0 to your system.<br />
:<code>AddType application/x-httpd-php-source .phps</code>
+
<code>pkg install php81</code> or<br />
 +
<code>make -C /usr/ports/lang/php81 install clean -DBATCH</code><br />
  
Locate a line called "DirectoryIndex index.html" and change it so that it becomes
+
<!--T:63-->
:<code>DirectoryIndex index.php index.html</code>
+
Also install Apache PHP module mod_php81.<br />
 +
<code>pkg install mod_php81</code> or<br />
 +
<code>make -C /usr/ports/lang/php81 install clean -DBATCH</code><br />
  
==Installing Required PHP Extensions==
+
<!--T:64-->
:Execute the following commands to install the required php extensions listed below.
+
As instructed by the post-install message, add the following lines to <code>/usr/local/etc/apache24/httpd.conf</code>:<br />
:<code>cd /usr/ports/lang/php5-extensions</code>
+
<source lang="php">
:<code>make config</code>
+
<FilesMatch "\.php$">
In the options dialog make sure at least the following options are selected (as for the other options that are preselected, either leave them or turn them off, as desired).
+
    SetHandler application/x-httpd-php
:*JSON
+
</FilesMatch>
:*MYSQL
+
<FilesMatch "\.phps$">
:*SESSION
+
    SetHandler application/x-httpd-php-source
:*SIMPLEXML
+
</FilesMatch></source>
:*XML
+
Also modify the following line:<br/>
:*ZLIB
+
<source lang="php">
:Then install the extensions.
+
DirectoryIndex index.html</source>
:<code>make install clean</code>
+
changing it to:<br />
 +
<source lang="php">
 +
DirectoryIndex index.php index.html</source>
 +
<br />
  
==Installing MYSQL==
+
==Installing Required PHP Extensions== <!--T:65-->  
:Execute the following commands to install your MYSQL server.
 
:<code>cd /usr/ports/databases/mysql55-server</code>
 
:<code>make install clean</code>
 
:<code>cd /usr/ports/databases/mysql55-client</code>
 
:<code>make install clean</code>
 
The installation will fail if MYSQL is already installed (perhaps as a dependency). In this case uninstall and then reinstall MYSQL (both server and client).
 
:<code>make deinstall</code>
 
:<code>make reinstall clean</code>
 
  
:Add the following line to /etc/rc.conf
+
<!--T:66-->
:<code>mysql_enable="YES"</code>
+
Joomla requires the following PHP extensions:
:Start the server now by issuing this command
 
:<code>/usr/local/etc/rc.d/mysql-server onestart</code>
 
  
==Configuring PHP==
+
<!--T:67-->
:By default php does not create your php.ini for you, but it does give you examples
+
*CURL
:We will use these examples to create your php.ini
+
*FILTER
:Execute the following commands to create your php.ini
+
*MYSQLI
:<code>cd /usr/local/etc/</code>
+
*SESSION
:During the install we will use the development example
+
*SIMPLEXML
:<code>cp php.ini-development php.ini</code>
+
*XML
:This creates a stock php.ini file, open it in your favorite text editor and modify it to your needs
+
*XMLREADER
:Once you are done with this you can go to your website and install joomla
+
*ZIP
 +
*ZLIB
  
==Installation of Joomla!==
+
<!--T:68-->
:Copy the install file the the root directory of apache and unzip
+
To install the required extensions via pkg:<br />
:<code>cp Joomla_*.zip /usr/local/www/apache22/data</code>
+
<code>pkg install php81-curl php81-filter php81-mysqli php81-session php81-simplexml php81-xml php81-xmlreader php81-zip php81-zlib</code><br />
:<code>cd /usr/local/www/apache22/data</code>
 
:<code>unzip Joomla_*.zip</code>
 
:<code>chown -R www ../data</code>
 
  
The final step changes ownership of the data directory and everything in it to 'www' (i.e. apache) thus allowing the Joomla! configuration script to write into this directory.
+
<!--T:69-->
 +
To simplify installation from sources, the php81-extensions meta-port can be used:<br />
 +
<code>make -C /usr/ports/lang/php81-extensions/ config</code><br />
 +
select the required extensions and deselect all others then:<br />
 +
<code>make -C /usr/ports/lang/php81-extensions/ install clean -DBATCH</code><br />
  
At this point you should be able to configure Joomla! by pointing your browser of choice to http://localhost
+
<!--T:70-->
 +
Optimally to configure the php81-mysqli extension to use MySQL 8.0 server's default authentication mechanism <caching_sha2_password> instead of the php81-mysqli package default <mysql_native_password> authentication:<br />
 +
<code>make -C /usr/ports/databases/php81-mysqli/ config</code><br />
 +
deselect 'Use MySQL Native Driver'<br /><br />
 +
NOTE: When configured this way, the php81-mysqli port will depend on mysql80-client, which will also be installed. Significant compilation time can optionally be saved by first installing mysql80-client via pkg prior to compiling php81-mysqli:<br /><code>pkg install mysql80-client</code><br /><br />
 +
Compile and reinstall php81-mysqli:<br />
 +
<code>make -C /usr/ports/databases/php81-mysqli/ <b>reinstall</b> clean -DBATCH</code><br />
  
Read the Joomla! installation screens carefully!! (And refer to the following)
+
==Configuring PHP== <!--T:71-->
  
At the step '''Database''', enter this
+
<!--T:72-->
:Username = root
+
Create a new php.ini file by copying one of the sample files.<br />
:Password = <leave empty>
+
<code>cd /usr/local/etc/</code><br />
:Database name = <can be anything you like, but not empty>
+
<code>cp php.ini-production php.ini</code><br />
As for the other settings, the defaults are acceptable.
 
  
At step '''Configuration''' don't forget to hit the button 'Install Sample Data'
+
<!--T:73-->
 +
Open and edit <code>/usr/local/etc/php.ini</code> and adjust the following values:
  
When you have removed the installation folder close the browser.
+
<!--T:74-->
 +
<source lang="php">output_buffering = Off
 +
post_max_size = 20M
 +
upload_tmp_dir = /usr/local/www/apache24/data/tmp/
 +
upload_max_filesize = 20M</source>
  
:Finally you should delete the zip-file and take back ownership of the data directory
+
<!--T:75-->
:<code>rm Joomla_*.zip</code>
+
After installing and configuring PHP restart the Apache service.<br />
:<code>chown -R root ../data</code>
+
<code>service apache24 restart</code><br />
 +
<br />
  
==Post Joomla! Installation PHP Configuration==
+
==Installing MySQL Database Server== <!--T:76-->  
:Now you will want to change your php.ini to the production one so run the following commands
 
:<code>cd /usr/local/etc/</code>
 
:<code>mv php.ini php.ini-Dev-Configured</code>
 
:We name it php.ini-Dev-Configured you can use it again later without re-configuring it
 
:<code>cp php.ini-production php.ini</code>
 
:Now the poduction php.ini is installed so you need to configure it with your favorite text editor and you are done!
 
  
Again open your browser and point it to http://localhost. You should now see the default Joomla! development site.
+
<!--T:77-->
 +
Execute the following commands to install MySQL 8.0 server.<br />
 +
<code>pkg install mysql80-server</code> or<br />
 +
<code>make -C /usr/ports/databases/mysql80-server/ install clean -DBATCH</code><br />
 +
<br />
  
==Troubleshooting==
+
<!--T:78-->
Most of the time problems arise from stale cookies and cached content. So delete your cookies and clean your cache. Otherwise,
+
Add the following line to <code>/etc/rc.conf</code>:<br />
:restart the apache server
+
<source lang="php">mysql_enable="YES"</source>
:<code>/usr/local/sbin/apachectl restart</code>
+
 
:restart the mysql server
+
<!--T:79-->
:<code>/usr/local/etc/rc.d/mysql-server restart</code>
+
NOTE: MySQL 8 server initially defaults to creating users using <caching_sha2_password> authentication.
 +
Joomla will connect to it's database using a user with a <caching_sha2_password> if the php81-mysqli extension is configured and compiled from source. More details provided in previous section: [[FreeBSD_Installation#Installing_Required_PHP_Extensions|Installing Required PHP Extensions]].
 +
 
 +
<!--T:80-->
 +
If you prefer to use <mysql_native_password> authentication,<br />edit <code>/usr/local/etc/mysql/my.cnf</code> and add the following line to the <code>[mysqld]</code> section:<br />
 +
<source lang="php">
 +
default_authentication_plugin  = mysql_native_password</source>
 +
Start the MySQL server.<br />
 +
<code>service mysql-server start</code><br />
 +
<br />
 +
Upon initial installation, the MySQL 8.0 server's root user has no password.<br />
 +
<br />
 +
Login to the mysql server on the command line as root and set your desired password.<br />
 +
<code>mysql -u root</code><br />
 +
root@localhost [(none)]><code>ALTER USER 'root'@'%' IDENTIFIED BY 'password';</code><br />
 +
<br />
 +
Create a database for the Joomla web site with your preferred database name.<br />
 +
root@localhost [(none)]><code>create database joomla;</code><br />
 +
<br />
 +
Create a dedicated MySQL user with your preferred username and password.<br />
 +
root@localhost [(none)]><code>create user 'joomla'@'%' identified by 'password';</code><br />
 +
<br />
 +
Grant the user all privileges to the Joomla database.<br />
 +
root@localhost [(none)]><code>grant all privileges on joomla.* to 'joomla'@'%';</code><br />
 +
root@localhost [(none)]><code>flush privileges;</code><br />
 +
<br />
 +
<code>exit</code> to close the connection to MySQL server.<br />
 +
<br />
 +
 
 +
==Installing Joomla! CMS== <!--T:81-->
 +
 
 +
<!--T:82-->
 +
Download the [https://downloads.joomla.org/latest Joomla installation package] ending with .zip<br />
 +
Unzip the file to apache's data directory.<br />
 +
<code>unzip Joomla_*.zip -d /usr/local/www/apache24/data/</code><br />
 +
 
 +
<!--T:83-->
 +
Change ownership of the data directory and everything in it to 'www' thus allowing the Joomla! configuration script to write into this directory.<br />
 +
<code>chown -R www /usr/local/www/apache24/data/</code><br />
 +
 
 +
<!--T:84-->
 +
At this point you should be able to begin installing and configuring Joomla!<br />
 +
 
 +
<!--T:85-->
 +
Open and direct your web browser to one of the following...<br />
 +
If browsing directly on the server: http://localhost<br />
 +
If browsing from a remote system: <nowiki>http://<ip_address></nowiki> or <nowiki>http://<fully.qualified.domain.name></nowiki> (if configured)<br />
 +
 
 +
<!--T:86-->
 +
You will see the Joomla Web Installer page.<br />
 +
 
 +
 
 +
<!--T:87-->
 +
In step 1 Configuration: <br />
 +
fill in the fields as required.<br />
 +
 
 +
 
 +
<!--T:88-->
 +
In step 2 Database: <br />
 +
Username: <joomlauser><br />
 +
Password: <joomlauser password><br />
 +
Database name: <joomladb><br />
 +
 
 +
 
 +
<!--T:89-->
 +
Leave the other settings unchanged:<br />
 +
Database Type: MySQLi<br />
 +
Hostname: localhost<br />
 +
Table Prefix: unchanged<br />
 +
 
 +
 
 +
<!--T:90-->
 +
The final step of the web installer will be to delete the installation folder. <br />
 +
Once that is done you can browse to your newly installed Joomla! web site!<br />
 +
<br />
 +
 
 +
==Post Installation== <!--T:91-->
 +
 
 +
<!--T:92-->
 +
Research how to optimally configure and harden the security of your Joomla! FAMP web server!<br />
 +
<br />
 +
 
 +
==Troubleshooting== <!--T:93-->
 +
 
 +
<!--T:94-->
 +
Configuration '''changes''' made to either apache's '''httpd.conf''' or PHP's '''php.ini''' will require that the apache service be restarted for the changes to take effect.<br />
 +
<code>service apache24 restart</code><br />
 +
 
 +
 
 +
<!--T:95-->
 +
Apache's error log is located at <code>/var/log/httpd-error.log</code><br />
 +
MySQL log files are located in <code>/var/db/mysql/</code> and are named <code><hostname>.err</code> and <code><hostname>-slow.log</code> by default.<br />
 +
MySQL databases are also located in <code>/var/db/mysql/</code><br />
 +
</translate>
 +
 
 +
<noinclude>
 +
[[Category:Tutorials{{#translation:}}]]
 +
[[Category:Installation{{#translation:}}]]
 +
</noinclude>

Latest revision as of 20:45, 17 February 2023

Other languages:
Deutsch • ‎English • ‎français

This article is a guide detailing how to install Joomla! Content Management System on a FreeBSD based system.
This guide details installation of the following application versions of the FAMP stack:

FreeBSD 13.1
Apache 2.4
MySQL 8.0
PHP 8.1
Joomla! 3.9.x

NOTE: Intended as a quick-start installation guide, this article does not address optimal security settings, performance tuning, etc.

Preparations[edit]

Open a terminal and log on to the FreeBSD system as root.

If you will be installing the required ports using pkg then skip to the next section to begin the installation.

If you intend to compile the ports from sources then ensure the file /etc/make.conf exists and contains DEFAULT_VERSIONS that reflect the versions you intend to install on the system.

DEFAULT_VERSIONS+= php=8.1 python=3.9 python3=3.9 perl5=5.32 mysql=8.0


Installing Apache Web Server[edit]

Execute the following command to install apache24 as your webserver.
pkg install apache24 or
make -C /usr/ports/www/apache24/ install clean -DBATCH

Add the following lines to /etc/rc.conf:

apache24_enable="YES"
apache24_http_accept_enable="YES"

Start the apache server.
service apache24 start

Installing PHP[edit]

The following commands will install PHP 8.0 to your system.
pkg install php81 or
make -C /usr/ports/lang/php81 install clean -DBATCH

Also install Apache PHP module mod_php81.
pkg install mod_php81 or
make -C /usr/ports/lang/php81 install clean -DBATCH

As instructed by the post-install message, add the following lines to /usr/local/etc/apache24/httpd.conf:

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

Also modify the following line:

DirectoryIndex index.html

changing it to:

DirectoryIndex index.php index.html


Installing Required PHP Extensions[edit]

Joomla requires the following PHP extensions:

  • CURL
  • FILTER
  • MYSQLI
  • SESSION
  • SIMPLEXML
  • XML
  • XMLREADER
  • ZIP
  • ZLIB

To install the required extensions via pkg:
pkg install php81-curl php81-filter php81-mysqli php81-session php81-simplexml php81-xml php81-xmlreader php81-zip php81-zlib

To simplify installation from sources, the php81-extensions meta-port can be used:
make -C /usr/ports/lang/php81-extensions/ config
select the required extensions and deselect all others then:
make -C /usr/ports/lang/php81-extensions/ install clean -DBATCH

Optimally to configure the php81-mysqli extension to use MySQL 8.0 server's default authentication mechanism <caching_sha2_password> instead of the php81-mysqli package default <mysql_native_password> authentication:
make -C /usr/ports/databases/php81-mysqli/ config
deselect 'Use MySQL Native Driver'

NOTE: When configured this way, the php81-mysqli port will depend on mysql80-client, which will also be installed. Significant compilation time can optionally be saved by first installing mysql80-client via pkg prior to compiling php81-mysqli:
pkg install mysql80-client

Compile and reinstall php81-mysqli:
make -C /usr/ports/databases/php81-mysqli/ reinstall clean -DBATCH

Configuring PHP[edit]

Create a new php.ini file by copying one of the sample files.
cd /usr/local/etc/
cp php.ini-production php.ini

Open and edit /usr/local/etc/php.ini and adjust the following values:

output_buffering = Off
post_max_size = 20M
upload_tmp_dir = /usr/local/www/apache24/data/tmp/
upload_max_filesize = 20M

After installing and configuring PHP restart the Apache service.
service apache24 restart

Installing MySQL Database Server[edit]

Execute the following commands to install MySQL 8.0 server.
pkg install mysql80-server or
make -C /usr/ports/databases/mysql80-server/ install clean -DBATCH

Add the following line to /etc/rc.conf:

mysql_enable="YES"

NOTE: MySQL 8 server initially defaults to creating users using <caching_sha2_password> authentication. Joomla will connect to it's database using a user with a <caching_sha2_password> if the php81-mysqli extension is configured and compiled from source. More details provided in previous section: Installing Required PHP Extensions.

If you prefer to use <mysql_native_password> authentication,
edit /usr/local/etc/mysql/my.cnf and add the following line to the [mysqld] section:

default_authentication_plugin   = mysql_native_password

Start the MySQL server.
service mysql-server start

Upon initial installation, the MySQL 8.0 server's root user has no password.

Login to the mysql server on the command line as root and set your desired password.
mysql -u root
root@localhost [(none)]>ALTER USER 'root'@'%' IDENTIFIED BY 'password';

Create a database for the Joomla web site with your preferred database name.
root@localhost [(none)]>create database joomla;

Create a dedicated MySQL user with your preferred username and password.
root@localhost [(none)]>create user 'joomla'@'%' identified by 'password';

Grant the user all privileges to the Joomla database.
root@localhost [(none)]>grant all privileges on joomla.* to 'joomla'@'%';
root@localhost [(none)]>flush privileges;

exit to close the connection to MySQL server.

Installing Joomla! CMS[edit]

Download the Joomla installation package ending with .zip
Unzip the file to apache's data directory.
unzip Joomla_*.zip -d /usr/local/www/apache24/data/

Change ownership of the data directory and everything in it to 'www' thus allowing the Joomla! configuration script to write into this directory.
chown -R www /usr/local/www/apache24/data/

At this point you should be able to begin installing and configuring Joomla!

Open and direct your web browser to one of the following...
If browsing directly on the server: http://localhost
If browsing from a remote system: http://<ip_address> or http://<fully.qualified.domain.name> (if configured)

You will see the Joomla Web Installer page.


In step 1 Configuration:
fill in the fields as required.


In step 2 Database:
Username: <joomlauser>
Password: <joomlauser password>
Database name: <joomladb>


Leave the other settings unchanged:
Database Type: MySQLi
Hostname: localhost
Table Prefix: unchanged


The final step of the web installer will be to delete the installation folder.
Once that is done you can browse to your newly installed Joomla! web site!

Post Installation[edit]

Research how to optimally configure and harden the security of your Joomla! FAMP web server!

Troubleshooting[edit]

Configuration changes made to either apache's httpd.conf or PHP's php.ini will require that the apache service be restarted for the changes to take effect.
service apache24 restart


Apache's error log is located at /var/log/httpd-error.log
MySQL log files are located in /var/db/mysql/ and are named <hostname>.err and <hostname>-slow.log by default.
MySQL databases are also located in /var/db/mysql/