お仕事

【環境構築】LAMP環境構築(2018年度版)

LAMP環境を構築したお話

 

[環境]

OS: CentOS 6.10

[一応]

vagrant上での作業

 

[インストールするもの]

Apache 2.4.34

MySQL 5.7.23

PHP 7.2.

 

[事前準備]

[事前準備]
- yum -y update
- yum install gcc gcc-c++ cmake expat-devel pcre pcre-devel git m4 autoconf gd-devel libxml2-devel t1lib-devel bzip2-devel curl-devel gmp-devel aspell-devel recode-devel ncurses-devel zlib-devel readline-devel libXpm-devel freetype freetype-devel openssl-devel bison

[Apache]
- cd /usr/local/src
- wget http://ftp.kddilabs.jp/infosystems/apache//apr/apr-1.6.3.tar.gz
- tar xfz ./apr-1.6.3.tar.gz
- cd apr-1.6.3
- ./configure
- make
- make install

- cd /usr/local/src
- wget http://ftp.tsukuba.wide.ad.jp/software/apache//apr/apr-util-1.6.1.tar.gz
- tar xfz apr-util-1.6.1.tar.gz
- cd apr-util-1.6.1
- ./configure --with-apr=/usr/local/apr/
- make
- make install

- cd /usr/local/src
- wget http://ftp.riken.jp/net/apache//httpd/httpd-2.4.34.tar.gz
- tar xfz httpd-2.4.34.tar.gz
- cd httpd-2.4.34
- ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr/ --enable-module=a--enable-module=so --enable-ssl --with-ssl=/usr/local/openssl
- make
- make install
- cp -ip /usr/local/src/httpd-2.4.34/build/rpm/httpd.init  /etc/init.d/httpd
- vim /etc/init.d/httpd
-- httpd=${HTTPD-/usr/sbin/httpd}          => httpd=${HTTPD-/usr/local/httpd/bin/httpd}
-- pidfile=${PIDFILE-/var/run/${prog}.pid} => pidfile=${PIDFILE-/usr/local/httpd/logs/httpd.pid}
-- CONFFILE=/etc/httpd/conf/httpd.conf     => CONFFILE=/usr/local/httpd/conf/httpd.conf

- vim /usr/local/httpd/conf/httpd.conf
-- User daemon => User vagrant
-- Group daemon => Group vagrant

- service httpd start
- chkconfig httpd on

[MySQL](vagrant上でやったもんだからソースからインストールできんかってん容量足りんかってん)
- rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
- yum install mysql-community-server
- service mysqld start
- grep 'temporary password' /var/log/mysqld.log
※ 表示されるパスワードを保存
- mysql -u root -p
※ 上で表示されたパスワードでログイン
-- set password for root@localhost=password('passwordPASSWORD@999');
-- SET GLOBAL validate_password_length=4;
-- SET GLOBAL validate_password_policy=LOW;
-- set password for root@localhost=password('root');
-  mysql_secure_installation
-- Enter password for user root => root
-- Change the password for root ? ((Press y|Y for Yes, any other key for No) => No
-- Remove anonymous users? (Press y|Y for Yes, any other key for No) => y
-- Disallow root login remotely? (Press y|Y for Yes, any other key for No) => y
-- Remove test database and access to it? (Press y|Y for Yes, any other key for No) => y
-- Reload privilege tables now? (Press y|Y for Yes, any other key for No) => y
- chkconfig mysqld on

[PHP]
- cd /usr/local/src
- wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
- rpm -ivh epel-release-6-8.noarch.rpm 
- yum --enablerepo=epel install libmcrypt php-mcrypt libmcrypt-devel php-mcrypt-devel php-pdo php-mysqlnd libmcrypt-devel

- cd /usr/local/src/
- wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
- rpm -ivh epel-release-6-8.noarch.rpm 
- yum install libmcrypt-devel

-  wget -O php-7.2.9.tar.gz  http://jp2.php.net/get/php-7.2.9.tar.gz/from/this/mirror
- tar xfz ./php-7.2.9.tar.gz 
- ./configure --prefix=/usr/local/lib/php --enable-ctype --enable-mbstring --with-apxs2=/usr/local/httpd/bin/apxs  --enable-pdo --with-pdo-mysql --with-curl --with-openssl
- make
- make test
- make install
- ln -s /usr/local/lib/php/bin/php /usr/local/bin/php

-  vim /usr/local/httpd/conf/httpd.conf
--  DirectoryIndex index.html =>  DirectoryIndex index.php index.html
-- 追記(#Include conf/extra/httpd-default.confのした) => Include conf/extra/php7.conf
- vim /usr/local/httpd/conf/extra/php7.conf
---- ここから ----
# ApacheにPHP7のモジュールを読み込ませる記述
LoadModule php7_module   /usr/lib64/httpd/modules/libphp7.so

# .phpファイルにアクセスした場合PHPスクリプトとして扱う記述
AddType application/x-httpd-php .php
---- ここまで ----

- service httpd restart
 

[独り言]

・・・あぁめんどくさい

 

[参考サイト]

【CentOS6】apache2.4をソースからコンパイルしてインストール

CentOS 6 の環境にPHP7をインストールしてApacheで動かすまで

PHP7.1を関連ライブラリと共にインストール(ソースからコンパイル)for Apache2.4+CentOS7.4

http://www.eastforest.jp/mysql/3521

CentOS6にPHP7をソースからインストール

環境構築   2018/09/06   tekitoizm
≪ 【MySQL】DBの制限ユーザーの作成  |  【環境構築】LAMPローカル開発環境構築(2020年度版) ≫