์จ๋ผ์ธ ๊ฐ์
>PHP - ๊ณ ๊ธ
๐ PHP ๊ณ ๊ธ - 8์ฃผ์ฐจ: ๋ฐฐํฌ ๋ฐ ์ด์ ๊ธฐ์ด (Linux ์๋ฒ) - 03 ์น ์๋ฒ (Nginx/Apache) ์ค์ 
				์ฃผ์ ํ๋ก๊ทธ๋จ ์คํ
- ํ์ : 10.0
 - ๋ผ์ด์ ์ค: free
 - ์ด์์ฒด์ :
 - ํ์ผ ํฌ๊ธฐ: 0
 
ํผ๋๋ฐฑ ๋ฐ ๋ค์ด๋ก๋
- ์ฌ์ฉ์ ํ์ : 10.0
 - ๋ค์ด๋ก๋ ์: 1
 - ์กฐํ์: 36
 
์ ์กฐ์ฌ ๋ฐ ๋ฑ๋ก ์ ๋ณด
- ์ ์์ฌ: LUZENSOFT
 - ๋ฑ๋ก์ผ: 2025-09-29 10:42:37
 
- ์ค๋ช
์น ์๋ฒ์ ์ญํ ๊ณผ PHP-FPM ์ฐ๋
#์น_์๋ฒ (Web Server)๋ ํด๋ผ์ด์ธํธ(๋ธ๋ผ์ฐ์ )์ HTTP ์์ฒญ์ ๋ฐ์๋ค์ด๊ณ , ์ฒ๋ฆฌํ ํ ์๋ต์ ๋๋ ค์ฃผ๋ ํต์ฌ ์ปดํฌ๋ํธ์ ๋๋ค. ํ๋์ PHP ํ๊ฒฝ์์ ์น ์๋ฒ๋ PHP ์ฝ๋๋ฅผ ์ง์  ์คํํ์ง ์๊ณ , #PHP-FPM(FastCGI Process Manager)์ ์์ฒญ์ ์์ํฉ๋๋ค. ์น ์๋ฒ๋ ์ ์ ์ธ ํ์ผ(HTML, CSS, ์ด๋ฏธ์ง)์ ๋น ๋ฅด๊ฒ ์ฒ๋ฆฌํ๊ณ , ๋์ ์ธ PHP ์์ฒญ๋ง PHP-FPM์ ์ ๋ฌํจ์ผ๋ก์จ #์ฑ๋ฅ ์ ๊ทน๋ํํฉ๋๋ค. ๐
1. Nginx ์ค์  (LEMP ์คํ)
#Nginx ๋ ๊ฐ๋ฒผ์ด ์ํคํ ์ฒ์ ๋์ ๋์์ฑ ์ฒ๋ฆฌ ๋ฅ๋ ฅ์ผ๋ก ์ธํด ํ๋์ #LEMP (Linux, Nginx, MySQL, PHP) ์คํ์์ ๊ฐ์ฅ ์ ํธ๋๋ ์น ์๋ฒ์ ๋๋ค.
Nginx ์ค์น (Ubuntu ๊ธฐ์ค)
Bash
sudo apt update
sudo apt install nginx
๊ธฐ๋ณธ ์ค์  ํ์ผ (/etc/nginx/sites-available/default)
Nginx ์ค์ ์ ํต์ฌ์ location ๋ธ๋ก์ ์ฌ์ฉํ์ฌ ์์ฒญ์ ๋ถ๋ฆฌํ๋ ๊ฒ์
๋๋ค.
Nginx
server {
    listen 80;
    server_name your_domain.com; # ๋๋ฉ์ธ ์ด๋ฆ ๋๋ IP ์ฃผ์
    root /var/www/html/my-project/public; # ํ๋ก์ ํธ์ ์น ๋ฃจํธ ๋๋ ํฐ๋ฆฌ
    index index.php index.html;
    # 1. ์ ์  ํ์ผ ์ฒ๋ฆฌ: ํ์ผ์ด ์กด์ฌํ๋ฉด ์ง์  ์๋น
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    # 2. PHP ์์ฒญ ์ฒ๋ฆฌ: PHP-FPM์ผ๋ก ์ ๋ฌ
    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        # PHP-FPM ์์ผ ๋๋ TCP ์ฃผ์๋ก ์์ฒญ ์ ๋ฌ
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; 
        # ๋๋ fastcgi_pass 127.0.0.1:9000;
    }
    # 3. .htaccess์ ๊ฐ์ ์จ๊น ํ์ผ ์ ๊ทผ ์ฐจ๋จ
    location ~ /. {
        deny all;
    }
}
root: PHP ์ ํ๋ฆฌ์ผ์ด์ ์ #์น_๋ฃจํธ_๋๋ ํฐ๋ฆฌ ๋ฅผ ์ ํํ ์ง์ ํด์ผ ํฉ๋๋ค. (์: Laravel, Symfony ๋ฑ์ ๋ณดํตpublicํด๋๊ฐ ๋ฃจํธ์ ๋๋ค.)location ~ .php$:.php๋ก ๋๋๋ ๋ชจ๋ ์์ฒญ์ PHP-FPM์ผ๋ก ์ ๋ฌํฉ๋๋ค.fastcgi_pass: PHP-FPM์ #์์ผ ๊ฒฝ๋ก ๋๋ IP ์ฃผ์์ ํฌํธ(๊ธฐ๋ณธ 9000๋ฒ)๋ฅผ ์ง์ ํ์ฌ ์ฐ๋ํฉ๋๋ค.
2. Apache ์ค์  (LAMP ์คํ)
#Apache ๋ ๋ชจ๋ ๊ธฐ๋ฐ์ ์ ์ฐ์ฑ๊ณผ ๊ด๋ฒ์ํ ํธํ์ฑ ๋๋ถ์ ์ฌ์ ํ ๋๋ฆฌ ์ฌ์ฉ๋ฉ๋๋ค. PHP-FPM๊ณผ ์ฐ๋ํ๊ธฐ ์ํด์๋ mod_proxy_fcgi ๋ชจ๋์ ์ฌ์ฉํฉ๋๋ค.
Apache ์ค์น (Ubuntu ๊ธฐ์ค)
Bash
sudo apt update
sudo apt install apache2
PHP-FPM ์ฐ๋ ๋ชจ๋ ํ์ฑํ
Bash
sudo a2enmod proxy proxy_fcgi
๊ฐ์ ํธ์คํธ ์ค์  ํ์ผ (/etc/apache2/sites-available/000-default.conf)
ProxyPassMatch ์ง์์๋ฅผ ์ฌ์ฉํ์ฌ PHP ์์ฒญ์ PHP-FPM ์์ผ์ผ๋ก ์ ๋ฌํฉ๋๋ค.
Apache
<VirtualHost *:80>
    ServerName your_domain.com
    DocumentRoot /var/www/html/my-project/public
    <Directory /var/www/html/my-project/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    # PHP-FPM ์ฐ๋ ์ค์ 
    # .php ํ์ผ์ ๋ํ ์์ฒญ์ PHP-FPM ์์ผ์ผ๋ก ์ ๋ฌ
    <FilesMatch .php$>
        SetHandler "proxy:unix:/var/run/php/php8.1-fpm.sock|fcgi://localhost/"
    </FilesMatch>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
