Jump to content
  • Create New...

How to setup nginx and php on FreeBSD to host your website


Recommended Posts

There instructions have been tested on FreeBSD 12.1!


First of all we want to install update the package repository:

pkg update


If you have never used pkg probably you will be asked to install it.


Now run this command to install php7.4 and nginx


pkg install php74 nginx


We can install the most common php extensions running this command:


 pkg install php74-extensions php74-mysqli php74-mbstring php74-curl php74-gd


The following extensions will be installed:

		php74-ctype: 7.4.14
        php74-curl: 7.4.14
        php74-dom: 7.4.14
        php74-extensions: 1.0
        php74-filter: 7.4.14
        php74-gd: 7.4.14
        php74-iconv: 7.4.14
        php74-json: 7.4.14
        php74-mbstring: 7.4.14
        php74-mysqli: 7.4.14
        php74-opcache: 7.4.14
        php74-pdo: 7.4.14
        php74-pdo_sqlite: 7.4.14
        php74-phar: 7.4.14
        php74-posix: 7.4.14
        php74-session: 7.4.14
        php74-simplexml: 7.4.14
        php74-sqlite3: 7.4.14
        php74-tokenizer: 7.4.14
        php74-xml: 7.4.14
        php74-xmlreader: 7.4.14
        php74-xmlwriter: 7.4.14


Enable nginx and php service to automatically start

sysrc nginx_enable=yes
sysrc php_fpm_enable=YES


We can start nginx and php for the first time by running

service nginx start
service php-fpm start


You can open now your web browser and type the server ip in the address bar.

You should see a page like this



We are going to configure nginx now. Open the file nginx.conf located in /usr/local/etc/nginx and modify the section "server":


    server {
        listen       80;
        server_name  _;
		root   /var/www;
        index  index.php index.html index.htm;

        location / {
			try_files $uri $uri/ =404;

        location ~ \.php$ {
			try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $request_filename;
            include        fastcgi_params;
        location ~ /\.ht {
            deny  all;


Change mydomainname.com with your domain  (or server ip).


We can test now if php is working correctly.


The files of your webiste will be hosted in the folder /var/www (you can change it in the configuration above). Create a new file inside that folder and call it index.php with this content:



Now open again the browser and type the ip address/domain name and you should see something like this:




The server is working properly and you can upload now your script :)


You might need to install more php extentions according to the requirements of  your script

  • Love 2
  • Good 2
Link to comment
Share on other sites

  • 3 weeks later...
On 2/23/2021 at 8:55 PM, Bizzy said:

is fixed i switch to freebsd 12.1 and is okay sry :) can you make a tutorial for ishop or so? ^^

You have to purchase an item shop script or get one for free in the internet and host it on your server. You have just to throw the ishop folder inside /var/www

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Activity

    1. 0

      Looking for Someone to create the queries etc for armors and weapons

    2. 13

      Official Private Shop Search

    3. 944

      [40250] Reference Serverfile + Client + Src [15 Available Languages]

    4. 79

      GUI Teleport System

    5. 0

      inventory slot marking system cant compile

    6. 8

      Inventory Bug

    7. 63

      Metin2 Dev - Changelogs

    8. 0

      [BUG] Can't select my own character (Select Target)

  • Recently Browsing

    • No registered users viewing this page.

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.