51
51

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ubuntu 12.04でLAMP環境を構築する

Last updated at Posted at 2012-12-26

Ubuntu 12.04にApache, MySQL, PHP, PHPMyAdminを導入してPHPアプリケーションを構築できる環境を整える手順書。

1.MySQL

1.1.インストール

Bash
$ sudo apt-get install mysql-server

1.2.文字コード設定

Bash
$ sudo vim /etc/mysql/my.conf
  # 以下の行を追加
  [mysqld]
  character-set-server=utf8
  skip-character-set-client-handshake

1.3.ユーザ設定

Bash
$ mysql -u root
  # rootのセキュリティ設定
  mysql > DELETE FROM mysql.user WHERE user = "" OR host = "::1";
  mysql > SET PASSWORD FOR root@localhost = PASSWORD("password");
  mysql > SET PASSWORD FOR root@127.0.0.1 = PASSWORD("password");
  # 新規ユーザの追加
  mysql > GRANT ALL PRIVILEGES ON db.* TO user@localhost IDENTIFIED BY "password";

2.Apache

2.1.インストール

Bash
$ sudo apt-get insall apache2

2.2.最低限設定

Bash
# mode_rewriteを有効化
$ sudo a2enmod rewrite

# .htaccessを有効化
$ sudo vim /etc/apache2/sites-enabled/000-default
  # 以下の部分を修正
  <Directory /var/www/>
    AllowOverride All
  </Directory>

2.3.動作確認

http://localhost/にアクセスして以下のような画面が確認できれば成功。
apache

3.PHP

3.1.インストール

Bash
$ sudo apt-get install php5

3.2.モジュール設定

Bash
# MySQLモジュールを追加
# MySQL連携のために必要
$ sudo apt-get install php5-mysql

# cURLモジュールを追加
# Facebook PHP SDKのために必要
$ sudo apt-get install php5-curl

3.3.動作確認

Bash
$ sudo mv /var/www/index.html /var/www/index.php
$ sudo vim /var/www/index.php
  # 以下の内容に書き換え
  <?php
    phpinfo();

http://localhost/にアクセスして以下のような画面が確認できれば成功。
phpinfo

4.PHPMyAdmin

4.1.インストール

Bash
$ sudo apt-get install phpmyadmin

4.2.動作確認

http://localhost/にアクセスして以下のような画面が確認できれば成功。
phpmyadmin

51
51
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
51
51

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?