In this tutorial or guide I will show you how to setup and install the needed components for running your own private cloud server based on FreeBSD and OwnCloud, I will also attach the session log output of my own install at the bottom so you can read the proper output of the server install in full.

One thing to note before beginning, this write up was done by request by a user, and while working on this project OwnCloud had several updates, and in the latest version decided to drop official support for FreeBSD installs, so if that is an issue for you then I suggest using a Linux flavor, you can still follow this guide for setting it up but you need to adjust some of the commands and folder loactions to mach your Linux system.

What is OwnCloudOwnCloud is a PHP and MySQL based free and open source file sharing application platform which allows us to create our very own cloud storage platform. The OwnCloud server which is a free edition is released under GNU AGPLv3 license whereas the Enterprise edition is under OwnCloud Commercial license. It is a client-server architectural software in which, the files are stored on the server whereas the clients are used to access and share the files. The client for OwnCloud is available for every platform making it easy to manage and access the files from every devices.

Why FreeBSDFreeBSD is a free and open source Unix-like operating system based on BSD systems. Unlike Linux, FreeBSD is developed as an entire operating system from kernel, device drivers to the userland utilities whereas Linux is a kernel with device drivers.

Currently while writing this article, the latest release of OwnCloud is 10.0.7 so, we'll be performing its setup on our freshly installed FreeBSD 11 server. I will only cover the minimal settings for getting OwnCloud up and running on FreeBSD with the basic configuration of FAMP stack

Routing and DNS information is handled by the pfSense network server where DNS Resolver is set whit Host Override for domain it-monkey.lan and server.it-monkey.lan pointing to IP 192.168.55.30 and this IP address is set to be staticly assign to the MAC Addr of the FreeBSD server through DHCP Static mapping.

I suggest you check if your router support this as it will make your access to the server much easier and cleaner

All configuration is done remotely over SSH connection using Putty from a Windows 7 client, as this is a headless server build from random parts I had available to use for this project, and to make it as common for most people that want to try something new.

Installing FAMP StackFAMP Stack is the combination of Apache web server, MySQL/MariaDB database server and PHP modules running on a FreeBSD server. FAMP is one of the widely used stack for hosting websites and web applications on servers. Here, we be installing FAMP stack in order to run our PHP based OwnCloud server.

This processes is pretty easy, you install the server OS (not covered in this guide), latest version of Apache web server, PHP and mySQL or MariaDB, we will be working whit the following versions:

Before installing any applications we need to make sure we have access to all the latest applications, versions and software available for the platformUpdate package repository information:sudo pkg update

Upgrade package repository information:sudo pkg upgrade

When the repository is updated, we need to install the tools used in this guidesudo pkg install curl wget vim nano gnupg

Apache:The Apache HTTP Server Project is a collaborative software development effort aimed at creating a robust, commercial-grade, featureful, and freely-available source code implementation of an HTTP (Web) server. The project is jointly managed by a group of volunteers located around the world, using the Internet and the Web to communicate, plan, and develop the server and its related documentation. This project is part of the Apache Software Foundation. In addition, hundreds of users have contributed ideas, code, and documentation to the project. This file is intended to briefly describe the history of the Apache HTTP Server and recognize the many contributors.

Now we need to set Apache to start automatically on boots:sudo sysrc apache24_enable=YES

Now we have to set the default production configuration for the Apache web server: sudo cp /usr/local/etc/apache24/httpd.conf.sample /usr/local/etc/apache24/httpd.conf

Now we can start the web server:sudo service apache24 start

When starting the Apache web server it is going to do a sanitycheck of its configuration, and since there is no static IP or DNS configuration on the server it is going to complain and warn you about this, this message can be ignored for now.

PHP:PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. It was originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by The PHP Group. PHP originally stood for Personal Home Page, but it now stands for the recursive acronym PHP: Hypertext Preprocessor

PHP code may be embedded into HTML code, or it can be used in combination with various web template systems, web content management systems, and web frameworks. PHP code is usually processed by a PHP interpreter implemented as a module in the web server or as a Common Gateway Interface (CGI) executable. The web server combines the results of the interpreted and executed PHP code, which may be any type of data, including images, with the generated web page. PHP code may also be executed with a command-line interface (CLI) and can be used to implement standalone graphical applications.

The standard PHP interpreter, powered by the Zend Engine, is free software released under the PHP License. PHP has been widely ported and can be deployed on most web servers on almost every operating system and platform, free of charge.

; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user's group; will be used.user = wwwgroup = www

; The address on which to accept FastCGI requests.; Valid syntaxes are:; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on; a specific port;; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on; a specific port;; 'port' - to listen on a TCP socket to all addresses; (IPv6 and IPv4-mapped) on a specific port;; '/path/to/unix/socket' - to listen on a unix socket.; Note: This value is mandatory.; listen = 127.0.0.1:9000listen = /var/run/php-fpm.socklisten.owner = wwwlisten.group = wwwlisten.mode = 0660

; Set permissions for unix socket, if one is used. In Linux, read/write; permissions must be set in order to allow connections from a web server. Many; BSD-derived systems allow connections regardless of permissions.; Default Values: user and group are set as the running user; mode is set to 0660;listen.owner = www;listen.group = www;listen.mode = 0660; When POSIX Access Control Lists are supported you can set them using; these options, value is a comma separated list of user/group names.; When set, listen.owner and listen.group are ignored;listen.acl_users =;listen.acl_groups =

; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address; must be separated by a comma. If this value is left blank, connections will be; accepted from any ip address.; Default Value: any;listen.allowed_clients = 127.0.0.1

; Specify the nice(2) priority to apply to the pool processes (only if set); The value can vary from -19 (highest priority) to 20 (lower priority); Note: - It will only work if the FPM master process is launched as root; - The pool processes will inherit the master process priority; unless it specified otherwise; Default Value: no set; process.priority = -19

; Choose how the process manager will control the number of child processes.; Possible Values:; static - a fixed number (pm.max_children) of child processes;; dynamic - the number of child processes are set dynamically based on the; following directives. With this process management, there will be; always at least 1 children.; pm.max_children - the maximum number of children that can; be alive at the same time.; pm.start_servers - the number of children created on startup.; pm.min_spare_servers - the minimum number of children in 'idle'; state (waiting to process). If the number; of 'idle' processes is less than this; number then some children will be created.; pm.max_spare_servers - the maximum number of children in 'idle'; state (waiting to process). If the number; of 'idle' processes is greater than this; number then some children will be killed.; ondemand - no children are created at startup. Children will be forked when; new requests will connect. The following parameter are used:; pm.max_children - the maximum number of children that; can be alive at the same time.; pm.process_idle_timeout - The number of seconds after which; an idle process will be killed.; Note: This value is mandatory.pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.; This value sets the limit on the number of simultaneous requests that will be; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP; CGI. The below defaults are based on a server without much resources. Don't; forget to tweak pm.* to fit your needs.; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'; Note: This value is mandatory.pm.max_children = 5

; The number of child processes created on startup.; Note: Used only when pm is set to 'dynamic'; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2pm.start_servers = 2

; The desired minimum number of idle server processes.; Note: Used only when pm is set to 'dynamic'; Note: Mandatory when pm is set to 'dynamic'pm.min_spare_servers = 1

; The desired maximum number of idle server processes.; Note: Used only when pm is set to 'dynamic'; Note: Mandatory when pm is set to 'dynamic'pm.max_spare_servers = 3

; The number of seconds after which an idle process will be killed.; Note: Used only when pm is set to 'ondemand'; Default Value: 10s;pm.process_idle_timeout = 10s;

; The number of requests each child process should execute before respawning.; This can be useful to work around memory leaks in 3rd party libraries. For; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.; Default Value: 0;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be; recognized as a status page. It shows the following informations:; pool - the name of the pool;; process manager - static, dynamic or ondemand;; start time - the date and time FPM has started;; start since - number of seconds since FPM has started;; accepted conn - the number of request accepted by the pool;; listen queue - the number of request in the queue of pending; connections (see backlog in listen(2));; max listen queue - the maximum number of requests in the queue; of pending connections since FPM has started;; listen queue len - the size of the socket queue of pending connections;; idle processes - the number of idle processes;; active processes - the number of active processes;; total processes - the number of idle + active processes;; max active processes - the maximum number of active processes since FPM; has started;; max children reached - number of times, the process limit has been reached,; when pm tries to start more children (works only for; pm 'dynamic' and 'ondemand');; Value are updated in real time.; Example output:; pool: www; process manager: static; start time: 01/Jul/2011:17:53:49 +0200; start since: 62636; accepted conn: 190460; listen queue: 0; max listen queue: 1; listen queue len: 42; idle processes: 4; active processes: 11; total processes: 15; max active processes: 12; max children reached: 0;; By default the status page output is formatted as text/plain. Passing either; 'html', 'xml' or 'json' in the query string will return the corresponding; output syntax. Example:; http://www.foo.bar/status; http://www.foo.bar/status?json; http://www.foo.bar/status?html; http://www.foo.bar/status?xml;; By default the status page only outputs short status. Passing 'full' in the; query string will also return status for each pool process.; Example:; http://www.foo.bar/status?full; http://www.foo.bar/status?json&full; http://www.foo.bar/status?html&full; http://www.foo.bar/status?xml&full; The Full status returns for each process:; pid - the PID of the process;; state - the state of the process (Idle, Running, ...);; start time - the date and time the process has started;; start since - the number of seconds since the process has started;; requests - the number of requests the process has served;; request duration - the duration in Âµs of the requests;; request method - the request method (GET, POST, ...);; request URI - the request URI with the query string;; content length - the content length of the request (only with POST);; user - the user (PHP_AUTH_USER) (or '-' if not set);; script - the main script called (or '-' if not set);; last request cpu - the %cpu the last request consumed; it's always 0 if the process is not in Idle state; because CPU calculation is done when the request; processing has terminated;; last request memory - the max amount of memory the last request consumed; it's always 0 if the process is not in Idle state; because memory calculation is done when the request; processing has terminated;; If the process is in Idle state, then informations are related to the; last request the process has served. Otherwise informations are related to; the current request being served.; Example output:; ************************; pid: 31330; state: Running; start time: 01/Jul/2011:17:53:49 +0200; start since: 63087; requests: 12808; request duration: 1250261; request method: GET; request URI: /test_mem.php?N=10000; content length: 0; user: -; script: /home/fat/web/docs/php/test_mem.php; last request cpu: 0.00; last request memory: 0;; Note: There is a real-time FPM status monitoring sample web page available; It's available in: /usr/local/share/php/fpm/status.html;; Note: The value must start with a leading slash (/). The value can be; anything, but it may not be a good idea to use the .php extension or it; may conflict with a real PHP file.; Default Value: not set;pm.status_path = /status

; The ping URI to call the monitoring page of FPM. If this value is not set, no; URI will be recognized as a ping page. This could be used to test from outside; that FPM is alive and responding, or to; - create a graph of FPM availability (rrd or such);; - remove a server from a group if it is not responding (load balancing);; - trigger alerts for the operating team (24/7).; Note: The value must start with a leading slash (/). The value can be; anything, but it may not be a good idea to use the .php extension or it; may conflict with a real PHP file.; Default Value: not set;ping.path = /ping

; This directive may be used to customize the response of a ping request. The; response is formatted as text/plain with a 200 response code.; Default Value: pong;ping.response = pong

; The access log format.; The following syntax is allowed; %%: the '%' character; %C: %CPU used by the request; it can accept the following format:; - %{user}C for user CPU only; - %{system}C for system CPU only; - %{total}C for user + system CPU (default); %d: time taken to serve the request; it can accept the following format:; - %{seconds}d (default); - %{miliseconds}d; - %{mili}d; - %{microseconds}d; - %{micro}d; %e: an environment variable (same as $_ENV or $_SERVER); it must be associated with embraces to specify the name of the env; variable. Some exemples:; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e; %f: script filename; %l: content-length of the request (for POST request only); %m: request method; %M: peak of memory allocated by PHP; it can accept the following format:; - %{bytes}M (default); - %{kilobytes}M; - %{kilo}M; - %{megabytes}M; - %{mega}M; %n: pool name; %o: output header; it must be associated with embraces to specify the name of the header:; - %{Content-Type}o; - %{X-Powered-By}o; - %{Transfert-Encoding}o; - ....; %p: PID of the child that serviced the request; %P: PID of the parent of the child that serviced the request; %q: the query string; %Q: the '?' character if query string exists; %r: the request URI (without the query string, see %q and %Q); %R: remote IP address; %s: status (response code); %t: server time the request was received; it can accept a strftime(3) format:; %d/%b/%Y:%H:%M:%S %z (default); The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t; %T: time the log has been written (the request has finished); it can accept a strftime(3) format:; %d/%b/%Y:%H:%M:%S %z (default); The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t; %u: remote user;; Default: "%R - %u %t \"%m %r\" %s";access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"

