오드로이드
설치 분류

오드로이드 U2, U3 웹서버 (Nginx + PHP5 + Mysql) 설치 가이드

컨텐츠 정보

본문

1. 들어가며


이제 본격적으로 홈페이지 구동을 위한 웹서버 설치에 대하여 적어보겠습니다.


기본적으로 우분투에서 설치하는 방법과 같기 때문에 기타 다른 사이트에서 설치하는 방법으로 하셔도


큰 차이는 없습니다.



그래도 오드로이드에 최적화된 가이드가 필요할 것 같아 작성합니다.



전 시작을 Nginx로 해서 아파치는 잘 모릅니다.


Apache2도 좋지만, 그냥 Nginx가 집과 같은 편안한 그런 느낌이랄까요 ㅎㅎ


Nginx + Php5 + Mysql을 차례대로 설치할 것입니다.


MariaDB가 궁금해서 찾아봤더니 14.04 LTS 버전에서 패키지로 제공될 것 같군요.



다만 오드로이드 U2, U3 이미지로는... 14.04 버전이 나올지 의문입니다.


사용자가 생각보다 적어서 개발자가 포팅을 할지 모르겠네요.



2. Nginx 설치하기


apt-get install nginx


위 명령어로 설치하면 됩니다.



root@odroid-server:~# apt-get install nginx

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

  geoip-database libgd2-noxpm libgeoip1 libjpeg-turbo8 libjpeg8 libxslt1.1

  nginx-common nginx-full

Suggested packages:

  libgd-tools geoip-bin

The following NEW packages will be installed:

  geoip-database libgd2-noxpm libgeoip1 libjpeg-turbo8 libjpeg8 libxslt1.1

  nginx nginx-common nginx-full

0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.

Need to get 2259 kB/2346 kB of archives.

After this operation, 7195 kB of additional disk space will be used.

Do you want to continue [Y/n]?

.

.

.

Setting up geoip-database (20130213-1) ...

Setting up libgeoip1:armhf (1.4.8+dfsg-4) ...

Setting up libjpeg-turbo8:armhf (1.2.1-0ubuntu2) ...

Setting up libxslt1.1:armhf (1.1.27-1ubuntu2) ...

Setting up libjpeg8:armhf (8c-2ubuntu7) ...

Setting up libgd2-noxpm:armhf (2.0.36~rc1~dfsg-6.1ubuntu1) ...

Setting up nginx-common (1.2.6-1ubuntu3) ...

Processing triggers for ureadahead ...

Setting up nginx-full (1.2.6-1ubuntu3) ...

Setting up nginx (1.2.6-1ubuntu3) ...

Processing triggers for libc-bin ...

ldconfig deferred processing now taking place

root@odroid-server:~#



위와 같이 설치됩니다.




nginx -V


위 명령어로 어떤 모듈이 설치되어있는지 볼 수 있습니다.



nginx version: nginx/1.2.6 (Ubuntu)

TLS SNI support enabled

configure arguments: --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --

error-log-path=/var/log/nginx/error.log --http-client-body-temp-

path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-

path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-

scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --

lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --with-pcre-jit --with-debug 

--with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-

http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --

with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-

http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-

md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-

module=/build/buildd/nginx-1.2.6/debian/modules/nginx-auth-pam --add-

module=/build/buildd/nginx-1.2.6/debian/modules/nginx-echo --add-

module=/build/buildd/nginx-1.2.6/debian/modules/nginx-upstream-fair --add-

module=/build/buildd/nginx-1.2.6/debian/modules/nginx-dav-ext-module



현재 안정화 버전이 1.4.7인데 약간 낮은 버전이지만 실사용에는 전혀 문제가 없습니다. 


dav모듈도 있고 필요한 모듈은 다 들어있습니다.



service nginx start


위 명령어를 내려 서비스 시작을 하고,


인터넷 브라우저에 가서 오드로이드의 내부IP를 넣으면


Welcome to nginx!


If you see this page, the nginx web server is successfully installed and working. 


Further configuration is required.


For online documentation and support please refer to nginx.org.

Commercial support is available at nginx.com.


Thank you for using nginx.


위와 같은 글이 나옵니다.



3. Mysql 설치하기


apt-get install mysql-server mysql-client


처음에 root 유저에 대한 암호를 물어봅니다. 두번 넣으면 됩니다.



root@odroid-server:~# apt-get install mysql-server mysql-client

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

  libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18

  libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5

  mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5

