カテゴリー別アーカイブ: Mac OS X

Mac OS X Apache (httpd) が起動しなくなったときの対処法

以下のコマンドを実行します.

$ sudo /usr/sbin/httpd -D FOREGROUND
$ sudo /usr/sbin/apachectl start

もし

No such file or directory: httpd: could not open error log file /private/var/log/apache2/error_log

とエラーが出た場合は

$ mkdir -p /private/var/log/apache2
$ touch /private/var/log/apache2/error_log

を作成しておきます.

$ ps aux | grep httpd

と実行して,

_www               856   0.0  0.1  2478336   4784   ??  S     1:02PM   0:00.01 /usr/sbin/httpd -D FOREGROUND
_www               855   0.0  0.0  2478080   2268   ??  S     1:02PM   0:00.02 /usr/sbin/httpd -D FOREGROUND
_www               853   0.0  0.0  2478080   2260   ??  S     1:02PM   0:00.03 /usr/sbin/httpd -D FOREGROUND
_www               849   0.0  0.1  2478336   5088   ??  S     1:02PM   0:00.04 /usr/sbin/httpd -D FOREGROUND
_www               848   0.0  0.0  2478080   2268   ??  S     1:02PM   0:00.02 /usr/sbin/httpd -D FOREGROUND
_www               847   0.0  0.0  2478336   4152   ??  S     1:02PM   0:00.03 /usr/sbin/httpd -D FOREGROUND
_www               844   0.0  0.1  2478336   5004   ??  S     1:02PM   0:00.09 /usr/sbin/httpd -D FOREGROUND
root               843   0.0  0.1  2478080  10480   ??  Ss    1:02PM   0:00.32 /usr/sbin/httpd -D FOREGROUND
rilakkuma3xjapan   942   0.0  0.0  2432784    604 s000  S+    2:02PM   0:00.00 grep httpd

のように表示されていればOKです.

Vagrant + CentOSのローカル開発環境構築 (Mac OS X)

1. VagrantをインストールするにはVirtualBoxが必要になるので先にインストールしておきます.

Downloads – Oracle VM VirtualBox
Downloads – Oracle VM VirtualBox

2. Vagrantをインストールします.

Vagrant
Vagrant
Download Vagrant
Download Vagrant

3. Vagrant + CentOSの開発用ディレクトリの作成

Vagrantを起動するためのディレクトリを作成して移動しておきます. さらに, CentOSのためのディレクトリを作成して移動しておきます.

$ mkdir vagrant && cd vagrant && mkdir centos && cd centos

4. Vagrantの初期化

作成 & 移動したディレクトリで以下のコマンドを実行します.

$ vagrant init chef/centos-6.5

5. Vagrant設定ファイルの編集

Vagrantを初期化すると, そのディレクトリにVagrantfileという設定ファイルが作成されるので, それをちょこっと編集します.

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "chef/centos-6.5"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <

29行目あたりの「# config.vm.network “private_network”, ip: “192.168.33.10”」をコメントアウト 「config.vm.network “private_network”, ip: “192.168.33.10”」して保存します.

6. CentOSの起動

以下のコマンドで起動します.

$ vagrant up

7. 開発環境にログイン

開発環境 (Vagrantを利用したCentOS) にログインするには,

$ vagrant ssh

を実行します.

あとは, Apacheのインストールなり, PHP, MySQLのインストールなりお好きにどうぞ.

8. ログアウト & CentOSの停止

Vagrantを利用したCentOSからログアウトするには,

[vagrant@localhost ~]$ exit

を実行します.

そして, PCのシャットダウンなどで, CentOSを停止するには,

$ vagrant suspend

を実行します.