; The timeout for serving a single request after which a PHP backtrace will be; dumped to the 'slowlog' file. A value of '0s' means 'off'.; Available units: s(econds)(default), m(inutes), h(ours), or d(ays); Default Value: 0;request_slowlog_timeout = 0

; The timeout for serving a single request after which the worker process will; be killed. This option should be used when the 'max_execution_time' ini option; does not stop script execution for some reason. A value of '0' means 'off'.; Available units: s(econds)(default), m(inutes), h(ours), or d(ays); Default Value: 0;request_terminate_timeout = 0

; Chroot to this directory at the start. This value must be defined as an; absolute path. When this value is not set, chroot is not used.; Note: you can prefix with '$prefix' to chroot to the pool prefix or one; of its subdirectories. If the pool prefix is not set, the global prefix; will be used instead.; Note: chrooting is a great security feature and should be used whenever; possible. However, all PHP paths will be relative to the chroot; (error_log, sessions.save_path, ...).; Default Value: not set;chroot =

; Chdir to this directory at the start.; Note: relative path can be used.; Default Value: current directory or / when chroot;chdir = /var/www

; Redirect worker stdout and stderr into main error log. If not set, stdout and; stderr will be redirected to /dev/null according to FastCGI specs.; Note: on highloaded environement, this can cause some delay in the page; process time (several ms).; Default Value: no;catch_workers_output = yes

; Clear environment in FPM workers; Prevents arbitrary environment variables from reaching FPM worker processes; by clearing the environment in workers before env vars specified in this; pool configuration are added.; Setting to "no" will make all environment variables available to PHP code; via getenv(), $_ENV and $_SERVER.; Default Value: yes;clear_env = no

; Limits the extensions of the main script FPM will allow to parse. This can; prevent configuration mistakes on the web server side. You should only limit; FPM to .php extensions to prevent malicious users to use other extensions to; execute php code.; Note: set an empty value to allow all extensions.; Default Value: .php;security.limit_extensions = .php .php3 .php4 .php5 .php7

; Additional php.ini defines, specific to this pool of workers. These settings; overwrite the values previously defined in the php.ini. The directives are the; same as the PHP SAPI:; php_value/php_flag - you can set classic ini defines which can; be overwritten from PHP call 'ini_set'.; php_admin_value/php_admin_flag - these directives won't be overwritten by; PHP call 'ini_set'; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

# /usr/local/etc/apache24/httpd.conf## This is the main Apache HTTP server configuration file. It contains the# configuration directives that give the server its instructions.# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.# In particular, see # <URL:http://httpd.apache.org/docs/2.4/mod/directives.html># for a discussion of each configuration directive.## Do NOT simply read the instructions in here without understanding# what they do. They're here only as hints or reminders. If you are unsure# consult the online docs. You have been warned. ## Configuration and logfile names: If the filenames you specify for many# of the server's control files begin with "/" (or "drive:/" for Win32), the# server will use that explicit path. If the filenames do *not* begin# with "/", the value of ServerRoot is prepended -- so "logs/access_log"# with ServerRoot set to "/usr/local/apache2" will be interpreted by the# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log" # will be interpreted as '/logs/access_log'.

## ServerRoot: The top of the directory tree under which the server's# configuration, error, and log files are kept.## Do not add a slash at the end of the directory path. If you point# ServerRoot at a non-local disk, be sure to specify a local disk on the# Mutex directive, if file-based mutexes are used. If you wish to share the# same ServerRoot for multiple httpd daemons, you will need to change at# least PidFile.#ServerRoot "/usr/local"

## Mutex: Allows you to set the mutex mechanism and mutex file directory# for individual mutexes, or change the global defaults## Uncomment and change the directory if mutexes are file-based and the default# mutex file directory is not on a local disk or is not appropriate for some# other reason.## Mutex default:/var/run

## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses.##Listen 12.34.56.78:80Listen 80

# Third party modulesIncludeOptional etc/apache24/modules.d/[0-9][0-9][0-9]_*.conf

<IfModule unixd_module>## If you wish httpd to run as a different user or group, you must run# httpd as root initially and it will switch. ## User/Group: The name (or #number) of the user/group to run httpd as.# It is usually good practice to create a dedicated user and group for# running httpd, as with most system services.#User wwwGroup www

</IfModule>

# 'Main' server configuration## The directives in this section set up the values used by the 'main'# server, which responds to any requests that aren't handled by a# <VirtualHost> definition. These values also provide defaults for# any <VirtualHost> containers you may define later in the file.## All of these directives may appear inside <VirtualHost> containers,# in which case these default settings will be overridden for the# virtual host being defined.#

## ServerAdmin: Your address, where problems with the server should be# e-mailed. This address appears on some server-generated pages, such# as error documents. e.g. admin@your-domain.com#ServerAdmin you@example.com

## ServerName gives the name and port that the server uses to identify itself.# This can often be determined automatically, but we recommend you specify# it explicitly to prevent problems during startup.## If your host doesn't have a registered DNS name, enter its IP address here.##ServerName www.example.com:80

## Note that from this point forward you must specifically allow# particular features to be enabled - so if something's not working as# you might expect, make sure that you have specifically enabled it# below.#

## DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.#DocumentRoot "/usr/local/www/apache24/data"<Directory "/usr/local/www/apache24/data"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks

# # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride None

# # Controls who can get stuff from this server. # Require all granted</Directory>

## DirectoryIndex: sets the file that Apache will serve if a directory# is requested.#<IfModule dir_module> DirectoryIndex index.php index.html</IfModule>

## The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. #<Files ".ht*"> Require all denied</Files>