Suggested packages:

  libipc-sharedcache-perl tinyca mailx

The following NEW packages will be installed:

  libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18

  libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client

  mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server

  mysql-server-5.5 mysql-server-core-5.5

0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.

Need to get 25.1 MB of archives.

After this operation, 84.9 MB of additional disk space will be used.

Do you want to continue [Y/n]?

.

.

.

Setting up libaio1:armhf (0.3.109-3) ...

Setting up libmysqlclient18:armhf (5.5.29-0ubuntu1) ...

Setting up libnet-daemon-perl (0.48-1) ...

Setting up libplrpc-perl (0.2020-2) ...

Setting up libdbi-perl (1.622-1) ...

Setting up libdbd-mysql-perl (4.021-1) ...

Setting up mysql-client-core-5.5 (5.5.29-0ubuntu1) ...

Setting up libterm-readkey-perl (2.30-4build4) ...

Setting up mysql-client-5.5 (5.5.29-0ubuntu1) ...

Setting up mysql-server-core-5.5 (5.5.29-0ubuntu1) ...

Setting up mysql-server-5.5 (5.5.29-0ubuntu1) ...

mysql start/running, process 4124

Setting up libhtml-template-perl (2.91-1) ...

Setting up mysql-client (5.5.29-0ubuntu1) ...

Processing triggers for ureadahead ...

Setting up mysql-server (5.5.29-0ubuntu1) ...

Processing triggers for libc-bin ...

ldconfig deferred processing now taking place

root@odroid-server:~#



위와 같이 설치됩니다.




4. Php5 설치하기


apt-get install php5-fpm


위 명령어로 먼저 fpm을 설치합니다.


root@odroid-server:~# apt-get install openssl

Reading package lists... Done

Building dependency tree

Reading state information... Done

openssl is already the newest version.

openssl set to manually installed.

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

root@odroid-server:~# apt-get install php5-fpm

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

  php5-common psmisc

Suggested packages:

  php-pear

The following NEW packages will be installed:

  php5-common php5-fpm psmisc

0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.

Need to get 4345 kB of archives.

After this operation, 9058 kB of additional disk space will be used.

Do you want to continue [Y/n]?

.

.

.

Setting up psmisc (22.20-1ubuntu2) ...

Setting up php5-common (5.4.9-4ubuntu2) ...


Creating config file /etc/php5/mods-available/pdo.ini with new version

Setting up php5-fpm (5.4.9-4ubuntu2) ...


Creating config file /etc/php5/fpm/php.ini with new version

Processing triggers for ureadahead ...

root@odroid-server:~#


위와 같이 설치됩니다.



apt-get install php5-cli php5-mcrypt php5-gd php5-curl


위 명령어로 추가로 필요한 패키지들을 설치합니다.



root@odroid-server:~# apt-get install php5-cli php5-mcrypt php5-gd php5-curl

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

  libgd2-xpm libmcrypt4

Suggested packages:

  libgd-tools libmcrypt-dev mcrypt php-pear

The following packages will be REMOVED:

  libgd2-noxpm

The following NEW packages will be installed:

  libgd2-xpm libmcrypt4 php5-cli php5-curl php5-gd php5-mcrypt

0 upgraded, 6 newly installed, 1 to remove and 0 not upgraded.

Need to get 2493 kB/2682 kB of archives.

After this operation, 6717 kB of additional disk space will be used.

Do you want to continue [Y/n]?

.

.

.

Setting up php5-cli (5.4.9-4ubuntu2) ...


Creating config file /etc/php5/cli/php.ini with new version

update-alternatives: using /usr/bin/php5 to provide /usr/bin/php (php) in auto mode

Setting up php5-curl (5.4.9-4ubuntu2) ...


Creating config file /etc/php5/mods-available/curl.ini with new version

Setting up php5-gd (5.4.9-4ubuntu2) ...


Creating config file /etc/php5/mods-available/gd.ini with new version

Setting up libmcrypt4 (2.5.8-3.1) ...

Setting up php5-mcrypt (5.4.6-0ubuntu1) ...

Processing triggers for php5-fpm ...

 * Restarting PHP5 FastCGI Process Manager php5-fpm                      [ OK ]

Processing triggers for libc-bin ...

ldconfig deferred processing now taking place

root@odroid-server:~#



위와 같이 설치가 됩니다.



apt-get install php5-mysql


