우분투 14.04 apache2, php5, mysql 설치
웹서버 설치하고 php5 사용할 수 있게 하고, mysql도 사용할 수 있게하려면... apt-get 몇 번 하면 되겠습니다용~
1. apache2 설치
$ sudo apt-get install apache2
설치하고나서, 파이어폭스나 크롬 브라우저에서 http://localhost 를 입력해 봅니다. 이때, 기본 웹페이지가 뜨면 정상적으로 설치된 것입니다용.
아래처럼....
This is the default welcome page used to test the correct operation of the Apache2 server after installation on Ubuntu systems. It is based on the equivalent page on Debian, from which the Ubuntu Apache packaging is derived. If you can read this page, it means that the Apache HTTP server installed at this site is working properly. You should replace this file (located at /var/www/html/index.html) before continuing to operate your HTTP server.
If you are a normal user of this web site and don't know what this page is about, this probably means that the site is currently unavailable due to maintenance. If the problem persists, please contact the site's administrator.
Ubuntu's Apache2 default configuration is different from the upstream default configuration, and split into several files optimized for interaction with Ubuntu tools. The configuration system is fully documented in /usr/share/doc/apache2/README.Debian.gz. Refer to this for the full documentation. Documentation for the web server itself can be found by accessing the manual if the apache2-doc package was installed on this server.
The configuration layout for an Apache2 web server installation on Ubuntu systems is as follows:
/etc/apache2/ |-- apache2.conf | `-- ports.conf |-- mods-enabled | |-- *.load | `-- *.conf |-- conf-enabled | `-- *.conf |-- sites-enabled | `-- *.conf
- apache2.conf is the main configuration file. It puts the pieces together by including all remaining configuration files when starting up the web server.
- ports.conf is always included from the main configuration file. It is used to determine the listening ports for incoming connections, and this file can be customized anytime.
- Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ directories contain particular configuration snippets which manage modules, global configuration fragments, or virtual host configurations, respectively.
- They are activated by symlinking available configuration files from their respective *-available/ counterparts. These should be managed by using our helpers a2enmod, a2dismod, a2ensite, a2dissite, and a2enconf,a2disconf . See their respective man pages for detailed information.
- The binary is called apache2. Due to the use of environment variables, in the default configuration, apache2 needs to be started/stopped with /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not work with the default configuration.
By default, Ubuntu does not allow access through the web browser to any file apart of those located in /var/www,public_html directories (when enabled) and /usr/share (for web applications). If your site is using a web document root located elsewhere (such as in /srv) you may need to whitelist your document root directory in/etc/apache2/apache2.conf.
The default Ubuntu document root is /var/www/html. You can make your own virtual hosts under /var/www. This is different to previous releases which provides better security out of the box.
Please use the ubuntu-bug tool to report bugs in the Apache2 package with Ubuntu. However, check existing bug reports before reporting a new bug.
Please report bugs specific to modules (such as PHP and others) to respective packages, not to the web server itself.
2. mySql 설치
웹개발시에 사용할 데이터베이스로 mysql을 사용할거니까, mysql 을 설치합니다.
$ sudo apt-get install mysql-server php5-mysql
설치 중에 mysql 데이터베이스를 관리할 root의 암호를 물어봅니다. 우분투의 root 계정을 의미하는것이 아닙니다. 입력하고 잘 기억해놓으세요.
php5-mysql 패키지는 php5와 mysql을 연동시키기 위해서 필요한 패키지랍니다. 함께 설치를 합시다.
설치가 되고 나면, 몇 가지 설정을 해줍니다.
mysql 이 관련 정보를 저장할 테이블도 만들고 디렉토리도 구성하도록 해 준답니다. 아래처럼 먼가 잔뜩 나오네요.
Installing MySQL system tables...
141027 19:17:24 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
OK
Filling help tables...
141027 19:17:24 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h RYU-UBUNTU password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
그 다음, mysql을 설치했을 때의 기본 설정으로 인한 보안상 취약점들을 수정할 스크립트를 실행해줍니다.
묻는 말에 적절히 대답하면 됩니다.
ryu@RYU-UBUNTU:/usr/bin$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] n
... skipping.
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
... 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
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- 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...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
ryu@RYU-UBUNTU:/usr/bin$
3. php 설치
이제 웹 개발에 사용할 스크립트 언어 php를 설치합니다.
$ sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
별문제 없이 설치가 됩니다.
여기서도 잠깐 설정을 수정하는 작업을 합니다.
apache2 서버가 웹 페이지를 표시할 때, 디렉토리에서 index.html을 가장 먼저 찾도록 되어 있습니다.
어디에 그렇게 설정이 되어있느냐.....하면, /etc/apache2/mods_enabled/dir.conf 에 그렇게 되어있답니다.
파일을 열어보면, 아래처럼 디렉토리 인덱스가 순서대로 적혀있습니다.
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml inde$
</IfModule>
아파치 설정이 바뀌었으니, 재시작을 해줘야겠네요.
$ sudo service apache2 restart
필요에 따라서 php5 에 추가로 모듈들을 설치를 할 수 있습니다.
어떤 모듈들이 있는지 살펴보려면 아래처럼 입력하면 됩니다.
$ apt-cache search php5-
모듈들이 쫙~ 나오면 살펴보고 설치하면 되겠습니다.
하나의 모듈에 대해서 더 자세히 알아보려면 아래 명령을 입력하면 됩니다.
$ apt-cache show [php 모듈명]
설치할 때는
$ sudo apt-get install [php 모듈명]
이제 얼추 설치가 된 듯 하네요.
4. php가 잘 동작하나 테스트하기
apache 를 설치하고 잘 동작하는지 확인할 때, 브라우저에 나타난 파일은 아래 위치에 있는 index.html 입니다.
/var/www/html/index.html
/var/www/html/ 디렉토리가 현재 웹서버의 루트 디렉토리이지요.
그럼, 루트 디렉토리에 php파일을 하나 만들어서 php 스크립트도 잘 동작하는지 확인해 봅시다.
터미널이든 GUI든.. /var/www/html 디렉토리로 가서 phpinfo.php 파일을 만듭시다.
파일 내용은 아래와 같이 작성하고 저장을 합시다.
/var/www/html 디렉토리가 root 권한이네요. sudo nano phpinfo.php 라고 해서 입력을 해 줍시다.
<?php
phpinfo();
?>
저장을 했으면 브라우저에서 다시 http://localhost/phpinfo.php 를 입력해 봅시다.
PHP Version 5.5.9-1ubuntu4.4 |
이렇게 시작이 되어서 아래로 길게 표로 뭔가 나오면 phpinfo.php가 잘 실행된 것입니다.
아래로 길게 표로 표시된 것들은 현재 웹서버와 관련된 여러 설정내용들입니다. 한번 쭉~ 살펴보는 것도 좋겠습니다.
나중에 혹시 수정하게 될지도 모를 php 의 설정파일의 위치도 표시되어있습니다.
/etc/php5/apache2/php.ini
php가 잘 동작하는 것을 확인했으니, phpinfo.php 파일은 삭제해줍시다.
이상! 우분투 14.04 에서 apache2, php5, mysql 을 설치해봤습니다.
끝!
'우분투' 카테고리의 다른 글
[우분투] 14.04에서 서버에 도메인 네임 추가하기 (0) | 2014.10.28 |
---|---|
[우분투] 14.04에서 bind9 이용해 DNS 설치하기 (2) | 2014.10.28 |
[우분투] 14.04에서 apache2 루트 디렉토리 변경하기 (2) | 2014.10.28 |
[우분투] 우분투 14.04 LTS 설치 (0) | 2014.10.27 |
[우분투] php curl 설치 (1) | 2014.10.24 |
댓글