PHP-FPM 설정파일에서 listen 부분을 포트방식에서 소켓으로 변경했더니 아래와 같은 오류가 발생하는군요~

listen = /var/opt/remi/php74/run/php-fpm/www.sock
;listen = 127.0.0.1:9074

 

2023/01/31 06:00:01 [crit] 2476#0: *1 connect() to
 unix:/var/opt/remi/php74/run/php-fpm/www.sock failed (13: Permission denied) while connecting to upstream,
 client: xxx.xxx.xxx.xxx, server: www.example.com, request: "GET / HTTP/1.1",
 upstream: "fastcgi://unix:/var/opt/remi/php74/run/php-fpm/www.sock:", host: "www.example.com"

 

# chown nginx:nginx /var/opt/remi/php74/run/php-fpm/www.sock

이렇게 소유권을 바꿔주는 방법도 있긴하지만 systemctl restart php74-php-fpm 을 하면 다시 퍼미션을 원래대로 돌아가서 매번 변경해주어야 합니다.

 

위와 같이 하면 번거로우니 아래의 방법을 사용합니다.

# vi /etc/opt/remi/php74/php-fpm.d/www.conf

listen.mode = 0666

위와 같이 수정하고 systemctl restart php74-php-fpm 을 재시작하고 확인합니다.

 

 

 

 

블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[워드프레스] NGINX 유저 설정



NGINX 는 디폴트 user 가 nginx 입니다.


nginx 로 사용해도 되지만 apache 로 바꿔봅시다~


먼저 /etc/httpd/conf/httpd.conf 파일에 아래 부분을 찾습니다.


User apache

Group apache



/etc/nginx/nginx.conf 파일에서 user 부분을 수정합니다.


#user nginx;

user apache apache;


위와 같이 저장하고 systemctl restart nginx 하면 됩니다.


그리고 홈페이지 root 디렉토리의 소유권을 변경해 주어야 합니다.


읽기전용이라면 755 퍼미션을 주면 되지만 안에서 파일을 생성하거나 디렉토리를 만들려면 소유권을 변경해주어야 됩니다.


# chown -R apache.apache /var/www/html


이렇게 하시면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[워드프레스] 아파치 .htaccess RewriteRule NGINX 적용



워드프레스에서 사용되는 Apache 용 .htaccess 사용되는 리디렉션을 nginx 에 적용하는 방법입니다.


# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>


# END WordPress



아래 처럼 한줄을 추가해주면 됩니다.


server {

    ...

    location / {

        index    index.html index.htm index.php;

        try_files $uri $uri/ /index.php?$args;

    }

}


생각보다는 간단하네요~


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 6.x NGINX configtest


아파치는 apachectl configtest 옵션으로 환경설정이 제대로 되었는지 검증이 가능합니다.

nginx 는 nginx -t 옵션으로 확인하면 됩니다.

[root@vps conf.d]# nginx configtest

nginx: invalid option: "configtest"


[root@vps conf.d]# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

아파치 버전 마다 다르겠지만 2.2 버전대에서는 apachectl configtest 는

# apachectl -t 와 동일합니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

NGINX 다운로드 트래픽 제어



cband 모듈같은 상세한 속도를 제한하는 옵션은 없지만


아파치 2.4.x 에서 SetEnv rate-limit 500 과 같은 역할을 하는 기능입니다.


    location ~ /fast/(.+)\.mp3$ {

        limit_rate 500K;

    }


    location ~ /slow/(.+)\.mp3$ {

        limit_rate 200K;

    }


500K = 500KB/s 입니다. ( ex: 접속자별로 속도 제한 CBandRemoteSpeed 500Kb/s )


위의 설정은 디렉토리에 따라 속도를 분기하는 예제입니다.



아래는 일정 용량 이후에 트래픽을 제어하는 예제입니다.


limit_rate_after 100K;

limit_rate 500K;


초반에 100KByte 까지는 빠르다가 이 후에는 500KB/s 로 속도가 제어된다는 의미입니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

NGINX Service Unavailable

LINUX 2017. 7. 5. 17:22

NGINX Service Unavailable



엔진엑스는 아래와 같은 에러가 자주 발생하는 듯 하네요~


아파치만 사용하다 nginx 는 아직 적응이 안되는군요~


