お仕事

環境構築

【環境構築】LAMPローカル開発環境構築(2022年度版)

[使用するもの]
VitualBox: 6.1.30
vagrant: 2.2.19

[作りたい環境]
OS: AlmaLinux 8.x(CentOS と同じ使い方ができそうなため)
PHP: PHP7.x
MySQL: 8.x
Apache: 2.4.x

1. 事前準備
1-1. 全体的なアップデート
sudo dnf update

1-2. 必要なものをインストール
sudo dnf install gcc gcc-c++ cmake expat-devel pcre pcre-devel git m4 autoconf gd-devel libxml2-devel bzip2-devel curl-devel gmp-devel ncurses-devel zlib-devel readline-devel libXpm-devel freetype freetype-devel openssl-devel bison wget zip unzip wget vim

2. selinuxの無効化
2-1. ファイルを開く
sudo vi /etc/sysconfig/selinux

2-2. 以下を変更
SELINUX=enforcing
から
SELINUX=disabled

2-3. vagrantの再起動

2-4. SELINUXの状態を確認
getenforce
=> Disabled と表示されればOK

参考サイト
https://sudachi.jp/wiki/%E3%83%98%E3%83%AB%E3%83%97:SELinux%E3%81%AE%E7%84%A1%E5%8A%B9%E5%8C%96%EF%BC%86%E3%83%95%E3%82%A1%E3%82%A4%E3%82%A2%E3%82%A6%E3%82%A9%E3%83%BC%E3%83%AB%E5%81%9C%E6%AD%A2(AlmaLinux)

3. ファイアウォールの停止(ローカル環境で使用する環境だから行っている感じ)
3-1. ファイアウォールの停止
sudo systemctl stop firewalld

3-2. ファイアウォールの自動起動の停止
sudo systemctl disable firewalld

3-3. ファイアウォールの停止確認
sudo systemctl is-enabled firewalld
=> disabled と表示されればOK

参考サイト
https://mebee.info/2021/04/23/post-33176/#outline__10

4. MySQL
4-1. MySQLのインストール
sudo dnf install @mysql:8.0

4-2. MySQLの自動起動設定
sudo systemctl enable --now  mysqld

4-3. MySQLの自動起動の設定確認
sudo systemctl is-enabled mysqld
=> enabled と表示されればOK

4-4. MySQLの初期設定
mysql_secure_installation


4-4-1. Press y|Y for Yes, any other key for No: => y: パスワード設定を行う n => パスワード設定を行わない => yを選択

4-4-2. Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: => パスワードのセキュリティポリシー: 0を選択

4-4-3. パスワードを入力

4-4-4. Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : => 入力したパスワードで問題ないか?

4-4-5. Remove anonymous users? (Press y|Y for Yes, any other key for No) : => 匿名ユーザーが必要ないか? => 匿名ユーザーは不要なのでyを選択

4-4-6. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : => リモートでrootユーザーで接続を行わないか? => リモートからrootユーザーで接続しないのでyを選択

4-4-7. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : => テストDBが必要か? => 必要ないのでyを選択

4-4-8. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : => 設定を反映させるか? => 反映させないのでyを選択

4-5. MySQLの接続確認
mysql -u root -p
=> 5-4-3 で入力したパスワードで接続できればOK

参考サイト
https://mebee.info/2021/06/04/post-33521/


5. Apache
5-1. Apacheのインストール
sudo dnf install httpd httpd-tools

5-2. Apacheの初期設定
5-2-1. Apacheの起動
sudo systemctl start httpd

5-2-2. Apacheの自動起動の設定
sudo systemctl enable --now httpd

5-3. Apacheの接続確認

参考サイト
https://mebee.info/2021/05/02/post-33639/

6. PHP
6-1. PHPのインストール
6-1-1. インストール可能なPHPの確認
sudo dnf module list php

6-1-2. デフォルトでインストールするつもりのPHPのバージョンを外す
sudo dnf module reset php

6-1-3. デフォルトでインストールするPHPのバージョンをセット
sudo dnf module enable php:7.4

6-1-4. PHPのインストール
sudo dnf install php php-common php-opcache php-cli php-gd php-curl php-mysqlnd

6-1-5. php-fpmの起動
sudo systemctl start php-fpm

6-1-6. php-fpmの自動起動の設定
sudo systemctl enable php-fpm

6-2. PHPのインストール確認
6-2-1. 以下のファイルを作成する
sudo vi /var/www/html/info.php

ファイルの中身
<?php
phpinfo();

?>

6-2-3.ファイルを開く
sudo vim /etc/httpd/conf/httpd.conf

6-2-4. 以下の文言を置き換える
 DirectoryIndex index.html =>  DirectoryIndex index.html index.php

6-2-5. ブラウザでファイルに接続
<IPアドレス>/index.php


[全体的な参考サイト]
https://blog.apar.jp/linux/15554/

≫ 続きを読む

環境構築   2022/01/10   tekitoizm

【環境構築】LAMPローカル開発環境構築(2020年度版)

LAMP環境を構築したお話

 

[一応]

vagrant上での作業

 

[環境]

vitualBox: 6.1.14

vagrant : 2.2.10

