FEMP(nginx, mariaDB, PHP) Stack on FreeBsd 12

설치 기준

OS : FreeBSD 12.2

nginx : 1.18

MariaDB : MariaDB 10.3.27

PHP : 7.3

1. pkg update (http://blog.tjsim00.net/?p=61)

2. nginx install

# pkg install nginx

# sysrc nginx_enable=YES

# service nginx start

3. mariadb install

# pkg install mariadb103-server mariadb103-client

# sysrc mysql_enable=YES

# service mysql-server start

# mysql_secure_installation

4. php install

# pkg install php73 php73-mysqli php73-curl php73-gd php73-mbstring php73-xml php73-pdo php73-iconv php73-zip php73-opcache php73-fileinfo php73-gettext php73-json php73-openssl php73-xsl php73-xmlwriter php73-tokenizer php73-composer php73-pecl-memcached php73-pecl-imagick php73-pecl-mcrypt phpfpm_exporter pcre

# sysrc php_fpm_enable=YES

# service php-fpm start

5. php-fpm 설정

# vi /usr/local/etc/php-fpm.d/www.conf

user = nobody
group = nobody
listen = /var/run/php-fpm.sock
listen.owner = nobody
listen.group = nobody
listen.mode = 0660

# vi /usr/local/etc/nginx/nginx.conf

user  nobody;

worker_processes  1;
error_log  /var/log/nginx/error.log;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user 
                      [$time_local] "$request" '
                      '$status $body_bytes_sent 
                      "$http_referer" '
                      '"$http_user_agent" 
                      "$http_x_forwarded_for"';
    
    sendfile        on;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       80;
        server_name  localhost;

        root   /usr/local/www/nginx;
        index  index.php;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }

    	location ~ \.php$ {

             try_files $uri /index.php =404;
             fastcgi_split_path_info ^(.+\.php)(/.+)$;
             fastcgi_pass unix:/var/run/php-fpm.sock;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME 
             $document_root$fastcgi_script_name;
             include fastcgi_params;
        }

        location ~ /\.ht {
            deny  all;
        }
    }
}

# service php-fpm restart

# service nginx restart

# vi /usr/local/www/nginx/info.php

<?php
    phpinfo();
?>

6. 브라우저에서 확인

http://{서버아이피}/info.php

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다