위 명령어로 php와 mysql과 연동할 수 있습니다.



root@odroid-server:~# apt-get install php5-mysql

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following NEW packages will be installed:

  php5-mysql

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 63.4 kB of archives.

After this operation, 183 kB of additional disk space will be used.

WARNING: The following packages cannot be authenticated!

  php5-mysql

Authentication warning overridden.

Get:1 http://ports.ubuntu.com/ubuntu-ports/ raring/main php5-mysql armhf 5.4.9-


4ubuntu2 [63.4 kB]

Fetched 63.4 kB in 2s (31.3 kB/s)

Selecting previously unselected package php5-mysql.

(Reading database ... 31340 files and directories currently installed.)

Unpacking php5-mysql (from .../php5-mysql_5.4.9-4ubuntu2_armhf.deb) ...

Processing triggers for php5-fpm ...

 * Restarting PHP5 FastCGI Process Manager php5-fpm                      [ OK ]

Setting up php5-mysql (5.4.9-4ubuntu2) ...


Creating config file /etc/php5/mods-available/mysql.ini with new version


Creating config file /etc/php5/mods-available/mysqli.ini with new version


Creating config file /etc/php5/mods-available/pdo_mysql.ini with new version

Processing triggers for php5-fpm ...

 * Restarting PHP5 FastCGI Process Manager php5-fpm                      [ OK ]

root@odroid-server:~#



위와 같이 설치됩니다.



5. Nginx와 php5-fpm과 연동하기


nano /etc/nginx/sites-available/default


위 명령어로 nginx 설정파일로 들어갑니다.


대략 45번째 줄에



location ~ \.php$ {            

            fastcgi_pass   unix:/var/run/php5-fpm.sock;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            include        fastcgi_params;

}


위 내용을 붙여넣습니다.



저장 후 빠져나옵니다. (컨트롤 + O , 엔터, 컨트롤 + X)




nano /etc/php5/fpm/pool.d/www.conf


위 명령으로 php5-fpm 설정으로 들어갑니다.



33번째 줄에


listen = /var/run/php5-fpm.sock


위와 같이 되어 있는지 확인합니다.


똑같으면 바로 빠져나옵니다. (컨트롤 + X)


변경했다면 저장 후 빠져나옵니다. (컨트롤 + O , 엔터, 컨트롤 + X)



그리고 보안 관련 설정을 추가해줍니다.


nano /etc/nginx/fastcgi_params


위 명령어로 설정에 들어가서



fastcgi_split_path_info ^(.+\.php)(/.*)$;

fastcgi_param  PATH_INFO          $fastcgi_path_info if_not_empty;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;


위 내용을 마지막 줄에 추가하여 저장 후 빠져나옵니다. (컨트롤 + O , 엔터, 컨트롤 + X)



그리고 클린 URL을 이용한 비정상적인 접근 제한을 위하여


http://www.wsgvet.com/bbs/board.php?bo_table=web&wr_id=77


위 링크대로 변경 후 빠져나옵니다.



마지막으로



service php5-fpm restart


service nginx restart


위 두명령어로 서비스를 재시작합니다.



root@odroid-server:~# service php5-fpm restart

 * Restarting PHP5 FastCGI Process Manager php5-fpm                      [ OK ]

root@odroid-server:~# service nginx restart

 * Restarting nginx nginx                                                [ OK ]

root@odroid-server:~#



위와 같이 OK가 두번 뜨면 정상입니다.



※ Nginx 및 php 부분은 http://webdir.tistory.com/240 여기서 많은 도움을 받았습니다.

관련자료

댓글 6

통쾌상퀘님의 댓글

php5.2.17 버전을 설치 하고 싶은데 오드로이드에서 가능할까요? 이글에 나온 php버전이 너무 높아서요..

우성군님의 댓글의 댓글

임의대로 설치하시려면 패키지 파일 받아서 하면 될 것 같기도 하지만...

의존성 때문에 골치아플 것 같네요.

우성군님의 댓글의 댓글

아톰보다는 느릴 것 같네요.

장점는 무소음이구요.

트랜스미션 속도가 기억이 안나는데...

외장하드 끼우면 10MB/s는 나올거예요.

h5ai로 파일서버 쓰면 될 것 같구요.

다만 최소 J1900정도로 자작하는 것을 추천드립니다.
설치 11 / 1 페이지
RSS

최근글


새댓글


알림 0