[Nginx APT] [Nginx Compile] PHP-FPM > Linux/Apm

본문 바로가기
사이트 내 전체검색

Linux/Apm

[Nginx APT] [Nginx Compile] PHP-FPM

페이지 정보

작성자 sbLAB 댓글 0건 조회 1,754회 작성일 23-06-14 21:32

본문

[Nginx apt설치 + PHP-FPM apt 설치]


80 port(xampp,apache2 서비스 중지) 

systemctl stop apache2

systemctl stop xampp


sudo apt update

sudo apt install nginx

sudo ufw enable

sudo ufw app list

sudo ufw allow 'Nginx Full'  //80, 443 allow

sudo ufw status

-------------------------------------------------------

To                         Action      From

--                         ------      ----

23/tcp                     ALLOW       Anywhere

Nginx Full                 ALLOW       Anywhere

23/tcp (v6)                ALLOW       Anywhere (v6)

Nginx Full (v6)            ALLOW       Anywhere (v6)

---------------------------------------------------------

systemctl status nginx


cd /etc/nginx 

------------------

conf.d  fastcgi.conf  fastcgi_params  koi-utf  koi-win  mime.types  modules-available  

modules-enabled  nginx.conf  proxy_params  scgi_params  sites-available  sites-enabled  

snippets  uwsgi_params  win-utf

-----------------


[nginx 루트 html 생성]

/usr/local/nginx/html


[nginx 사용자 추가]

# useradd --shell /usr/sbin/nologin --home-dir /usr/local/nginx/html nginx


# cat /etc/passwd

nginx:x:1001:1001::/usr/local/nginx/html:/usr/sbin/nologin


# cd /usr/local/nginx/

# chown nginx:nginx html -R


[php-fpm 설치]

# apt install php-fpm

# php -v

# apt install php8.1-{bcmath,fpm,xml,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi}

# php -m


# ps -ef | grep nginx

-----------------------

root       28869       1  0 20:35 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx

www-data   28870   28869  0 20:35 ?        00:00:00 nginx: worker process

www-data   28871   28869  0 20:35 ?        00:00:00 nginx: worker process

root       29499    3044  0 20:59 pts/1    00:00:00 grep --color=auto nginx

------------------------


[경로확인]

/etc/nginx/nginx.conf  <= nginx.conf


/run/php/php8.1-fpm.sock     <= php8.1-fpm.sock 경로

/etc/php/8.1/fpm/  <= php-fpm.conf  php.ini 경로

/etc/php/8.1/fpm/pool.d/www.conf <= www.conf



# nano /etc/nginx/nginx.conf

---------------------------------

user nginx;

worker_processes auto;

pid /run/nginx.pid;