CentOS: 7.x

 

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

Apache 2.4.6

MariaDB: 10.5.5

PHP 7.4.10

 

1, 事前準備
1-1, yum -y update


1-2, sudo 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 wget zip unzip  libsodium-devel

 

1-3, ファイアウォールの停止(ローカル環境で使用する環境だから行っている感じ)

sudo systemctl stop firewalld

 

1-4, ファイアウォールの自動起動の停止

sudo systemctl disable firewalld

 

1-5, selinuxを停止

1-5-1, 以下のコマンドでselinuxのコンフィグを設定

sudo vi /etc/selinux/config

1-5-2, 以下の記述をコメントアウト

SELINUX=enforcing

# SELINUX=enforcing

1-5-3, コメントアウトをした下に以下を追記

SELINUX=disabled

 

2, mariaDB

2-1, MariaDBのインストール

sudo yum install mariadb mariadb-server

 

2-2, mariaDBのコンフィグファイルを開く

sudo vi /etc/my.cnf.d/server.cnf

 

2-3, 下記を[mariadb]の下に追記しデフォルトの文字コードをUTF-8に

character-set-server=utf8

 

2-4, mariaDBの自動起動有効化

sudo systemctl enable mariadb

 

2-5, mariaDBの起動

sudo systemctl start mariadb

 

2-6, mariaDBの初期設定を行う

sudo mysql_secure_installation

 

2-7, のコマンドで聞かれること
2-7-1, Switch to unix_socket authentication: Yを入力してEnter押下
(unixソケットで接続しますか?)

2-7-2, Change the root password?: Yを入力してEnter押下
(管理者用パスワードを変更しますか?)
変更後パスワード・確認用パスワードを入力する

2-7-3, Disallow root login remotely?: Yを入力してEnter押下
(リモートでroot接続できなくしてよいですか?)

2-7-4, Remove test database and access to it?: Yを入力してEnter押下
(テスト用のデータベース削除してよいですか?)

2-7-5, Reload privilege tables now?: Yを入力してEnter押下
(テーブル情報リロードしますか?)

 

2-8, mariaDBの再起動

sudo systemctl restart mariadb

2-9, 6-6-2で入力した パスワードでmariaDBへの接続

mysql -u root -p

 

3, apache(httpd)

3-1, apacheのインストール

sudo yum install httpd

 

3-2, apacheの自動起動の設定

sudo systemctl enable httpd.service

 

3-3, apacheの起動

sudo systemctl start httpd.service

 

4, PHPのインストール

4-1, Remiリボジトリの有効化

sudo yum install epel-release
sudo rpm -ivh http://ftp.riken.jp/Linux/remi/enterprise/remi-release-7.rpm
 

4-2, PHPのインストール

sudo yum install php74 php74-php php74-php-mysql php74-php-php-mysqlnd php74-php-bcmath php74-php-ctype php74-php-json php74-php-mbstring php74-php-openssl php74-php-PDO php74-php-tokenizer php74-php-xml gcc

 

4-3, PHPのシンボリックリンクを追加

sudo ln -s /usr/bin/php74 /usr/bin/php

 

4-4, PHPのバージョン確認

php -v

 

4-5, apacheの再起動

sudo systemctl restart httpd.service

 

5, composer(PHP関連)のインストール

5-1, composerファイルのダウンロード

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php composer-setup.php

 

5-2,  ダウンロードしたcomposer.pharをbin に移動

sudo mv composer.phar /usr/local/bin/composer

 

参考サイト

composer: https://getcomposer.org/download/

≫ 続きを読む

環境構築   2018/09/06   tekitoizm

【環境構築】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

【環境構築】Jenkinsのインストール

[環境]
OS: CentOS 6.7

1, Java(version 1.7)のインストール(インストール済の場合は必要なし)
- yum install java-1.7.0-openjdk
-- root権限で実行

2, リポジトリ情報の追加
- wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
-- root権限で実行
- rpm -ivh http://pkg.jenkins-ci.org/redhat/jenkins-1.643-1.1.noarch.rpm
-- root権限で実行

3, Jenkinsのインストール
-- yum install jenkins
-- root権限で実行

4, iptablesの追加
- vim /etc/sysconfig/iptables
-- root権限で実行
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
- /etc/init.d/iptables restart
-- root権限で実行


5, jenkinsの起動
- /etc/init.d/jenkins start

6, 確認
- ブラウザで以下のURLを開く
-- [インストールしたサーバーのIP]:8080
- Jenkinsの画面が表示されればOK

7, 自動起動の設定
- chkconfig jenkins on
-- root権限で実行

 

[参考サイト]

- Jenkins を CentOS 6 にインストールする手順 (yum, RPM) | WEB ARCH LABO

RedHat Repository for Jenkins

≫ 続きを読む

環境構築   2018/07/10   tekitoizm

【環境構築】Zip Archiveのインストール

[環境]

- CentOS 6.9

- pecl install zip

- vim /etc/php.ini

-- 追記 : extension=zip.so

- apache再起動

 

[参考サイト]

ZIP Archive のインストール|プログラムメモ

 

≫ 続きを読む

環境構築   2018/07/10   tekitoizm