CentOS6.5の初期設定をやろう~その2-LAMPを入れよう(Apache2.4.7)

CentOS 6.5にLAMBを設定その2
今回はApache2.4.7のrpmを作って入れる

http://www.kakiro-web.com/linux/apache-install.html
http://qiita.com/100/items/ab31e57fcc66ac661d5c
http://www.system-act.com/web/apache.html
上記のサイトさんにお世話になりました

# yum -y install doxygen mailcap
# yum --enablerepo=epel install freetds-devel
# yum -y install expat-devel libuuid-devel db4-devel \
postgresql-devel sqlite-devel unixODBC-devel \
openldap-devel openssl-devel nss-devel pcre-devel \
lua-devel libxml2-devel

以下から最新のaprとapr-utilを確認
http://archive.apache.org/dist/apr/


# mkdir /usr/local/src/httpd
# cd /usr/local/src/httpd
# wget http://archive.apache.org/dist/apr/apr-1.5.0.tar.bz2
# wget http://archive.apache.org/dist/apr/apr-util-1.5.3.tar.bz2

# rpmbuild -tb --clean apr-1.5.0.tar.bz2
# cd /root/rpmbuild/RPMS/x86_64/
# rpm -Uvh apr-1.5.0-1.x86_64.rpm apr-devel-1.5.0-1.x86_64.rpm

# cd /usr/local/src/httpd
# rpmbuild -tb --clean apr-util-1.5.3.tar.bz2
# cd /root/rpmbuild/RPMS/x86_64/
# rpm -Uvh apr-util-1.5.3-1.x86_64.rpm \
apr-util-devel-1.5.3-1.x86_64.rpm

# cd /usr/local/src/
# wget http://ftp.riken.jp/Linux/fedora/releases/18/Everything/source/SRPMS/d/distcache-1.4.5-23.src.rpm
# rpmbuild --rebuild --clean distcache-1.4.5-23.src.rpm
# cd /root/rpmbuild/RPMS/x86_64/
# rpm -Uvh distcache-1.4.5-23.x86_64.rpm distcache-devel-1.4.5-23.x86_64.rpm

以下から最新のApache2.4を確認
http://archive.apache.org/dist/httpd/

# cd /usr/local/src/httpd
# wget http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.bz2
# rpmbuild -tb --clean httpd-2.4.7.tar.bz2
# rpm -Uvh httpd-2.4.7-1.x86_64.rpm
# rpm -Uvh httpd-devel-2.4.7-1.x86_64.rpm \
httpd-tools-2.4.7-1.x86_64.rpm mod_ssl-2.4.7-1.x86_64.rpm

初期設定(仮)
・サイトのディレクトリは/home/wwwとする(適宜よみかえて)
・PHPを入れるのでMPMはpreforkにしておく

ディレクトリ
# mkdir /home/www
# mkdir /home/www/htdocs
# mkdir /home/www/cgi-bin

まずはユーザーが作られてるか確認
# cat /etc/group |grep apache
# cat /etc/passwd |grep apache
# usermod -d /home/www
ないとき
# groupadd -g 48 apache
# useradd -u 48 apache -g apache -s /sbin/nologin -d /home/www

以下おのおのの好みで設定
# vim /etc/httpd/conf/httpd.conf

LoadModule mpm_event_module lib64/httpd/modules/mod_mpm_event.so

#LoadModule mpm_event_module lib64/httpd/modules/mod_mpm_event.so
#LoadModule mpm_worker_module lib64/httpd/modules/mod_mpm_worker.so
LoadModule mpm_prefork_module lib64/httpd/modules/mod_mpm_prefork.so


User daemon
Group daemon

User apache
Group apache


DocumentRoot "/var/www/html"
<Directory "/var/www/html">

DocumentRoot "/home/www/html/"
<Directory "/home/www/html/">

Options Indexes FollowSymLinks

Options Includes ExecCGI FollowSymLinks

<IfModule mime_module>
#AddHandler cgi-script .cgi

AddHandler cgi-script .cgi .pl

<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" ←最後"/"で閉じ忘れると大変なことになる

ScriptAlias /cgi-bin/ "/home/www/cgi-bin/"

<Directory "/var/www/cgi-bin/">

<Directory "/home/www/cgi-bin/">

最後に設定のテスト

# apachectl configtest

OKが出れば終了
# /etc/rc.d/init.d/httpd restart
# chkconfig --list httpd
# chkconfig httpd on
ランレベルは2~5までonならばOK
[PR]

  by innocenceflower | 2013-12-15 15:09 | 備忘録

<< CentOS6.5の初期設定を... CentOS6.5の初期設定を... >>

SEM SKIN - DESIGN by SEM EXE