LoginSignup
0
0

More than 5 years have passed since last update.

AWS EC2上でhttpdとphpの設定手順忘備録

Last updated at Posted at 2018-12-17

Appach&php on AWS EC2 設定

準備

  • EC2 VPC+InternetGWの中につくる

ホスト名の設定:リモートログイン

  • sshでログイン ssh -i ***.pem ec2-usr@xxx.xxx.xxx.xxx (パブリックIPでログイン)
  • ホスト名を設定する(1) sudo nano /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=xxxxx-xxxxxx-aws-web-1a
NOZEROCONF=yes
  • ホスト名を設定する(2) sudo nano /etc/hosts
127.0.0.1   xxxxxx-xxxxxxx-aws-web-1a localhost localhost.localdomain localhost4 $
::1         localhost6 localhost6.localdomain6
  • ここで一旦、リブート sudo reboot

言語・日時の設定:再度リモートログイン

  • ssh -i ***.pem ec2-usr@xxx.xxx.xxx.xxx (パブリックIP)
    • ログインするとプロンプトに設定したホスト名が表示される
  • 日本語の設定 sudo nano /etc/sysconfig/i18n
LANG=ja_JP.UTF-8
  • 時間の設定(1) sudo cp /usr/share/zoneinfo/Japan /etc/localtime
  • 時間の設定(2) sudo nano /etc/sysconfig/clock
ZONE="Asia/Tokyo"
UTC=true
  • 日時合わせの確認 date

ミドルウェアの設定

  • システムのアップデート sudo yum update -y
  • appachのインストール sudo yum install -y httpd24
  • php70関係のインストール sudo yum install -y php70 php70-mbstring php70-pdo php70-mysqlnd
  • MySQLのインストール sudo yum install -y mysql
  • Gitのインストール sudo yum install -y git

Appachの設定

  • 設定ファイルの編集 sudo nano /etc/httpd/conf/httpd.conf

    • DirectoryIndexに index.phpを最優先で追加
    • ServerNameにxxxxxx-xxxxxxx-aws-web-1aを設定
  • 設定ファイルの確認 sudo /etc/init.d/httpd configtest

  • 自動起動の設定 sudo chkconfig httpd on

  • Appachの起動 sudo service httpd start

phpの設定

  • 設定ファイルの編集 sudo nano /etc/php.ini
  • Dynamic extensionとmbstringの部分に追記
    • extension=mbstring
    • mbstring.language = Japanese
    • mbstring.internal_encoding = UTF-8
0
0
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
0
0