2018. 6. 20.

nginx + php71 + php-fpm 설치하기

version 정보

  • nginx : 1.14.0
  • php : 7.1.18

yum install nginx 를 통해서 설치하였으며,

# yum install nginx

[root@centos html]# nginx -v
nginx version: nginx/1.14.0

php71 은 remi repo를 추가해서 아래와 같이 설치했다.

# yum --enablerep=remi-php71 install php-fpm php-common

[root@centos html]# php -v
PHP 7.1.18 (cli) (built: May 24 2018 07:59:58) ( NTS )
Copyright © 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright © 1998-2018 Zend Technologies

설정파일

/etc/php-fpm.d/www.conf 파일

########### file /etc/php-fpm.d/www.conf
user = nginx
group = nginx
;listen은 nginx 설정과 맞춰줘야 한다.
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock;
listen.owner = nginx
listen.group = nginx

/etc/nginx/conf.d/default.conf 파일

########### file /etc/nginx/conf.d/default.conf

server {
    listen   80;
    server_name  your_server_ip;

    # note that these lines are originally from the "location /" block
    # root 설정이 없으면 404 에러가 날수 있다.
    root   /usr/share/nginx/html; 
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        #fastcgi_pass 는 아래 두개 중 아무거나 사용해도 좋으나 php-fpm.d/www.conf 설정과 맞춰줘야 한다.
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        #/scripts 이름으로 인해서 오류가 생길 수 있다.
     #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

에러상황 #1

사이트에 접속은 되는데 404 error 또는 파일을 찾을 수 없는 상황

[error] 7469#7469: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.0.114, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:",

해결방법

/etc/nginx/conf.d/default.conf 설정파일에서 아래와 같이 root 폴더 설정을 한다.

server {
 root /usr/share/nginx/html;
 index
}

에러상황 #2

*1 connect() to unix:/var/run/php-fpm/php-fpm.sock failed (13: Permission denied) while connecting to upstream,

php-fpm.sock 의 그룹:사용자 권한 문제
아래와 같은 명령어로 해결할 수 있다.

# chown nginx:nginx /var/run/php-fpm/php-fpm.sock

다른 분들 고생 안했으면 좋겠다.

2018. 6. 15.

아이맥, 맥북, 맥 부팅이 느려질 때 해결방법

아이맥, 맥북, 맥 부팅이 느려질 때 해결방법

2013 late 아이맥을 사용하고 있는데 high sierra로 올리고 난 다음 부터 부팅 시동음이 울릴때까지 2,3분이 걸린다.

그 해결책으로 여러가지를 검색 해 본 결과 아래와 같은 방법을 적용해 보라고 한다.

  1. Shutdown the computer, wait 30 seconds, restart the computer.
  2. Resetting your Mac’s PRAM and NVRAM
  3. Reset the System Management Controller (SMC)
  4. Start the computer in Safe Mode, then restart normally. This is slower than a standard startup.
  5. Repair the disk by booting from the Recovery HD. Immediately after the chime hold down the Command and R keys until the Utility Menu appears. Choose Disk Utility and click on the Continue button. Select the indented (usually, Macintosh HD) volume entry from the side list. Click on the First Aid button in the toolbar. Wait for the Done button to appear. Quit Disk Utility and return to the Utility Menu. Restart the computer from the Apple Menu.
  6. Create a New User Account Open Users & Groups preferences. Click on the lock icon and enter your Admin password when prompted. On the left under Current User click on the Add [+] button under Login Options. Setup a new Admin user account. Upon completion log out of your current account then log into the new account. If your problems cease, then consider switching to the new account and transferring your files to it - Transferring files from one User Account to another.
  7. Download and install theOS X El Capitan 10.11.6 ComboUpdate or 10.12.6 Combo Update or macOS High Sierra 10.13.2 Combo Update as needed.
  8. Reinstall OS X by booting from the Recovery HD using the Command and R keys. When the Utility Menu appears select Reinstall OS X then click on the Continue button.
  9. Erase and Install OS X Restart the computer. Immediately after the chime hold down the CommandandRkeys until the Apple logo appears. When the Utility Menu appears:
  10. 개발자 포럼에서 sudo trimforce diasble을 적용하면 빨라진다는 말이 있다.

본인은 일단 다 했봤는데, 재부팅은 빨라졌다. 첫 구동 할때는 느림. 그래도 재시작이 빨라져서 너무 좋다.