티스토리 뷰
Ubuntu 에서 간단하게 apt를 이용하여 nginx 와 php를 설치하는 방법입니다.
apt 를 이용함으로 기본적으로 root 사용자를 이용합니다.
1. nginx 설치
$apt-get install nginx
설치하셨다면 IP로 http 접속시 아래와 같은 화면을 보실수 있으실것입니다.
nginx 의 버전 체크는
$nginx -v
로 확인하실수 있습니다.
2. php-fpm 설치하기
php 역시 빠르게 설치하기위해 apt-get install 을 이용하여 설치해 주도록합니다.
$apt-get install php5-fpm
3. nginx 설정 및 php 연동하기
nginx 를 설정하여 php를 연결할 차례 입니다. 아래와 같이 /etc/nginx/sites-available/default 를 열어 수정하도록 합니다.
$vim /etc/nginx/sites-available/default
일단 기본 주소를 이용하기때문에 index에 index.php 를 추가해주시고 root 를 변경 후 php 부분의 주석을 제거해주도록 합니다.
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; #default root /var/www/; #Your root directory index index.php index.html index.htm; # ADD index.php # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests #location /RequestDenied { # proxy_pass http://127.0.0.1:8080; #} #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 /usr/share/nginx/html; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
이제 php파일을 만들어 주도록합니다. 위의 설정에서 root /var/www/ 에서 보다시피 저는 root를 /var/www/ 에 연결 하였기 때문에 해당 폴더로 이동 혹은 생성하여 index.php 를 생성하여 주도록 합니다.
$cd /var $mkdir www $chown user:user www $cd www/ $vim index.php
파을을 생성하고 아래와 같이 php 정보를 읽는 코드를 써줍니다.
<?php phpinfo(); ?>
이제 저장 후 index.php 의 권한을 다시 user 로 설정 그리고 nginx 를 reload 혹은 restart 해주도록 합니다.
$chown user:user ./index.php $service nginx reload
이제 이전에 nginx 를 테스트 하였던 페이지로 이동하여 phpinfo() 를 통해 만들어진 정보 페이지를 확인합니다.
위와 같이 php 의 정보를 보여주는 페이지가 뜬다면 php 를 개발할수 있는 기본적인 환경이 완료된 것 입니다.
'Dev WEB > WAS Tips' 카테고리의 다른 글
Let's encrypt 를 이용하여 Nginx 서버에서 무료 HTTPS 지원하기 (0) | 2016.02.19 |
---|---|
NginX 웹페이지에 비밀번호 ( 보안 ) 설정하기 (0) | 2015.04.30 |
Ubuntu 에서 NginX + PHP-FPM 연동하기 (0) | 2015.03.08 |
Ubuntu (Linux) + Apache + Mysql + PHP (LAMP) 셋팅하기 (0) | 2015.03.02 |
Ubuntu 14.04 에 Jetty 9 설치하기 (0) | 2015.03.02 |
- Total
- Today
- Yesterday
- Nodejs
- 데이터베이스
- SNS
- 튜토리얼북
- mac
- JavaScript
- 우분투
- 서버 개발
- 개발자
- it
- 서버
- 맥
- 게임 개발
- cocos2d-x
- 인터넷
- 웹 개발자
- 개발
- html
- ubuntu
- Developer
- php
- Database
- Laravel
- 웹 서버
- 설치
- 웹 개발
- 게임
- 웹
- Tutorialbook
- 에러
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |