Skip to content

Instantly share code, notes, and snippets.

@ar-android
Last active December 27, 2023 19:07
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ar-android/b7555911de8a5505aaa67cd66fc34d4a to your computer and use it in GitHub Desktop.
Save ar-android/b7555911de8a5505aaa67cd66fc34d4a to your computer and use it in GitHub Desktop.
Setup FreeBSD Server for Laravel

Update Package

sudo freebsd-update fetch install

Install NGINX

sudo pkg install nginx

Install MYSQL Server

sudo pkg install mysql56-server

Install PHP 7.1

sudo pkg install php71 php71-mysqli php71-gd php71-curl php71-zlib php71-hash php71-tokenizer php71-mbstring php71-pdo php71-phar php71-json php71-filter php71-iconv php71-openssl php71-zlib php71-zip php71-mbstring php71-dom  php71-xml php71-session php71-pdo_mysql php71-ctype

Install Composer

curl -s http://getcomposer.org/installer | php && echo "export PATH=${PATH}:/var/www/vendor/bin" >> ~/.bashrc && mv composer.phar /usr/local/bin/composer

Configure PHP

Copy configure file

sudo cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Config environment variable php

sudo nano /usr/local/etc/php.ini

Change to this :


cgi.fix_pathinfo=0

listen.owner = www
listen.group = www
listen.mode = 0660

Next rehash

rehash

And enable Service

sudo sysrc nginx_enable=yes mysql_enable=yes php_fpm_enable=yes

Install GIT

sudo pkg install git

Config MYSQL

sudo service mysql-server start

Install Secure MYSQL

sudo mysql_secure_installation

Install REDIS

sudo pkg install redis

Start service Redis

sudo sh -c 'echo redis_enable=\"YES\" >> /etc/rc.conf'
sudo service redis start

Install PHPMYADMIN

wget https://files.phpmyadmin.net/phpMyAdmin/4.7.7/phpMyAdmin-4.7.7-all-languages.zip

pkg install unzip

unzip phpMyAdmin-4.7.7-all-languages.zip

rm phpMyAdmin-4.7.7-all-languages.zip

mv phpMyAdmin-4.7.7-all-languages/ phpmyadmin

cd phpmyadmin/

cp config.sample.inc.php config.inc.php

Nginx config phpmyadmin


server {
    # default server specification
    listen 8083;
    server_name localhost;

    # file location
    root /root/phpmyadmin;
    index index.php index.html index.htm;

    # check if a file or directory index file exists, else route it to 404 error page.
    # else pass the request to the index.php as a query parameter.
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # error pages
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    # handle execution of PHP files
    # set php5-fpm socket
    # tell NGINX to proxy requests to PHP FPM via the FCGI protocol
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

}

Restart nginx and php

sudo service nginx restart
sudo service php-fpm restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment