티스토리 뷰

Ubuntu 에서 Apache, Mysql, PHP 를 간단하게 셋팅하는 방법입니다.


1. Apache2 설치하기

$ apt-get update
$ apt-get install apache2

이제 ip를 학인 후 주소창에 ip를 써주시고 아래와 같은 창을 볼수 있으시면 정상적으로 설치 된것을 의미 합니다.






2. Mysql 설치 및 셋팅하기

$ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql


혹시 Mysql  관련 보안 설정이 필요 하신분은 아래의 스크립트를 실행하여 보시기 바랍니다. 알아 두셔야 할 점은 기본설치시 아래의 보안 사항들은 거의 기본적으로 적용되어 있습니다.

$ sudo mysql_install_db
$ sudo /usr/bin/mysql_secure_installation

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y                                            
 #익명의 사용자를 삭제 하시겠습니까? 
... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
root 의 원격 로그인을 막겠습니까?
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
test 데이터베이스를 제거하시겠습니까?
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
테이블 권한을 다시 로드 하시겠습니까?
 ... Success!

Cleaning up...


3. PHP 설치하기


전의 과정과 마찬가지로  apt-get  을 이용하여 간단하게 설치합니다.

$ sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt


PHP 를 적용하기 위해 아래와 같이 dir.conf 를 수정합니다.

$ sudo vim /etc/apache2/mods-enabled/dir.conf


<IfModule mod_dir.c>
        DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


3.1 PHP 모듈 설정 ( 필요하다면 )

PHP 의 모듈은 아래와 같이 apt-cache search 를 통하여 검색이 가능합니다.

$ apt-cache search php5-모듈명

또한 아래와 같은 명령으로 설치가 가능합니다.
$ apt-get install php5-모듈명


4. 셋팅 테스트해보기

apache2 설치시 default 설정을 수정해서 아래와 같은 php 파일을 만들어 줍니다.

$vim /var/www/html/phpinfo.php


그리고 아래와 같은 코드를 입력하여 줍니다.

<?php 
     phpinfo();
?>


그리고 이전에 테스트 했던것과 같은 페이지로 이동하여 phpinfo.php 를 입력해주시면 아래와 같이 php 정보가 보이는 페이지를 만드신 것을 확인 하실 수 있습니다.






공유하기 링크
댓글