Service Unavailable


The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.



이런 경우엔 nginx 재시작 해주면 됩니다.



# systemctl restart php-fpm

# systemctl restart nginx


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

NGINX phpMyAdmin 연결

LINUX 2017. 6. 26. 09:34

NGINX phpMyAdmin 연결



아파치에서는 설치하면 자동으로 Alias 로 연결이 되었습니다.


nginx 는 Alias 대신에 심볼릭 링크를 걸어주면 잘 작동 하는군요~



server {

    listen       80;

    server_name  www.example.com;

    root         /var/www/html;

}


nginx 환경설정에 root 폴더가 /var/www/html 이라면


# ln -s /usr/share/phpMyAdmin /var/www/html/phpmyadmin


이렇게 심볼릭링크를 걸어주고 웹브라우저에서 http://www.example.com/phpmyadmin 으로 접속을 하면 됩니다.


'LINUX' 카테고리의 다른 글

리눅스 아파치 로그 IP 정렬방법  (0) 2017.07.03
아파치 BLEXBot 차단하기  (0) 2017.06.26
NGINX https Redirect 방법  (0) 2017.06.23
NGINX 확장자 html 에서도 php 동작되도록  (0) 2017.06.23
CentOS 원격백업 rsnapshot  (0) 2017.06.22
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

NGINX https Redirect 방법

LINUX 2017. 6. 23. 17:14

NGINX https Redirect 방법



아파치에서는 아래처럼 .htaccess 에서 80 포트로 오면 443 으로 리디렉션을 시켜줄 수가 있습니다.


RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]

RewriteCond %{SERVER_PORT} !^443$

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]



이것을 nginx 에서 설정하는 방법입니다.


server {
    listen       80;
    server_name  www.example.com;
    root         /var/www/html;

    location / {
        index    index.html index.htm index.php;
        return 301 https:$host$request_uri;
    }
}


이제 엔진엑스를 재시작하고 확인하면 됩니다.


'LINUX' 카테고리의 다른 글

아파치 BLEXBot 차단하기  (0) 2017.06.26
NGINX phpMyAdmin 연결  (0) 2017.06.26
NGINX 확장자 html 에서도 php 동작되도록  (0) 2017.06.23
CentOS 원격백업 rsnapshot  (0) 2017.06.22
ssh-copy-id 에러시 키 복사 방법  (0) 2017.06.22
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

NGINX 확장자 html 에서도 php 동작되도록



엔진엑스 설정만으로는 index.html 파일에서 php 가 작동이 안됩니다.


html 에서도 동작이 되도록 하려면 아래 처럼 설정하면 됩니다.



▶ /etc/php-fpm.d/www.conf 수정


security.limit_extensions = .php .php3 .php4 .php5 .htm .html


위 부분을 찾아서 주석을 해제하고 .htm .html 을 추가하고 저장합니다.


# systemctl restart php-fpm



▶ /etc/nginx/conf.d/www.example.com.conf 엔진엑스 설정


server {

    listen       80;

    server_name  www.example.com;

    root         /var/www/html;


    location / {

        index    index.html index.htm index.php;

    }


    location ~ [^/]\.(php|htm|html)(/|$) {

        fastcgi_pass  127.0.0.1:9000;

        fastcgi_index index.html;

        fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;

        include       fastcgi_params;

    }

}


server {

    listen       443;

    server_name  www.example.com;

    root         /var/www/html;


    ssl on;

    ssl_certificate /etc/letsencrypt/live/www.example.com/cert.pem;

    ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;


    location / {

        index    index.html index.htm index.php;

    }


    location ~ [^/]\.(php|htm|html)(/|$) {

        fastcgi_pass  127.0.0.1:9000;

        fastcgi_index index.html;

        fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;

        include       fastcgi_params;

    }

}


# systemctl restart nginx


이제 잘 되는지 확인하시면 됩니다.


'LINUX' 카테고리의 다른 글

NGINX phpMyAdmin 연결  (0) 2017.06.26
NGINX https Redirect 방법  (0) 2017.06.23
CentOS 원격백업 rsnapshot  (0) 2017.06.22
ssh-copy-id 에러시 키 복사 방법  (0) 2017.06.22
리눅스 VPS 스왑 용량 변경하기  (0) 2017.06.21
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,