## ErrorLog: The location of the error log file.# If you do not specify an ErrorLog directive within a <VirtualHost># container, error messages relating to that virtual host will be# logged here. If you *do* define an error logfile for a <VirtualHost># container, that host's errors will be logged there and not here.#ErrorLog "/var/log/httpd-error.log"

# # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost> # container, they will be logged here. Contrariwise, if you *do* # define per-<VirtualHost> access logfiles, transactions will be # logged therein and *not* in this file. # CustomLog "/var/log/httpd-access.log" common

# # If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # #CustomLog "/var/log/httpd-access.log" combined</IfModule>

<IfModule alias_module> # # Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location. # Example: # Redirect permanent /foo http://www.example.com/bar

# # Alias: Maps web paths into filesystem paths and is used to # access content that does not live under the DocumentRoot. # Example: # Alias /webpath /full/filesystem/path # # If you include a trailing / on /webpath then the server will # require it to be present in the URL. You will also likely # need to provide a <Directory> section to allow access to # the filesystem path.

# # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. # ScriptAlias /cgi-bin/ "/usr/local/www/apache24/cgi-bin/"

</IfModule>

<IfModule cgid_module> # # ScriptSock: On threaded servers, designate the path to the UNIX # socket used to communicate with the CGI daemon of mod_cgid. # #Scriptsock cgisock</IfModule>

## "/usr/local/www/apache24/cgi-bin" should be changed to whatever your ScriptAliased# CGI directory exists, if you have that configured.#<Directory "/usr/local/www/apache24/cgi-bin"> AllowOverride None Options None Require all granted</Directory>

# # AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below) # # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # #AddHandler cgi-script .cgi

# For type maps (negotiated resources): #AddHandler type-map var

# # Filters allow you to process content before it is sent to the client. # # To parse .shtml files for server-side includes (SSI): # (You will also need to add "Includes" to the "Options" directive.) # #AddType text/html .shtml #AddOutputFilter INCLUDES .shtml</IfModule>

## The mod_mime_magic module allows the server to use various hints from the# contents of the file itself to determine its type. The MIMEMagicFile# directive tells the module where the hint definitions are located.##MIMEMagicFile etc/apache24/magic

## MaxRanges: Maximum number of Ranges in a request before# returning the entire resource, or one of the special# values 'default', 'none' or 'unlimited'.# Default setting is to accept 200 Ranges.#MaxRanges unlimited

## EnableMMAP and EnableSendfile: On systems that support it, # memory-mapping or the sendfile syscall may be used to deliver# files. This usually improves server performance, but must# be turned off when serving from networked-mounted # filesystems or if support for these functions is otherwise# broken on your system.# Defaults: EnableMMAP On, EnableSendfile Off##EnableMMAP off#EnableSendfile on

# Supplemental configuration## The configuration files in the etc/apache24/extra/ directory can be # included to add extra features or to modify the default configuration of # the server, or you may simply copy their contents here and change as # necessary.

# Secure (SSL/TLS) connections#Include etc/apache24/extra/httpd-ssl.conf## Note: The following must must be present to support# starting without SSL on platforms with no /dev/random equivalent# but a statically compiled-in mod_ssl.#<IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin</IfModule>

