Quick guide on how to install phpipam on FreeBSD. I will assume that you know how to install FreeBSD š
### Patch OS
freebsd-update fetch install
### Install all required packages
pkg install nginx php74-sockets php74-openssl php74-gmp php74-gettext php74-mbstring php74-gd php74-curl php74-pear php74-pdo_mysql php74-session php74-filter php74-json php74-iconv php74-ctype mysql57-server git sudo screen
Configure mysql
We won’t do any tuning to mysql, just create a user and database and lets go.
### Enable mysql on boot
sysrc mysql_enable=YES
### Run mysql_secure installation, choose to edit root password and press other to everything else.
mysql_secure_installation
### Login to mysql and create database, user and grant access to user
$ mysql -u root -p
CREATE DATABASE phpipam;
GRANT ALL ON phpipam.* TO phpipam@localhost IDENTIFIED BY 'trwITH!lU';
FLUSH PRIVILEGES;
QUIT;
Configure phpipam
Get phpipam and put in www dir. Use git to get code, this will also make it easier for version updates later on.
### Create folder
mkdir -p /usr/local/www/phpipam
### Get phpipam into folder
git clone https://github.com/phpipam/phpipam.git /usr/local/www/phpipam
### use version instead of dev
cd /usr/local/www/phpipam && git checkout -b 1.4 origin/1.4
### Create config.php
cp /usr/local/www/phpipam/config.dist.php /usr/local/www/phpipam/config.php
### Edit config.php so it matches mysql settings you created
$db['host'] = 'localhost';
$db['user'] = 'phpipam';
$db['pass'] = 'trwITH!lU';
$db['name'] = 'phpipam';
$db['port'] = 3306;
Updating phpipam
### Create backup of config.php
cp /usr/local/www/phpipam/config /tmp/config.php
### Create backup of database
cd /usr/local/www/phpipam
mysqldump -uroot -p phpipam > db/bkp/phpipam_$(date -v-1d +%d-%B-%Y).db
### Pull from GitHub
cd /var/www/phpipam
git pull
git checkout -b 1.x origin/1.x
git submodule update --init --recursive
Finish up by opening the web interface and follow upgrade procedure.
Configure nginx
Make nginx start on boot and backup the original config. We will then add our own.
### Enable nginx and mysql and boot
sysrc nginx_enable=YES
### backup original config
mv /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf.org
After we now have the backup, lets add the content beneath to nginx.conf.
user www;
worker_processes 2;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
# disable max upload size
client_max_body_size 0;
# add timeouts for very large uploads
client_header_timeout 30m;
client_body_timeout 30m;
server {
listen 80;
server_name ipam.ramsgaard.me;
root /usr/local/www/phpipam;
index index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php-fpm.sock;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
Configure PHP/FPM
Lets make a production ini file and afterwards setup php-fpm config file.
cp /usr/local/etc/php.ini{-production,}
Open the file /usr/local/etc/php-fpm.d/www.conf and uncomment the following lines.
listen.owner = www
listen.group = www
listen.mode = 0660
### Replace the TCP socket with unix socket.
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm.sock;
### Enable and start php-fpm
sysrc php_fpm_enable=YES
service php-fpm start
Conclusion
We have now installed all the required components, you should now reboot the server and check if all the services is coming up automatically. If so you can proceed and access the web interface of your new phpipam installation. Then follow the guide on how to get setup.