AllowOverride All:.htaccessํ์ผ ์ฌ์ฉ์ ํ์ฉํฉ๋๋ค.SetHandler: PHP-FPM ์์ผ ๊ฒฝ๋ก๋ฅผ ์ง์ ํ์ฌ ์์ฒญ์ ์์ํฉ๋๋ค.
3. ์น ์๋ฒ ์๋น์ค ๊ด๋ฆฌ
์ด๋ค ์น ์๋ฒ๋ฅผ ์ฌ์ฉํ๋ , ์ค์  ํ์ผ์ ๋ณ๊ฒฝํ ํ์๋ ๋ฐ๋์ ์๋น์ค๋ฅผ **์ฌ์์(Restart)**ํด์ผ ๋ณ๊ฒฝ ๋ด์ฉ์ด ์ ์ฉ๋ฉ๋๋ค.
์๋น์ค ๊ด๋ฆฌ ๋ช ๋ น์ด (systemd)
Bash
# Nginx์ ๊ฒฝ์ฐ
sudo systemctl restart nginx
sudo systemctl status nginx
# Apache์ ๊ฒฝ์ฐ
sudo systemctl restart apache2
sudo systemctl status apache2
# PHP-FPM์ ๊ฒฝ์ฐ (์น ์๋ฒ์ ๋ณ๊ฐ๋ก ๊ด๋ฆฌ)
sudo systemctl restart php8.1-fpm
๋ง์น๋ฉฐ
์์ ์ ์ธ #PHP_์ด์ ์ ์น ์๋ฒ์ PHP-FPM์ ์ฐ๋ ์ค์ ์ ๋ฌ๋ ค ์์ต๋๋ค. Nginx๋ ์ฑ๋ฅ๊ณผ ํจ์จ์ฑ ๋ฉด์์ ์ด์ ์ ์ ๊ณตํ๋ฉฐ, Apache๋ ๋ชจ๋ ์ฌ์ฉ์ ์ ์ฐ์ฑ์ ์ ๊ณตํฉ๋๋ค. ์ฌ์ฉ ํ๊ฒฝ์ ๋ง๋ ์น ์๋ฒ๋ฅผ ์ ํํ๊ณ , fastcgi_pass๋ ProxyPassMatch๋ฅผ ํตํด PHP-FPM๊ณผ์ ์์ผ/TCP ์ฐ๋์ ์ ํํ ์ค์ ํ๋ ๊ฒ์ด ๊ณ ์ฑ๋ฅ ์๋น์ค ๊ตฌ์ถ์ ํต์ฌ์
๋๋ค. โ๏ธ
๋น ๋ฅธ์๋, ๊ฐํธํ์ฌ์ฉ, ์ฅ์ ์๋VPN, ์ฌ์ฉ์ด๋ ฅ์๋ ๊นจ๋ํ ์์ดํผ
https://xn--299ao67b9qbmsf04c.net/