Skip to content

Instantly share code, notes, and snippets.

@hakopako
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakopako/9935376 to your computer and use it in GitHub Desktop.
Save hakopako/9935376 to your computer and use it in GitHub Desktop.
VMの環境を手動で構築する手順

box

$ vagrant box add centos-6.4 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box
$ vagrant init
$ vi VagrantFile


config.vm.network :private_network, ip: "192.168.33.10"
-> config.vm.network :private_network, ip: "hogehoge(別に変えなくてもいい)"


$ vagrant up

yum epel remi

$ sudo yum -y update
$ sudo wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ sudo wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
$ sudo rpm --upgrade --verbose --hash epel-release-6-8.noarch.rpm remi-release-6.rpm
$ sudo vi /etc/yum.repos.d/remi.repo


enabled=1 #これを 0 -> 1へ


apache

$ sudo yum -y install httpd httpd-devel
$ sudo vi /etc/httpd/conf/httpd.conf


ServerTokens OS
→ServerTokens Prod
エラーページでOS名を表示させない

#ServerName www.example.com:80
→ServerName localhost:80

AllowOverride None

→ AllowOverride All
.htaccessの使用を許可させる。.htaccessでbasic認証とかの設定などが使えるのでここは許可するように変更しておきます。

#ErrorLog logs/error_log
→ErrorLog "|/usr/sbin/rotatelogs -l /var/log/httpd/error_log_%Y_%m%d 86400"
エラーログを日付ごとにローテーションしてログにとります。

LogFormatの記述の下に

SetEnvIf Request_URI ".(gif)|(jpg)|(png)$" no_log
SetEnvIf Remote_Addr 192.168.0. no_log
と記述してcustomlogを

CustomLog logs/access_log_ combined
→CustomLog "|/usr/sbin/rotatelogs -l /var/log/httpd/access_log_%Y_%m%d 86400" combined env=!no_log
に変更しましょう。
gif、jpg,pngへのアクセスログ、192.168.0.*からのアクセスはログに残らないようになります。
さらにログは/var/log/httpd配下のディレクトリの中に
access_log_2011_0123のように日付ごとのファイルで残すことが可能です。

#ServerSignature On
→ServerSignature Off
エラーページでapacheのバージョンを表示しないようにする


$ sudo chkconfig httpd on
$ sudo apachectl start

server setting

$ sudo vi /etc/sysconfig/iptables


-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT


$ sudo /etc/init.d/iptables restart

$ sudo adduser USERNAME
$ sudo passwd USERNAME
$ sudo visudo


root ALL=(ALL) ALL
USERNAME ALL=(ALL) ALL  ←add


Mysql

$ sudo yum -y install mysql-server php-mysql
$ sudo etc/init.d/mysqld start
$ mysql -u root -p

Memcache

$ sudo yum –y install memcached
$ sudo /sbin/chkconfig memcached on
$ sudo /sbin/service memcached start
$ sudo yum -y install php-pecl-memcache
$ sudo vi /etc/sysconfig/memcached


PORT=”11211″
USER=”memcached”
MAXCONN=”1024″
CACHESIZE=”64″
OPTIONS=”"


PHP

$ sudo pear install HTTP_Request2
$ sudo pear install --alldeps xml_serializer-beta
$ sudo yum -y install --enablerepo=remi --enablerepo=remi-php55 php php-devel php-mbstring php-mcrypt php-mysql php-phpunit-PHPUnit php-pecl-xdebug
$ sudo vim /etc/php.ini


; UNIX: "/path1:/path2"
include_path = ".:/usr/share/php:/usr/share/pear"


👇pear install がphp5.5だとうまくいかないので5.3へダウングレードが必要な際👇
downgrade -> http://blog.hello-world.jp.net/?p=584

PHPUnit

$ sudo yum -y install php-pear
$ sudo pear channel-discover pear.phpunit.de
$ sudo pear channel-update pear.php.net
$ sudo pear channel-discover components.ez.no
$ sudo pear upgrade pear
$ sudo yum -y install php-xml
$ sudo pear install -o phpunit/PHPUnit-3.4.15
$ sudo pear install phpunit/PHP_CodeCoverage
$ sudo yum -y install php-dom

Jenkins

$ sudo yum -y install java-1.7.0-openjdk.x86_64
$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
$ sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
$ sudo yum install jenkins
$ sudo service jenkins start

Version control

$ sudo yum -y install subversion
$ sudo yum -y install git-core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment