Shammer's Philosophy

My private adversaria

Install PHP5

I got a new VM yesterday, so I tried to install apache2 and php5. It is very easy.

  1. apt-get install apache2
  2. apt-get install php5
  3. configure php5
  4. restart apache2
  5. php test

Install apache2 and php5

This is very simple. Exec following commands.

  • apt-get update
  • apt-get install apache2
  • apt-get install php5

The command "apt-get update" may not be required, but sometimes apt-get returns error because apt source informations are old. If apt-get returned error such messages, exec apt-get update and makes apt source newer.

configure php5

Edit /etc/php5/apache2/php.ini. Taking a backup before modify php.ini is recommended.
I referenced Debian PHP5のインストールと設定.

# diff php.ini php.ini.default 
174c174
< short_open_tag = Off
---
> ; short_open_tag
1714c1714
< mbstring.language = Japanese
---
> ;mbstring.language = Japanese
1720c1720
< mbstring.internal_encoding = UTF-8
---
> ;mbstring.internal_encoding = EUC-JP
1724c1724
< mbstring.http_input = auto
---
> ;mbstring.http_input = auto
1729c1729
< mbstring.http_output = UTF-8
---
> ;mbstring.http_output = SJIS
1737c1737
< mbstring.encoding_translation = On
---
> ;mbstring.encoding_translation = Off
1742c1742
< mbstring.detect_order = auto
---
> ;mbstring.detect_order = auto
1747c1747
< mbstring.substitute_character = none;
---
> ;mbstring.substitute_character = none;
1758c1758
< mbstring.func_overload = 0
---
> ;mbstring.func_overload = 0

Apache2 restart by /etc/init.d/apache2 restart after modify php.ini.

Test php

Create phptest.php as the following.

<?php
	phpinfo();
?>

And access http://$HOST/phptest.php. If php running fine, php displays environment informations.