# Install Concrete5 CMS on FreeBSD 13.1



## tennea9 (Dec 7, 2022)

Hello,
I don't know if it is the right place to post this thread. 
Sorry in advance if it is not.

As I did not find any ressource on internet about how to install Concrete5 CMS latest version (9.1.3) on FreeBSD 13.1, 
I wrote a script to install it on a FreeBSD server.
It's a basic installation (http) with apache24, mariadb-server 106 and php80.
There is a tinyURL for concrete package because of the length of concrete's URL.

Maybe it will help some people.


```
#!/bin/sh
echo "nameserver 1.1.1.1" > /etc/resolv.conf
clear
echo "----------------------------------"
echo "Welcome to this script for Concrete5 9.1.3 on FreeBSD 13.1"
echo "----------------------------------"
echo "Give a database name"
echo "(example : concrete5db)"
read dbname
echo "----------------------------------"
echo "Give a privileged user for this database"
echo "(exemple : admin)"
read dbuser
echo "----------------------------------"
echo "Give a password for $dbuser"
read dbuserPASSWD
echo "----------------------------------"
echo "Do you want yo create a specific vhost (-> http://vhost) [o] ? Or use Default one (-> http://IP) [n] ?"
read answer
case $answer in
    o)
        echo "----------------------------------"
        echo "Give a domain name"
        echo "(example : mywonderfulconcrete5.com)"
        read vhost
        clear
        echo "----------------------------------"
        echo "Installation begins"

        pkg install -y apache24 wget unzip
        sysrc apache24_enable=YES
        pkg install -y mariadb106-server
        sysrc mysql_enable=YES
        service mysql-server start
        
        clear
        echo "----------------------------------"
        echo "Please answer to the following questions"
        echo "(it's mysql_secure_installation script)"
        mysql_secure_installation
        wait

        mysqladmin -uroot create $dbname
        mysql -uroot -e"GRANT ALL ON $dbname.* TO $dbuser@localhost IDENTIFIED BY '$dbuserPASSWD'"
        
        pkg install -y mod_php80 php80-xml php80-session php80-curl php80-fileinfo php80-zip php80-mbstring php80-dom php80 php80-iconv php80-simplexml php80-mysqli php80-pdo_mysql php80-pdo php80-filter php80-gd php80-tokenizer

        echo "<IfModule dir_module>" > /usr/local/etc/apache24/Includes/php.conf
        echo "DirectoryIndex index.php index.html" >> /usr/local/etc/apache24/Includes/php.conf
        echo '<FilesMatch "\.php$">' >> /usr/local/etc/apache24/Includes/php.conf
        echo 'SetHandler application/x-httpd-php' >> /usr/local/etc/apache24/Includes/php.conf
        echo '</FilesMatch>' >> /usr/local/etc/apache24/Includes/php.conf
        echo '<FilesMatch "\.phps$">' >> /usr/local/etc/apache24/Includes/php.conf
        echo 'SetHandler application/x-httpd-php-source' >> /usr/local/etc/apache24/Includes/php.conf
        echo '</FilesMatch>' >> /usr/local/etc/apache24/Includes/php.conf
        echo '</IfModule>' >> /usr/local/etc/apache24/Includes/php.conf
        
        cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

        # Following tinyURL is for concrete5 9.1.3 version package from concretecms.org. Original URL is too long, had to shorten it.
        # tinyURL was created on december 6th of 2022. Valid for 90 days.
        wget https://tinyurl.com/concrete5-majekla -P /tmp
        cd /tmp
        unzip concrete5-majekla
        rm concrete5-majekla
        mkdir -p /usr/local/www/$vhost/logs
        mv concrete-cms-9.1.3/* /usr/local/www/$vhost
        
        mkdir /usr/local/etc/apache24/vhosts
        echo "<VirtualHost *:80>" > /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "ServerName $vhost" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "DocumentRoot /usr/local/www/$vhost" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "ErrorLog /usr/local/www/$vhost/logs/error_log" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "CustomLog /usr/local/www/$vhost/logs/access_log combined" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "<Directory /usr/local/www/$vhost>" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "AllowOverride Options FileInfo Limit" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "Options Indexes FollowSymLinks" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "Require all granted" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "DirectoryIndex index.php" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "</Directory>" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "</VirtualHost>" >> /usr/local/etc/apache24/vhosts/$vhost.conf
        echo "Include etc/apache24/vhosts/*.conf" >> /usr/local/etc/apache24/httpd.conf
        
        chown -R www:www /usr/local/www/$vhost/application/files
        chown -R www:www /usr/local/www/$vhost/application/config
        chown -R www:www /usr/local/www/$vhost/application/languages
        chown -R www:www /usr/local/www/$vhost/packages
        chown -R www:www /usr/local/www/$vhost/updates

        chmod -R 755 /usr/local/www/$vhost/application/files
        chmod -R 755 /usr/local/www/$vhost/application/config
        chmod -R 755 /usr/local/www/$vhost/application/languages
        chmod -R 755 /usr/local/www/$vhost/packages
        chmod -R 755 /usr/local/www/$vhost/updates

        service apache24 restart
        clear
        echo "----------------------------------"
        echo "Installation done !"
        echo "----------------------------------"
        echo "you've created database $dbname with privileged user $dbuser/$dbuserPASSWD"
        echo "After DNS record, you'll be able to reach concrete5 web platform with URL :"
        echo "http://$vhost"
    ;;
    n)
        clear
        echo "----------------------------------"
        echo "Installation begins"
        sleep 2
        pkg install -y apache24 wget
        sysrc apache24_enable=YES
        pkg install -y mariadb106-server
        sysrc mysql_enable=YES
        service mysql-server start
        clear
        echo "----------------------------------"
        echo "Please answer to the following questions"
        echo "(it's mysql_secure_installation script)"
        mysql_secure_installation
        wait
        
        mysqladmin -uroot create $dbname
        mysql -uroot -e"GRANT ALL ON $dbname.* TO $dbuser@localhost IDENTIFIED BY '$dbuserPASSWD'"
        
        pkg install -y mod_php80 php80-xml php80-session php80-curl php80-fileinfo php80-zip php80-mbstring php80-dom php80 php80-iconv php80-simplexml php80-mysqli php80-pdo_mysql php80-pdo php80-filter php80-gd php80-tokenizer
        
        echo "<IfModule dir_module>" > /usr/local/etc/apache24/Includes/php.conf
        echo "DirectoryIndex index.php index.html" >> /usr/local/etc/apache24/Includes/php.conf
        echo '<FilesMatch "\.php$">' >> /usr/local/etc/apache24/Includes/php.conf
        echo 'SetHandler application/x-httpd-php' >> /usr/local/etc/apache24/Includes/php.conf
        echo '</FilesMatch>' >> /usr/local/etc/apache24/Includes/php.conf
        echo '<FilesMatch "\.phps$">' >> /usr/local/etc/apache24/Includes/php.conf
        echo 'SetHandler application/x-httpd-php-source' >> /usr/local/etc/apache24/Includes/php.conf
        echo '</FilesMatch>' >> /usr/local/etc/apache24/Includes/php.conf
        echo '</IfModule>' >> /usr/local/etc/apache24/Includes/php.conf
        
        cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini


        # Following tinyURL is for concrete5 9.1.3 version package from concretecms.org. Original URL is too long, had to shorten it.
        # tinyURL was created on december 6th of 2022. Valid for 90 days.
        wget https://tinyurl.com/concrete5-majekla -P /tmp                           
        cd /tmp
        unzip concrete5-majekla
        rm concrete5-majekla                           
        rm /usr/local/www/apache24/data/index.html
        mv concrete-cms-9.1.3/* /usr/local/www/apache24/data
        cd /usr/local/www/apache24/data
        
        chown www:www /usr/local/www/apache24/data

        chown -R www:www /usr/local/www/apache24/data/application/files
        chown -R www:www /usr/local/www/apache24/data/application/config
        chown -R www:www /usr/local/www/apache24/data/application/languages
        chown -R www:www /usr/local/www/apache24/data/packages
        chown -R www:www /usr/local/www/apache24/data/updates

        chmod -R 755 /usr/local/www/apache24/data/application/files
        chmod -R 755 /usr/local/www/apache24/data/application/config
        chmod -R 755 /usr/local/www/apache24/data/application/languages
        chmod -R 755 /usr/local/www/apache24/data/packages
        chmod -R 755 /usr/local/www/apache24/data/updates

        service apache24 restart
        clear
        echo "----------------------------------"
        echo "Installation done"
        echo "----------------------------------"
        echo "you've created database $dbname with privileged user $dbuser/$dbuserPASSWD"
        echo "you can reach Concrete5 Web platform with :"
        echo "http://SERVER-IP"
    ;;
esac
```


----------