include /etc/nginx/modules-enabled/*.conf;


events {

        worker_connections 768;

        # multi_accept on;

}


http {

        sendfile on;

        tcp_nopush on;

        types_hash_max_size 2048;

        # server_tokens off;

        # server_names_hash_bucket_size 64;

        # server_name_in_redirect off;

        #gzip on;


        include /etc/nginx/mime.types;

        default_type application/octet-stream;



        #ssl

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE

        ssl_prefer_server_ciphers on;


        #log

        access_log /var/log/nginx/access.log;

        error_log /var/log/nginx/error.log;


        #server

        server {

           listen       80;

           server_name  *.mysite.kr;


           root /usr/local/nginx/html/;

           #charset koi8-r;


           #access_log  logs/host.access.log  main;


           location / {

              #root   html;

              index  index.html index.htm;

           }


           #*.php-fpm

           location ~ \.php$ {

              include fastcgi.conf;

              fastcgi_pass unix:/run/php/php8.1-fpm.sock;

             }


          }


        include /etc/nginx/conf.d/*.conf;

}

-----------------------------------------


[pool.d -> www.conf  설정]

#nano /etc/php/8.1/fpm/pool.d/www.conf

--------------------------------------

user = nginx

group = nginx

...

listen.owner = nginx

listen.group = nginx

listen.mode = 0660

-----------------------------


[/etc/nginx/nginx.conf - syntax 체크]

#/usr/sbin/nginx -t


[error log]

nano /var/log/nginx/error.log


systemctl restart nginx

systemctl restart php8.1-fpm


systemctl status nginx

systemctl status php8.1-fpm

----------------------------------------------------------------


[mysql(이미 설치된 상태) + phpmyadmin 연결]

systemctl status mysql

systemctl start mysql
sudo ln -s /usr/share/phpmyadmin /usr/local/nginx/html/phpma


[Nginx Compile 설치 + PHP-FPM apt 설치]


Compile Install 

http://sebom.com/gb/bbs/board.php?bo_table=tech&wr_id=95


[경로확인]

/usr/local/nginx/conf <= nginx conf 경로

/usr/local/nginx/html <= nginx html 경로

/usr/local/nginx/logs/error.log  <= error.log 경로

/var/run/php/php8.1-fpm.sock <= php8.1-fpm.sock 경로

/etc/php/8.1/fpm/  <= php-fpm.conf  php.ini 경로

/etc/php/8.1/fpm/pool.d/www.conf  <= www.conf 경로



/usr/local/nginx/conf#  ls

------------------------------

fastcgi.conf            koi-utf             nginx.conf           uwsgi_params

fastcgi.conf.default    koi-win             nginx.conf.default   uwsgi_params.default

fastcgi_params          mime.types          scgi_params          win-utf

fastcgi_params.default  mime.types.default  scgi_params.default

------------------------------



#nano /usr/local/nginx/conf/nginx.conf

--------------------------------------      

user  nginx;

worker_processes  auto;


error_log  logs/error.log;

error_log  logs/error.log  notice;

error_log  logs/error.log  info;


pid  logs/nginx.pid;


events {

    worker_connections  1024;

}


http {

    #/usr/local/nginx/conf/mime.types

    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"';


    #access_log  logs/access.log  main;

    sendfile        on;

    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;


    #------------------------------

    #server load balancing settings

    #------------------------------

    server {

        listen       80;

        server_name  *.mysite.kr;


        #root /usr/local/nginx/html/;

        #charset koi8-r;


        #access_log  logs/host.access.log  main;


        location / {

            #root   html;

            index  index.html index.htm;

        }


        location /api {

            proxy_pass http://blserver;

        }


        location /status {

          check_status;

        }


        #error_page  404              /404.html;


        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }


        # php-fpm ---- load balancing proxy 용도 서버인 경우 php-fpm 사용 안 할 것--

       #location ~ \.php$ {

       #    root html;

       #    include fastcgi.conf;

       #    fastcgi_pass unix:/run/php/php8.1-fpm.sock;

       #}


        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

        #    include        fastcgi_params;

        #}


        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }


        upstream blserver {

          # least_conn;

          # ip_hash; 


          server 192.168.0.11:80;

          server 192.168.0.35:80;


          check interval=3000 rise=2 fall=5 timeout=4000 type=http;

          check_http_send "HEAD / HTTP/1.0\r\n\r\n";

          check_http_expect_alive http_2xx http_3xx;


        }


    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;


    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}



    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;


    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;


    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;


    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;


    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}


}

-------------------------------------



#nano /etc/php/8.1/fpm/pool.d/www.conf

-------------------------------------

..

user = nginx

group = nginx

..

listen = /var/run/php/php8.1-fpm.sock

..

listen.owner = nginx

listen.group = nginx

listen.mode = 0660

...

-----------------


/usr/local/nginx/sbin/nginx -t


systemctl restart php8.1-fpm

systemctl restart nginx


systemctl status php8.1-fpm

systemctl status nginx



댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
95
어제
401
최대
1,279
전체
221,749

그누보드5
Copyright © sebom.com All rights reserved.