Include etc/apache24/Includes/*.conf

Now we need to create a PHP Info \ Diagnostics page to check if all is working correctly:sudo nano /usr/local/www/apache24/data/phpinfo.php

Now that you have checked that everything is working correctly whit Apache and PHP, it is time to install and configure the Database server mySQL v5.7

mySQL:mySQL is the world's most popular open source database. With its proven performance, reliability and ease-of-use, mySQL has become the leading database choice for web-based applications, used by high profile web properties including Facebook, Twitter, YouTube, Yahoo! and many more.

Open mySQL Server to create the needed Databases and access that is required by OwnCloud: sudo mysql -u root -p

Now there is a bug in the SQL secure installation process that make us to reset the password for root user before creating the databases and access:ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySexyPassword123.';

Then we can create the database: ownclouddb, and the admin user: ocadmin

Now we have done the minimum FAMP configuration for OwnCloud to run on FreeBSD, now we are just missing a few environment configurations before installing the OwnCloud package. We start by creating the SSL Certs so we can use HTTPS connection for accessing the server

In this guide we will be using the self signed SSL Cert, but the process for generating a self signed cert and a signed cert is identical as you need to generate a CSR and PEM file and a private and public key pair, if you follow this process and give the correct details, you can send the CSR file to a Certificate Authority and get it publicly signed and validated for your server

You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but for some fields there will be a default value,If you enter “ . “ the field will be left blank(not recommended).

Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:An optional company name []:

My server is located in Drammen, Norway so the form will look like this for me, and you have to adjust this to your server or organisation locations, if you are a home user the important part here is Country, City, Common Name and Email are correct and you can leave the rest empty

Common Name needs to be the FQDN and or Public IP of the server if you are going to have it accessed for the Internet

Set the correct premission so Apache web server can read the files:sudo chown -R www:www /usr/local/www/apache24/data/owncloud/

We can now download the OwnCloud software to our server, the current way to do that is to use wget or curl and point it at the URL holding the tar install file of OwnCloud, these URLs changes often so check OwnClouds website for the current version

We only need these files temporarily so we move to the system temp folder:cd /tmp

Now we need to download the OwnCloud software to our server, the current way to do that is to use wget or curl and point it at the URL holding the tar install file of OwnCloud, these urls changes often so check OwnClouds website for the current version

Documents installed with the system are in the /usr/local/share/doc/freebsd/directory, or can be installed later with: pkg install en-freebsd-docFor other languages, replace "en" with a language code like de or fr.

Show the version of FreeBSD installed: freebsd-version ; uname -aPlease include that output and any error messages when posting questions.Introduction to manual pages: man manFreeBSD directory layout: man hier

Edit /etc/motd to change this login announcement.In order to make fetch (the FreeBSD downloading tool) ask forusername/password when it encounters a password-protected web page, you can setthe environment variable HTTP_AUTH to 'basic:*'.

And some of the standard libraries are provided as separate portssince they require extra dependencies:

databases/ruby-gdbm:GDBM module

Install them as occasion demands.====Message from ctags-5.8:

**************************************************************************The executable for Exuberant CTAGS is installed as /usr/local/bin/exctags**************************************************************************

Installation of the tools is now compleeted, now we install the Webserver Apache v2.4$ sudo pkg install apache24Updating FreeBSD repository catalogue...FreeBSD repository is up to date.All repositories are up to date.The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:apache24: 2.4.29apr: 1.6.3.1.6.1db5: 5.3.28_6

To run apache www server from startup, add apache24_enable="yes"in your /etc/rc.conf. Extra options can be found in startup script.

Your hostname must be resolvable using at least 1 mechanism in/etc/nsswitch.conf typically DNS or /etc/hosts or apache mighthave issues starting depending on the modules you are using.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

- apache24 default build changed from static MPM to modular MPM- more modules are now enabled per default in the port- icons and error pages moved from WWWDIR to DATADIR

If build with modular MPM and no MPM is activated in httpd.conf, then mpm_prefork will be activated as default MPM in etc/apache24/modules.d to keep compatibility with existing php/perl/python modules!

Now we need to set Apache to start automatically on reboots$ sudo sysrc apache24_enable=YESapache24_enable: -> YES

Now we have to set the default production configuration for the Apache web server$ sudo cp /usr/local/etc/apache24/httpd.conf.sample /usr/local/etc/apache24/httpd.conf

Now we can start the web server$ sudo service apache24 startPerforming sanity check on apache24 configuration:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.55.30. Set the 'ServerName' directive globally to suppress this messageSyntax OKStarting apache24.AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.55.30. Set the 'ServerName' directive globally to suppress this message

This is a common error since we have not configured DNS or Domain of the FreeBSD Server as this is handled by an external system you do not need to do this for this guide and can be ignored for now

Try `man ldap.conf' and visit the OpenLDAP FAQ-O-Matic at http://www.OpenLDAP.org/faq/index.cgi?file=3for more information.

************************************************************Message from libmcrypt-2.5.8_3:

===> NOTICE:

The libmcrypt port currently does not have a maintainer. As a result, it ismore likely to have unresolved issues, not be up-to-date, or even be removed inthe future. To volunteer to maintain this port, please create an issue at:

https://bugs.freebsd.org/bugzilla

More information about port maintainership is available at:

https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-portMessage from mod_php71-7.1.15:

If you are building PHP-based ports in poudriere(8) with ZTS enabled,add WITH_MPM=event to /etc/make.conf to prevent build failures.

*********************************************************************

Now we need to configure the production configuration of PHP$ sudo cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini$ sudo nano /usr/local/etc/php-fpm.d/www.conf; Start a new pool named 'www'.; the variable $pool can be used in any directive and will be replaced by the; pool name ('www' here)[www]

; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user's group; will be used.user = wwwgroup = www

; The address on which to accept FastCGI requests.; Valid syntaxes are:; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on; a specific port;; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on; a specific port;; 'port' - to listen on a TCP socket to all addresses; (IPv6 and IPv4-mapped) on a specific port;; '/path/to/unix/socket' - to listen on a unix socket.; Note: This value is mandatory.; listen = 127.0.0.1:9000listen = /var/run/php-fpm.socklisten.owner = wwwlisten.group = wwwlisten.mode = 0660

; Set permissions for unix socket, if one is used. In Linux, read/write; permissions must be set in order to allow connections from a web server. Many; BSD-derived systems allow connections regardless of permissions.; Default Values: user and group are set as the running user; mode is set to 0660;listen.owner = www;listen.group = www;listen.mode = 0660; When POSIX Access Control Lists are supported you can set them using; these options, value is a comma separated list of user/group names.; When set, listen.owner and listen.group are ignored;listen.acl_users =;listen.acl_groups =

; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address; must be separated by a comma. If this value is left blank, connections will be; accepted from any ip address.; Default Value: any;listen.allowed_clients = 127.0.0.1

; Specify the nice(2) priority to apply to the pool processes (only if set); The value can vary from -19 (highest priority) to 20 (lower priority); Note: - It will only work if the FPM master process is launched as root; - The pool processes will inherit the master process priority; unless it specified otherwise; Default Value: no set; process.priority = -19

; Choose how the process manager will control the number of child processes.; Possible Values:; static - a fixed number (pm.max_children) of child processes;; dynamic - the number of child processes are set dynamically based on the; following directives. With this process management, there will be; always at least 1 children.; pm.max_children - the maximum number of children that can; be alive at the same time.; pm.start_servers - the number of children created on startup.; pm.min_spare_servers - the minimum number of children in 'idle'; state (waiting to process). If the number; of 'idle' processes is less than this; number then some children will be created.; pm.max_spare_servers - the maximum number of children in 'idle'; state (waiting to process). If the number; of 'idle' processes is greater than this; number then some children will be killed.; ondemand - no children are created at startup. Children will be forked when; new requests will connect. The following parameter are used:; pm.max_children - the maximum number of children that; can be alive at the same time.; pm.process_idle_timeout - The number of seconds after which; an idle process will be killed.; Note: This value is mandatory.pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.; This value sets the limit on the number of simultaneous requests that will be; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP; CGI. The below defaults are based on a server without much resources. Don't; forget to tweak pm.* to fit your needs.; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'; Note: This value is mandatory.pm.max_children = 5

; The number of child processes created on startup.; Note: Used only when pm is set to 'dynamic'; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2pm.start_servers = 2

; The desired minimum number of idle server processes.; Note: Used only when pm is set to 'dynamic'; Note: Mandatory when pm is set to 'dynamic'pm.min_spare_servers = 1

; The desired maximum number of idle server processes.; Note: Used only when pm is set to 'dynamic'; Note: Mandatory when pm is set to 'dynamic'pm.max_spare_servers = 3

; The number of seconds after which an idle process will be killed.; Note: Used only when pm is set to 'ondemand'; Default Value: 10s;pm.process_idle_timeout = 10s;

; The number of requests each child process should execute before respawning.; This can be useful to work around memory leaks in 3rd party libraries. For; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.; Default Value: 0;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be; recognized as a status page. It shows the following informations:; pool - the name of the pool;; process manager - static, dynamic or ondemand;; start time - the date and time FPM has started;; start since - number of seconds since FPM has started;; accepted conn - the number of request accepted by the pool;; listen queue - the number of request in the queue of pending; connections (see backlog in listen(2));; max listen queue - the maximum number of requests in the queue; of pending connections since FPM has started;; listen queue len - the size of the socket queue of pending connections;; idle processes - the number of idle processes;; active processes - the number of active processes;; total processes - the number of idle + active processes;; max active processes - the maximum number of active processes since FPM; has started;; max children reached - number of times, the process limit has been reached,; when pm tries to start more children (works only for; pm 'dynamic' and 'ondemand');; Value are updated in real time.; Example output:; pool: www; process manager: static; start time: 01/Jul/2011:17:53:49 +0200; start since: 62636; accepted conn: 190460; listen queue: 0; max listen queue: 1; listen queue len: 42; idle processes: 4; active processes: 11; total processes: 15; max active processes: 12; max children reached: 0;; By default the status page output is formatted as text/plain. Passing either; 'html', 'xml' or 'json' in the query string will return the corresponding; output syntax. Example:; http://www.foo.bar/status; http://www.foo.bar/status?json; http://www.foo.bar/status?html; http://www.foo.bar/status?xml;; By default the status page only outputs short status. Passing 'full' in the; query string will also return status for each pool process.; Example:; http://www.foo.bar/status?full; http://www.foo.bar/status?json&full; http://www.foo.bar/status?html&full; http://www.foo.bar/status?xml&full; The Full status returns for each process:; pid - the PID of the process;; state - the state of the process (Idle, Running, ...);; start time - the date and time the process has started;; start since - the number of seconds since the process has started;; requests - the number of requests the process has served;; request duration - the duration in Âµs of the requests;; request method - the request method (GET, POST, ...);; request URI - the request URI with the query string;; content length - the content length of the request (only with POST);; user - the user (PHP_AUTH_USER) (or '-' if not set);; script - the main script called (or '-' if not set);; last request cpu - the %cpu the last request consumed; it's always 0 if the process is not in Idle state; because CPU calculation is done when the request; processing has terminated;; last request memory - the max amount of memory the last request consumed; it's always 0 if the process is not in Idle state; because memory calculation is done when the request; processing has terminated;; If the process is in Idle state, then informations are related to the; last request the process has served. Otherwise informations are related to; the current request being served.; Example output:; ************************; pid: 31330; state: Running; start time: 01/Jul/2011:17:53:49 +0200; start since: 63087; requests: 12808; request duration: 1250261; request method: GET; request URI: /test_mem.php?N=10000; content length: 0; user: -; script: /home/fat/web/docs/php/test_mem.php; last request cpu: 0.00; last request memory: 0;; Note: There is a real-time FPM status monitoring sample web page available; It's available in: /usr/local/share/php/fpm/status.html;; Note: The value must start with a leading slash (/). The value can be; anything, but it may not be a good idea to use the .php extension or it; may conflict with a real PHP file.; Default Value: not set;pm.status_path = /status

; The ping URI to call the monitoring page of FPM. If this value is not set, no; URI will be recognized as a ping page. This could be used to test from outside; that FPM is alive and responding, or to; - create a graph of FPM availability (rrd or such);; - remove a server from a group if it is not responding (load balancing);; - trigger alerts for the operating team (24/7).; Note: The value must start with a leading slash (/). The value can be; anything, but it may not be a good idea to use the .php extension or it; may conflict with a real PHP file.; Default Value: not set;ping.path = /ping

; This directive may be used to customize the response of a ping request. The; response is formatted as text/plain with a 200 response code.; Default Value: pong;ping.response = pong

; The access log format.; The following syntax is allowed; %%: the '%' character; %C: %CPU used by the request; it can accept the following format:; - %{user}C for user CPU only; - %{system}C for system CPU only; - %{total}C for user + system CPU (default); %d: time taken to serve the request; it can accept the following format:; - %{seconds}d (default); - %{miliseconds}d; - %{mili}d; - %{microseconds}d; - %{micro}d; %e: an environment variable (same as $_ENV or $_SERVER); it must be associated with embraces to specify the name of the env; variable. Some exemples:; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e; %f: script filename; %l: content-length of the request (for POST request only); %m: request method; %M: peak of memory allocated by PHP; it can accept the following format:; - %{bytes}M (default); - %{kilobytes}M; - %{kilo}M; - %{megabytes}M; - %{mega}M; %n: pool name; %o: output header; it must be associated with embraces to specify the name of the header:; - %{Content-Type}o; - %{X-Powered-By}o; - %{Transfert-Encoding}o; - ....; %p: PID of the child that serviced the request; %P: PID of the parent of the child that serviced the request; %q: the query string; %Q: the '?' character if query string exists; %r: the request URI (without the query string, see %q and %Q); %R: remote IP address; %s: status (response code); %t: server time the request was received; it can accept a strftime(3) format:; %d/%b/%Y:%H:%M:%S %z (default); The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t; %T: time the log has been written (the request has finished); it can accept a strftime(3) format:; %d/%b/%Y:%H:%M:%S %z (default); The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t; %u: remote user;; Default: "%R - %u %t \"%m %r\" %s";access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"

; The timeout for serving a single request after which a PHP backtrace will be; dumped to the 'slowlog' file. A value of '0s' means 'off'.; Available units: s(econds)(default), m(inutes), h(ours), or d(ays); Default Value: 0;request_slowlog_timeout = 0

; The timeout for serving a single request after which the worker process will; be killed. This option should be used when the 'max_execution_time' ini option; does not stop script execution for some reason. A value of '0' means 'off'.; Available units: s(econds)(default), m(inutes), h(ours), or d(ays); Default Value: 0;request_terminate_timeout = 0

; Chroot to this directory at the start. This value must be defined as an; absolute path. When this value is not set, chroot is not used.; Note: you can prefix with '$prefix' to chroot to the pool prefix or one; of its subdirectories. If the pool prefix is not set, the global prefix; will be used instead.; Note: chrooting is a great security feature and should be used whenever; possible. However, all PHP paths will be relative to the chroot; (error_log, sessions.save_path, ...).; Default Value: not set;chroot =

; Chdir to this directory at the start.; Note: relative path can be used.; Default Value: current directory or / when chroot;chdir = /var/www

; Redirect worker stdout and stderr into main error log. If not set, stdout and; stderr will be redirected to /dev/null according to FastCGI specs.; Note: on highloaded environement, this can cause some delay in the page; process time (several ms).; Default Value: no;catch_workers_output = yes

; Clear environment in FPM workers; Prevents arbitrary environment variables from reaching FPM worker processes; by clearing the environment in workers before env vars specified in this; pool configuration are added.; Setting to "no" will make all environment variables available to PHP code; via getenv(), $_ENV and $_SERVER.; Default Value: yes;clear_env = no

; Limits the extensions of the main script FPM will allow to parse. This can; prevent configuration mistakes on the web server side. You should only limit; FPM to .php extensions to prevent malicious users to use other extensions to; execute php code.; Note: set an empty value to allow all extensions.; Default Value: .php;security.limit_extensions = .php .php3 .php4 .php5 .php7

; Additional php.ini defines, specific to this pool of workers. These settings; overwrite the values previously defined in the php.ini. The directives are the; same as the PHP SAPI:; php_value/php_flag - you can set classic ini defines which can; be overwritten from PHP call 'ini_set'.; php_admin_value/php_admin_flag - these directives won't be overwritten by; PHP call 'ini_set'; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

Now we need to enable the PHP modules in Apache webserver$ sudo nano /usr/local/etc/apache24/httpd.conf## This is the main Apache HTTP server configuration file. It contains the# configuration directives that give the server its instructions.# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.# In particular, see # <URL:http://httpd.apache.org/docs/2.4/mod/directives.html># for a discussion of each configuration directive.## Do NOT simply read the instructions in here without understanding# what they do. They're here only as hints or reminders. If you are unsure# consult the online docs. You have been warned. ## Configuration and logfile names: If the filenames you specify for many# of the server's control files begin with "/" (or "drive:/" for Win32), the# server will use that explicit path. If the filenames do *not* begin# with "/", the value of ServerRoot is prepended -- so "logs/access_log"# with ServerRoot set to "/usr/local/apache2" will be interpreted by the# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log" # will be interpreted as '/logs/access_log'.

## ServerRoot: The top of the directory tree under which the server's# configuration, error, and log files are kept.## Do not add a slash at the end of the directory path. If you point# ServerRoot at a non-local disk, be sure to specify a local disk on the# Mutex directive, if file-based mutexes are used. If you wish to share the# same ServerRoot for multiple httpd daemons, you will need to change at# least PidFile.#ServerRoot "/usr/local"

## Mutex: Allows you to set the mutex mechanism and mutex file directory# for individual mutexes, or change the global defaults## Uncomment and change the directory if mutexes are file-based and the default# mutex file directory is not on a local disk or is not appropriate for some# other reason.## Mutex default:/var/run

## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses.##Listen 12.34.56.78:80Listen 80

# Third party modulesIncludeOptional etc/apache24/modules.d/[0-9][0-9][0-9]_*.conf

<IfModule unixd_module>## If you wish httpd to run as a different user or group, you must run# httpd as root initially and it will switch. ## User/Group: The name (or #number) of the user/group to run httpd as.# It is usually good practice to create a dedicated user and group for# running httpd, as with most system services.#User wwwGroup www

</IfModule>

# 'Main' server configuration## The directives in this section set up the values used by the 'main'# server, which responds to any requests that aren't handled by a# <VirtualHost> definition. These values also provide defaults for# any <VirtualHost> containers you may define later in the file.## All of these directives may appear inside <VirtualHost> containers,# in which case these default settings will be overridden for the# virtual host being defined.#

## ServerAdmin: Your address, where problems with the server should be# e-mailed. This address appears on some server-generated pages, such# as error documents. e.g. admin@your-domain.com#ServerAdmin you@example.com

## ServerName gives the name and port that the server uses to identify itself.# This can often be determined automatically, but we recommend you specify# it explicitly to prevent problems during startup.## If your host doesn't have a registered DNS name, enter its IP address here.##ServerName www.example.com:80

## Note that from this point forward you must specifically allow# particular features to be enabled - so if something's not working as# you might expect, make sure that you have specifically enabled it# below.#

## DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.#DocumentRoot "/usr/local/www/apache24/data"<Directory "/usr/local/www/apache24/data"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks

# # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride None

# # Controls who can get stuff from this server. # Require all granted</Directory>

## DirectoryIndex: sets the file that Apache will serve if a directory# is requested.#<IfModule dir_module> DirectoryIndex index.php index.html</IfModule>

## The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. #<Files ".ht*"> Require all denied</Files>

## ErrorLog: The location of the error log file.# If you do not specify an ErrorLog directive within a <VirtualHost># container, error messages relating to that virtual host will be# logged here. If you *do* define an error logfile for a <VirtualHost># container, that host's errors will be logged there and not here.#ErrorLog "/var/log/httpd-error.log"

# # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost> # container, they will be logged here. Contrariwise, if you *do* # define per-<VirtualHost> access logfiles, transactions will be # logged therein and *not* in this file. # CustomLog "/var/log/httpd-access.log" common

# # If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # #CustomLog "/var/log/httpd-access.log" combined</IfModule>

<IfModule alias_module> # # Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location. # Example: # Redirect permanent /foo http://www.example.com/bar

# # Alias: Maps web paths into filesystem paths and is used to # access content that does not live under the DocumentRoot. # Example: # Alias /webpath /full/filesystem/path # # If you include a trailing / on /webpath then the server will # require it to be present in the URL. You will also likely # need to provide a <Directory> section to allow access to # the filesystem path.

# # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. # ScriptAlias /cgi-bin/ "/usr/local/www/apache24/cgi-bin/"

</IfModule>

<IfModule cgid_module> # # ScriptSock: On threaded servers, designate the path to the UNIX # socket used to communicate with the CGI daemon of mod_cgid. # #Scriptsock cgisock</IfModule>

## "/usr/local/www/apache24/cgi-bin" should be changed to whatever your ScriptAliased# CGI directory exists, if you have that configured.#<Directory "/usr/local/www/apache24/cgi-bin"> AllowOverride None Options None Require all granted</Directory>

# # AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below) # # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # #AddHandler cgi-script .cgi

# For type maps (negotiated resources): #AddHandler type-map var

# # Filters allow you to process content before it is sent to the client. # # To parse .shtml files for server-side includes (SSI): # (You will also need to add "Includes" to the "Options" directive.) # #AddType text/html .shtml #AddOutputFilter INCLUDES .shtml</IfModule>

## The mod_mime_magic module allows the server to use various hints from the# contents of the file itself to determine its type. The MIMEMagicFile# directive tells the module where the hint definitions are located.##MIMEMagicFile etc/apache24/magic

## MaxRanges: Maximum number of Ranges in a request before# returning the entire resource, or one of the special# values 'default', 'none' or 'unlimited'.# Default setting is to accept 200 Ranges.#MaxRanges unlimited

## EnableMMAP and EnableSendfile: On systems that support it, # memory-mapping or the sendfile syscall may be used to deliver# files. This usually improves server performance, but must# be turned off when serving from networked-mounted # filesystems or if support for these functions is otherwise# broken on your system.# Defaults: EnableMMAP On, EnableSendfile Off##EnableMMAP off#EnableSendfile on

# Supplemental configuration## The configuration files in the etc/apache24/extra/ directory can be # included to add extra features or to modify the default configuration of # the server, or you may simply copy their contents here and change as # necessary.

# Secure (SSL/TLS) connections#Include etc/apache24/extra/httpd-ssl.conf## Note: The following must must be present to support# starting without SSL on platforms with no /dev/random equivalent# but a statically compiled-in mod_ssl.#<IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin</IfModule>

Include etc/apache24/Includes/*.conf

Now we need to create a PHP Info \ Diagnostics page to check if all is working correctly$ sudo nano /usr/local/www/apache24/data/phpinfo.php<?php phpinfo(); ?>

Now we need to restart Apache Web server since we have done alot of configuration changes that needs to be reloaded$ sudo service apache24 restartPerforming sanity check on apache24 configuration:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.55.30. Set the 'ServerName' directive globally to suppress this messageSyntax OKStopping apache24.Waiting for PIDS: 5585.Performing sanity check on apache24 configuration:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.55.30. Set the 'ServerName' directive globally to suppress this messageSyntax OKStarting apache24.AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.55.30. Set the 'ServerName' directive globally to suppress this message

Test web server, open a web browser and test both IP and DNS access: http://192.168.55.30/phpinfo.php and http://server.it-monkey.lan/phpinfo.php Now that you have checked that everything is working correctly whit Apache and PHP, it is time to install and configure the Database server mySQL v5.7

$ sudo pkg install mysql57-serverUpdating FreeBSD repository catalogue...FreeBSD repository is up to date.All repositories are up to date.The following 6 package(s) will be affected (of 0 checked):

If you want to enable SMTP AUTH with the system Sendmail, readSendmail.README

NOTE: This port has been compiled with a default pwcheck_method of auxprop. If you want to authenticate your user by /etc/passwd, PAM or LDAP, install ports/security/cyrus-sasl2-saslauthd and set sasl_pwcheck_method to saslauthd after installing the Cyrus-IMAPd 2.X port. You should also check the /usr/local/lib/sasl2/*.conf files for the correct pwcheck_method. If you want to use GSSAPI mechanism, install ports/security/cyrus-sasl2-gssapi. If you want to use SRP mechanism, install ports/security/cyrus-sasl2-srp. If you want to use LDAP auxprop plugin, install ports/security/cyrus-sasl2-ldapdb.Message from mysql57-client-5.7.21:

* * * * * * * * * * * * * * * * * * * * * * * *

This is the mysql CLIENT without the server.for complete server and client, please install databases/mysql57-server

VALIDATE PASSWORD PLUGIN can be used to test passwordsand improve security. It checks the strength of passwordand allows the users to set only those passwords which aresecure enough. Would you like to setup VALIDATE PASSWORD plugin?

Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: MySexyPassword123.

Re-enter new password: MySexyPassword123.

Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : yBy default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.

Now we have done the minimum FAMP configuration for OwnCloud to run on FreeBSD,now we are just missing a few enviornment configuratuions before installing the OwnCloud package. We start by creating the SSL Certs so we can use HTTPS connection for accessing the server$ sudo mkdir -p /usr/local/etc/ssl/self-cert/owncloud/$ cd /usr/local/etc/ssl/self-cert/owncloud/$ sudo openssl req -config /etc/ssl/openssl.cnf -new -out /usr/local/etc/ssl/self-cert/owncloud/owncloud.csr -keyout /usr/local/etc/ssl/self-cert/owncloud/owncloud.pemGenerating a 2048 bit RSA private key.+++...+++writing new private key to '/usr/local/etc/ssl/self-cert/owncloud/owncloud.pem'Enter PEM pass phrase: MySexyPassword123.Verifying - Enter PEM pass phrase: MySexyPassword123.-----You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:NOState or Province Name (full name) [Some-State]:BuskerudLocality Name (eg, city) []:DrammenOrganization Name (eg, company) [Internet Widgits Pty Ltd]:IT-MonkeyOrganizational Unit Name (eg, section) []:ITCommon Name (e.g. server FQDN or YOUR name) []:server.it-monkey.lanEmail Address []:admin@it-monkey.lan

Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:MySexyPassword123.An optional company name []:IT-Monkey

Now we need to download the OwnCloud software to our server, the current way to do that is to use wget or curl and point it at the url holding the tar install file of OwnCloud, these urls changes often so check OwnClouds website for the current version

Now we need to unpack and extract the files from the downloaded tar package and move it to a location the web server can read the files$ sudo tar -xjf owncloud-10.0.7.tar.bz2$ sudo cp -r owncloud/* /usr/local/www/apache24/data/owncloud/cp: /usr/local/www/apache24/data/owncloud is not a directory$ sudo mkdir -p /usr/local/www/apache24/data/owncloud/$ sudo chown -R www:www /usr/local/www/apache24/data/owncloud/

Restart Apache web server$ sudo service apache24 restartPerforming sanity check on apache24 configuration:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.55.30. Set the 'ServerName' directive globally to suppress this messageSyntax OKStopping apache24.Waiting for PIDS: 5585.Performing sanity check on apache24 configuration:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.55.30. Set the 'ServerName' directive globally to suppress this messageSyntax OKStarting apache24.AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.55.30. Set the 'ServerName' directive globally to suppress this message

Now everything should be installed and working and when you open your web browser and navigate to http://192.168.55.30/owncloud/ or http://server.it-monkey.lan/owncloud/ you should see the OwnCloud setup page