Jump to content

FreeBSD - Setup Nginx + php 8.1


Recommended Posts

Hello community,

In this guide I'm going to teach you how to install nginx + php 8.1 on freebsd.

Step by Step
 

# Install the packages
pkg install -y php81 nginx
pkg install -y php81-extensions php81-mysqli php81-mbstring php81-curl php81-gd

# Start the services when starting the operating system
sysrc nginx_enable=yes
sysrc php_fpm_enable=YES

# Start the services
service nginx start
service php-fpm start

# Create the directory
/var/www

# Replace the server { in: @/usr/local/etc/nginx/nginx.conf
    server {
        listen       80;
        server_name  localhost;
		
		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_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $request_filename;
            include        fastcgi_params;
        }
		
        location ~ /\.ht {
            deny  all;
        }
    }
 
# Restart nginx
service nginx restart

# Done! You can place the web files in the directory: @/var/www

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...