haruki のすべての投稿

Ubunt16にWordPressとレスポンシブルWebデザインテーマbizvektorを組み込んでみる

Ubunt16にWordPressと
レスポンシブルWebデザインテーマbizvektorを組み込んでみます

1,Apacheの組み込み

sudo apt -y install apache2
apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built:   2016-07-14T12:32:26

apacheを起動する

sudo service apache2 start

Webで確認する

firefox localhost

cat <<EOF > /var/www/html/test.html
<html>
<hr>
hello
<hr>
</html>
EOF
bash: /var/www/html/test.html: 許可がありません

ローカルでなので、

sudo chmod 777 /var/www/html/
cat <<EOF > /var/www/html/test.html
<html>
<hr>
hello
<hr>
</html>
EOF

curl 'http://localhost/test.html'

アクセスできた

<html>
<hr>
hello
<hr>
</html>

ブラウザでも確認

firefox localhost/test.html

2,PHPを組み込む

sudo apt -y install php
php -v
PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies
cat <<EOF > /var/www/html/phpinfo.php
<?php
phpinfo();
?>
EOF
 
curl 'http://localhost/phpinfo.php'

firefoxで、アクセスしてみる

firefox localhost/phpinfo.php


apacheの再起動を忘れた


sudo service apache2 stop
sudo service apache2 start

うまくいかない

firefox localhost/phpinfo.php


パッケージを追加

sudo apt -y install libapache2-mod-php
firefox localhost/phpinfo.php

うまくいった。

3,mysqlをインストール

sudo apt -y install mysql-server php-mysql

Mysqlのrootのパスワードを聞かれるので、
入力しタブでスペースで、続行する(確認の2回あります)

mysql -u root -p

データベース(wordpress)を作成
wordpressというユーザを作成し、パスワードをwordpress2016とする

rootで入るので、先ほどのパスワードを入力する

mysql -u root -p
Enter password: (先ほどのパスワード)
create database wordpress;
grant all privileges on wordpress.* to wordpress@localhost identified by 'wordpress2016';
flush privileges;
exit;

4,WordPressをインストール
WordPressをダウンロードし
ファイルを解凍する

cd /tmp
wget http://ja.wordpress.org/wordpress-3.8.1-ja.tar.gz
tar zxvf wordpress-3.8.1-ja.tar.gz 
cp -r wordpress /var/www/html
sudo chown -R www-data:www-data /var/www/html/wordpress
firefox http://localhost/wordpress/
お使いのサーバーの PHP では WordPress に必要な MySQL 拡張を利用できないようです。

ライブラリィ−を追加してみる


sudo apt-get update
sudo apt-get install php-curl php-gd php-mbstring php-mcrypt php-xml php-xmlrpc

sudo service apache2 stop
sudo service apache2 start
firefox http://localhost/wordpress/

やはりだめ

お使いのサーバーの PHP では WordPress に必要な MySQL 拡張を利用できないようです。

WordPressのバージョンを上げてみる

cd /tmp
sudo rm -rf /var/www/html/wordpress
sudo rm -rf /tmp/wordpress
wget http://ja.wordpress.org/latest-ja.tar.gz
tar -xzvf latest-ja.tar.gz 
cp -r wordpress /var/www/html
sudo chown -R www-data:www-data /var/www/html/wordpress

firefox http://localhost/wordpress/

うまくいった。。。。

データベース名:wordpress
ユーザ名:wordpress
パスワード:wordpress2016
データベースのホスト名:localhost
テーブル接頭辞:wp_

「インストール続行」
サイトのタイトル:タイトル
ユーザー名:admin
パスワード:admin_password
パスワード:admin_password
メールアドレス:xxx@yyy.zz
「WordPressをインストール」

5,レスポンシブルWebデザインテーマbizvektorを組み込む
手順は
・テーマの読み込み
・推奨プラグインの読み込み(有効化)
・サンプルデータの読み込み

となります。

5.1 テーマの読み込み

BizVektor
https://bizvektor.com/

のダウンロードページ
https://bizvektor.com/bizvektor.com/about/download/

から、
Download BizVektor ver 1.8.23
を、ダウンロード

外観>テーマ>新規追加
「データのアップロード」
により
先ほど、ダウンロードしたファイルを「参照」で
指定し、
「今すぐインストール」
を、押下

外観>テーマ
選択し、
ダウンロードしたテーマ「BizVektor」
を、有効にしてください。

5.2 推奨プラグインの読み込み(有効化)

プラグインの説明と設定方法

に従い、
「プラグイン」→「新規追加」画面より、『お気に入り』画面を表示。
「wordpress.orgユーザー名」のフォームに「bizvektor」と入力して、必要なプラグインをインストール。

インストールした、プラグインを有効化します

プラグインを追加する

5.3 サンプルデータの読み込み
BizVektor クイックスタート
のページの
「サンプルデータ」
を、ダウンロードする

ダウンロードしたデータを
bv_contents_corporate_v20140928.zip
解凍し、
bv_contents_corporate_v20140928.xml
のファイルを読み出す

コンテンツデータのダウンロード・インポート
に従い、コンテンツデータを、インポートする

「ツール」→「インポート」→「WordPress」でダウンロードしたxmlファイルを選択し、「ファイルをアップロードしてインポート」

これで、レスポンシブル対応のWordPressが立ち上がります。

■隘路(ポイント)
「お使いのサーバーの PHP では WordPress に必要な MySQL 拡張を利用できないようです。」
への対策
1,WordPressを最新にする
2,不足しているライブラィーを追加する

  sudo apt-get install php-curl php-gd php-mbstring php-mcrypt php-xml php-xmlrpc

3,Apacheを再起動する

sudo service apache2 stop
sudo service apache2 start

Redmine3.3とGitを連携する

Redmineのプラグイン
redmine_github_hook.git
を使って、GitとRedmineを連携してみました。

Redmineの配置場所を、
/var/lib/redmine
としますので、
それ以外の場合は、
/var/lib/redmine
の部分を書き換えて下さい

1,プラグインを組み込む

cd /var/lib/redmine/plugins
git clone https://github.com/koppen/redmine_github_hook.git

2,Git側で、レポジトリーを作成
GitHubまたは、Gitbucketで、対象のレポジトリを作成

3,サーバ側設定

cd /var/lib/redmine/repo

GitHubの場合

git clone --bare      https://github.com/<アカウント名>/<レポジトリ名>.git

Gitbucketの場合

git clone --bare      https://<アカウント名>@bitbucket.org/<アカウント名>/<レポジトリ名>.git

キーを登録しSSHで接続する場合は

git clone --bare git@github.com:<アカウント名>/<レポジトリ名>.git

で、可能です。

4,Remindeの再起動し、プラグインを組み込む

cd /var/lib/redmine//tmp
touch restart.txt

RedmineのWebでどこかの、画面をアクセスする(または、再表示)
(再起動しても、restart.txtは、消えない)

5,Redmineで、設定
プロジェクトの画面
設定>リポジトリ>新しいリポジトリ
バージョン管理システム:Git
識別子:わかりやすい文字を指定
リポジトリのパス:/var/lib/redmine/repo/<レポジトリ名>.git
パスのエンコーディング:UTF-8

識別子を設定により、
一つのプロジェクトで、識別子名による、切り替えができる

これにより、
Redmineから、
更新履歴、差分、コメントなどを、見ることがき、
更新内容と、Redmine内のチケットと連携(関係付ける)ことができます

6,Gitの最新の手動反映
Gitサーバ側のWebhookにより、
Gitサーバ側の更新時に、Redmineサーバの
更新内容を自動連携する方法がありますが、
以下により、手動反映ができました

cd /var/lib/redmine/repo
rm -rf <レポジトリ名>.git
git clone --bare      https://github.com/<アカウント名>/<レポジトリ名>.git
git clone --bare      https://<アカウント名>@bitbucket.org/<アカウント名>/<レポジトリ名>.git

7,プラウザからGitの最新の反映
毎回端末で、接続して、反映するのが大変なため、
自動更新を行う

更新方法としては
Cronで行う方法もあるが、
ほどんど更新していないのに、
Gitサーバに問い合わせに行くのは、申し訳ない。

本来,Gitサーバ側で
Service Hooks:WebHook
で、設定を行えばいいのだが、

Redmine側から取りに行く方法で行ってみた。

phpから、Shellを起動してみる

7,1 phpのインストール

phpがあるか確認

php --version

-bash: php: コマンドが見つかりません

ないので、phpのインストール

参考:
http://qiita.com/ozawan/items/caf6e7ddec7c6b31f01e

yum install --enablerepo=remi,remi-php56 php php-devel php-mbstring php-pdo php-gd

/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/httpd start

7.2 phpで、shellを起動

参考:
http://php.net/manual/ja/function.shell-exec.php

cat <<EOF > /var/lib/redmine/public/ls.php
<?php
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
?>
EOF

xx.xx.xx/ls.php

で、表示を確認

7.3 phpで、gitを起動するプログラムを作成

repoの所有者を変更

chown -R apache:apache /var/lib/redmine/repo
cat <<EOF > /var/lib/redmine/public/git_change.php
<?php
shell_exec('rm -rf /var/lib/redmine/repo/<レポジトリ名>.git');
$output = shell_exec('git clone --bare      https://github.com/<アカウント名>/<レポジトリ名>.git');
shell_exec('mv /var/lib/redmine/public/<レポジトリ名>.git /var/lib/redmine/repo/<レポジトリ名>.git');

echo "<pre>$output</pre>";
?>
EOF

同期したいときに
ブラウザから

xx.xx.xx/git_change.php

で、最新情報を読み取る

8 ファイル、フォルダの日本語対応
Redmineサーバ側のGitのバージョンを上げる
CentOS 8.7
の場合、Gitのバージョンは 1.7.1
最新にバージョンを上げる

参考

バージョンを確認する

git --version
git version 1.7.1

パッケージを読み込む

yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker

ソースを読み込み、インストールする

cd
wget https://www.kernel.org/pub/software/scm/git/git-2.4.0.tar.gz
tar zxvf git-2.4.0.tar.gz

cd git-2.4.0
make prefix=/usr/local all
make prefix=/usr/local install
. ~/.bash_profile
git --version
git version 2.4.0

最新を読み込み、インストールする

cd /usr/local/src/
git clone git://git.kernel.org/pub/scm/git/git.git
cd git
make prefix=/usr/local all
make prefix=/usr/local install
git --version

git version 2.9.2.574.gc6b0597

Redmineを再起動する

cd /var/lib/redmine/tmp
rm  restart.txt
touch restart.txt

/etc/rc.d/init.d/httpd restart

参考
http://qiita.com/n_slender/items/54cd282c140fadbbb322
http://symfoware.blog68.fc2.com/blog-entry-1694.html

ConoHaでCentOS6.7へRedmine3.3をインストールする

1,パッケージインストール

2,EPELリポジトリの登録

3,開発ツール・インストール

4,Rubyをインストール

10分ほどかかります。

5,bundlerインストール

6,MySQL redmine用の設定

7,redmineインストール

8,DB情報設定

9,Passengerインストール

10,httpd設定

DocumentRootで検索 /DocumentRoot

11,Redmineへアクセス
サーバとトップへアクセス

ConoHaでCentOS6.7へRedmine2.5をインストールする

1,パッケージインストール

2,EPELリポジトリの登録

3,開発ツール・インストール

4,Rubyをインストール

5,bundlerインストール

6,MySQL redmine用の設定

7,redmineインストール

8,DB情報設定

9,Passengerインストール

10,httpd設定

DocumentRootで検索 /DocumentRoot

11,Redmineへアクセス
サーバとトップへアクセス

注意点(ポイント)
1,redmine-2.5.0の場合、Rubyのバージョンが依存する(2.0.0-p648)
   2.2.3だとだめだった
2,chmod o+x /root/ をしないとダメだった
   画面表示されない時はログファイルでエラーの内容を確認
find / -name error_log
cat /var/log/httpd/error_log

参考
http://j-orangepekoe.blog.so-net.ne.jp/2016-03-02
http://www.aetherworks.org/article/112066375.html
http://qiita.com/mozo/items/6ec0151dad350c051399
http://blog.redmine.jp/articles/2_5/installation_centos/
http://blog.redmine.jp/articles/3_2/install/centos/

Ubuntu16 で、漢字入力を設定する

Ubuntu16 で、漢字入力を設定する

システム設定>言語サポート
を選択する

必要な言語パッケージがインストールされる

インストールされたた、

システム設定>テキスト入力
から、

日本語を選択し

ボタンで、削除する

ボタンで、追加を指定し
日本語(Mozc)(IBus)
を選択し、追加する
切り替えにカーソルを移動し、半角/全角
ボタンで、変換ボタンを指定する

矢印で、
日本語(Mozc)(IBus)
を、一番上にする

入力する場所で、変換ボタンを押して
入力が切り替えるのを見る(右上)
日本語変換になった時に
切り替えの表示を
クリックし、入力モードをひらがなにする

Ubuntu16 に、Chromeをインスツール

Ubuntu16 に、Chromeをインスツールします

https://www.google.co.jp/chrome/browser/desktop/

から、パッケージをダウンロードする

gdebiをダウンロードする

sudo apt -y install gdebi

ダウンロードしたフォルダーから

google-chrome-stable_current_amd64.deb
を、右クリックで、gdebiを選択して
インストールを行う

完了したら、左上のコンピュータ検索から
chrome
で検索する

ドラッグして、メニューに追加する

検索で表示されない場合には
端末から

google-chrome

で、一度、起動する

左上のコンピュータ検索から
chrome
で検索する

ドラッグして、メニューに追加する

CentOS 6.7にWordPressとレスポンシブルWebデザインテーマbizvektorを組み込んでみる

CentOS 6.7にWordPressとレスポンシブルWebデザインテーマbizvektorを組み込んでみる

CentOs に WordPressをインストールする

root権限になっていなければ、rootになる

$su
パスワード:
#

各種パッケージ
httpd mysql-server php php-mysql wget
をインストールする

yum -y install httpd mysql-server php php-mysql wget

apacheがインストールされたか確認

/etc/init.d/httpd status
httpd は停止しています

apacheを起動する

/etc/init.d/httpd start
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]

localhostにアクセスする

curl 'http://localhost/'

firefoxで、アクセスしてみる

firefox localhost/

タイムゾーンの設定
PHPの設定ファイル(/etc/php.ini)を編集する。


vim /etc/php.ini

date.timezone =を検索(”/”は検索)

/date.timezone =

iで、挿入モードにして
#date.timezone =
date.timezone = “Asia/Tokyo”
に変更

; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
#date.timezone =
date.timezone = "Asia/Tokyo"

esc+:wq
で、上書き終了

apacheを再起動

/etc/init.d/httpd restart

httpd を停止中:                                            [  OK  ]
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]

Webが起動し、PHPが走っているか確認する

cat <<EOF > /var/www/html/phpinfo.php
<?php
phpinfo();
?>
EOF

curl 'http://localhost/phpinfo.php'

firefoxで、アクセスしてみる

firefox localhost/phpinfo.php

mysqlがインストールされたか確認

/etc/init.d/mysqld status

mysqld は停止しています

mysqlを起動する

/etc/init.d/mysqld start

   :
mysqld を起動中:                                           [  OK  ]

パスワードを設定(rootにパスワードcentosと設定してみた)

mysql -u root

update mysql.user set password=password('centos') where user = 'root';
flush privileges;
exit;

設定したパスワードでログインできるかを確認します。

# mysql -u root -p
Enter password: 

exit;

データベース(wordpress)を作成
wordpressというユーザを作成し、パスワードをwordpress2016とする

# mysql -u root -p
Enter password: 
create database wordpress;
grant all privileges on wordpress.* to wordpress@localhost identified by 'wordpress2016';

WordPressをインストール
WordPressをダウンロードし
ファイルを解凍し、
Apacheが読み込めるようにする。

cd /tmp
wget http://ja.wordpress.org/wordpress-3.8.1-ja.tar.gz
tar zxvf wordpress-3.8.1-ja.tar.gz 
cp -r wordpress /var/www/
chown -R apache.apache /var/www/wordpress

apacheの設定を行う

vim /etc/httpd/conf/httpd.conf

DocumentRoot “/var/www/html
DocumentRoot “/var/www/wordpress”
に変更

DocumentRoot “/var/www/htmlを検索

/DocumentRoot "/var/www/html

DocumentRoot “/var/www/wordpress”
に変更

iで、挿入モードに入る

#DocumentRoot "/var/www/html"
DocumentRoot  "/var/www/wordpress "

次に、

<Directory "/var/www/html">

<Directory "/var/www/wordpress">

に変更
一度、ESCで、コマンドモードに戻り

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

で、検索
挿入モードiで、

#<Directory "/var/www/html">
<Directory "/var/www/wordpress">

に、修正
次に、

<Directory "/var/www/wordpress">

の中の

    AllowOverride None

を、

    AllowOverride All

に変更

#   AllowOverride None
    AllowOverride All

に変更

esc+:wq

を指定

apacheを再起動

/etc/init.d/httpd restart

httpd を停止中:                                            [  OK  ]
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]

fierfoxで、アクセスする

firefox localhost/

データベース名:wordpress
ユーザ名:wordpress
パスワード:wordpress2016
データベースのホスト名:localhost
テーブル接頭辞:wp_

「インストール続行」
サイトのタイトル:タイトル
ユーザー名:admin
パスワード:admin_password
パスワード:admin_password
メールアドレス:xxx@yyy.zz
「WordPressをインストール」

成功しました !

「ログイン」

にて、開始画面へ

WordPress 4.5.3 が利用可能です ! 更新してください。

とのメッセージがあるため、
WordPress 4.5.3に更新する

WordPress の新しいバージョンがあります。
「今すぐ更新」
を押下

更新の後、ログイン画面に戻るので、
ログイン後、
プラグインを「今すぐ更新」を押下

次に、レスポンシブルWebデザインテーマbizvektorを組み込んでみる

BizVektor

HOME


のダウンロードページ

ダウンロード


から、
Download BizVektor ver 1.8.23
を、ダウンロード

外観>テーマ>新規追加
「データのアップロード」
により
先ほど、ダウンロードしたファイルを「参照」で
指定し、
「今すぐインストール」
を、押下

外観>テーマ
選択し、
ダウンロードしたテーマ「BizVektor」
を、有効にしてください。

BizVektor クイックスタート


に従い、
「プラグイン」→「新規追加」画面より、『お気に入り』画面を表示。
「wordpress.orgユーザー名」のフォームに「bizvektor」と入力して、必要なプラグインをインストール。

インストールした、プラグインを有効化します

プラグインを追加する
プラグインが、有効にならない場合、
必要なライブラィーを追加する

お使いの WP Multibyte Patch を有効化するには PHP の mbstring 関数が必要です。

yum -y install php-mbstring

apacheを再起動

/etc/init.d/httpd restart

httpd を停止中:                                            [  OK  ]
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]

BizVektor クイックスタート


コンテンツデータのダウンロード・インポート
に従い、コンテンツデータを、インポートする

「ツール」→「インポート」→「WordPress」でダウンロードしたxmlファイルを選択し、「ファイルをアップロードしてインポート」

インストール時のエラーが分からないので、
エラー表示を有効にする

vim /etc/php.ini

display_errors = Off
変更前
display_errors = On
変更後

display_errors =を検索し

/display_errors = 

i挿入モードで

;display_errors = Off
display_errors = On

に変更
esc+:wqで上書き終了

apacheを再起動

/etc/init.d/httpd restart

httpd を停止中:                                            [  OK  ]
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]

WordPress インポートできない時の対処方法
Fatal error: Class ‘DOMDocument’ not found

yum -y install php-xml

再度、apacheを再起動

/etc/init.d/httpd restart

httpd を停止中:                                            [  OK  ]
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]

サンプルデータが表示できた・・・

apacheとmysqlを自動起動に設定する

現状の確認
apacheは

chkconfig --list | grep httpd

offになっている

httpd          	0:off	1:off	2:off	3:off	4:off	5:off	6:off

自動起動(on)に設定

chkconfig httpd on

onになった

chkconfig --list | grep httpd
httpd          	0:off	1:off	2:on	3:on	4:on	5:on	6:off

mysqlの設定も

chkconfig --list | grep mysqld

offになっている

mysqld          	0:off	1:off	2:off	3:off	4:off	5:off	6:off

onにする

chkconfig mysqld on
chkconfig --list | grep mysqld
mysqld          	0:off	1:off	2:on	3:on	4:on	5:on	6:off

一応chromeもインストールしておく

wget http://chrome.richardlloyd.org.uk/install_chrome.sh
bash ./install_chrome.sh

テーマ、記事などを、修正削除していて、
うまく行かなくなり、削除し、再インストーツする場合。

wordpressが残っている確認する

cd /tmp
ls wordpress

もし、なければ、再度、ダウンロード

cd /tmp
wget http://ja.wordpress.org/wordpress-3.8.1-ja.tar.gz
tar zxvf wordpress-3.8.1-ja.tar.gz 

コンテンツ側(/var/www/wordpress)を削除し、
再度、複写する

rm -rf /var/www/wordpress
cp -r wordpress /var/www/
chown -R apache.apache /var/www/wordpress

Webより、再度設定する

firefox localhost/

データベーステーブルの接頭辞は、
一応、wp1_に変えておく

エラー対策まとめ、

■プラグイン有効時(WP Multibyte Patch)でのエラー
[/html]
yum -y install php-mbstring
/etc/init.d/httpd restart
[/html]

■サンプルデータのインポート時に無反応

vim /etc/php.ini
にて、
display_errors = On
/etc/init.d/httpd restart

■サンプルデータのインポート時のエラー

yum -y install php-xml
/etc/init.d/httpd restart

■サンプルデータ読み込み時の、infoエラー

をインポートできませんでした。投稿タイプ info が有効ではありません。

テーマが、「BizVektor」に切り替わっていない
外観>テーマで、
「BizVektor」を有効化

UbuntuでBootstrapを試してみる

Ubuntuの環境で、Bootstrapをインストールしてみます

■pills
ナビゲーション(錠剤:pills)

下記のような、を表示してみます。

1,を実施の後に、行って下さい。
http://getbootstrap.com/components/#nav-pills

スクリーンショット 2016-06-29 16:02:34

 

■tabs(タブ)
http://getbootstrap.com/components/#nav-tabs

■Breadcrumbs(パンくず)
http://getbootstrap.com/components/#breadcrumbs

■pagination(ページ付け)
http://getbootstrap.com/components/#pagination-default

■Pager(ページャ)
http://getbootstrap.com/components/#default-example

■Aligned links(並べたリンク)
http://getbootstrap.com/components/#aligned-links

■Available variations(各種のラベル)
http://getbootstrap.com/components/#available-variations

■Badges(バッジ、印)
http://getbootstrap.com/components/#badges

VirtualBox centos6.8で、Apache+Passenger+Sinatraでの環境構築

VirtualBox centos6.8で、Apache+Passenger+Sinatraでの環境構築
してみる

sudoを使えるようにする
使用できるか確認する

・結果表示
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for centos: ##←パスワードを入力
centos は sudoers ファイル内にありません。この事象は記録・報告されます。
[centos@localhost ~]$ 

使用できない

Passwordを入力

ALL=を検索する

root ALL=(ALL) ALL
の下に

ユーザー名 ALL=(ALL) ALLを追加する

vi のコマンドなので
iで、挿入モードとして
ユーザー名 ALL=(ALL) ALL
を入力し
[Esc]+:+wq+改行で上書き終了
suから抜ける

suから抜ける
もう一度ためして見る

・表示結果
[sudo] password for centos: 
bin   dev  home  lib64	     media  mnt  opt   root  selinux  sys  usr
boot  etc  lib	 lost+found  misc   net  proc  sbin  srv      tmp  var
[centos@localhost ~]$ 

できた。

必要なアプリをインストール

15分ぐらいかかります・・・・

・結果表示
Here's what you can expect from the installation process:
  
 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.
  :
  :
Press Enter to continue, or Ctrl-C to abort.
 
1を、選択
・結果表示
Use <space> to select.
If the menu doesn't display correctly, press '!'
  
 ‣ ⬢  Ruby
   ⬢  Python
   ⬡  Node.js
   ⬡  Meteor
 
entrで、進んで行く

エラーがでます

・結果表示
[root@localhost sina]# /etc/rc.d/init.d/httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中: httpd: Syntax error on line 1010 of /etc/httpd/conf/httpd.conf: Cannot load /home/centos/sina/vendor/bundle/ruby/2.2.0/gems/passenger-5.0.29/buildout/apache2/mod_passenger.so into server: /home/centos/sina/vendor/bundle/ruby/2.2.0/gems/passenger-5.0.29/buildout/apache2/mod_passenger.so: cannot open shared object file: Permission denied

cannot open shared object file: Permission denied
Permission関係なので、SELinuxの設定を変えてみます

[root@localhost sina]# /etc/rc.d/init.d/httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]

apacheの起動はできた

http://localhost/にアクセスしてみます

エラーがでる

[root@localhost sina]# curl 'http://localhost/'
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /
on this server.</p>
<hr>
<address>Apache/2.2.15 (CentOS) Server at localhost Port 80</address>
</body></html>
[root@localhost sina]# 

apacheのエラーログを調べてみる
まず、error_logのありかを調べる

・結果表示
/var/log/httpd/error_log

エラーを表示してみる

・表示結果
  :
    :
[Sat Jun 25 05:17:15 2016] [error] [client ::1] (13)Permission denied: access to / denied

(13)Permission denied: access to / denied
で、Googleに聞いてみる
ユーザホームディレクトリのパーミッションが原因のようだ

http://dqn.sakusakutto.jp/2010/05/apache_13permission_denied_acc.html
http://toybox-v2.blogspot.jp/2011/10/13permission-denied-access-to-denied.html
(13)Permission denied: access to hoge denied の対処

Permissionを変えてみる

まず、現状を調べる

・表示結果
合計 12
drwxr-xr-x.  3 root   root   4096  6月 22 05:18 2016 .
dr-xr-xr-x. 25 root   root   4096  6月 25 04:16 2016 ..
drwx------. 33 centos centos 4096  6月 25 05:00 2016 centos

実行権限を付与する

・表示結果
合計 12
drwxr-xr-x.  3 root   root   4096  6月 22 05:18 2016 .
dr-xr-xr-x. 25 root   root   4096  6月 25 04:16 2016 ..
drwxr-xr-x. 33 centos centos 4096  6月 25 05:00 2016 centos
[root@localhost sina]# 

実行権限が付与された

drwx------. 33 centos centos 4096  6月 25 05:00 2016 centos
  ↓↓
drwxr-xr-x. 33 centos centos 4096  6月 25 05:00 2016 centos

もう一度行ってみる

[root@localhost sina]# curl 'http://localhost/'
Hello World[root@localhost sina]#

うまく表示された

Firfoxからhttp://localhost/を呼んでも、うまくいった

再起動して確認してましす

必要はファイルなどは、保存後、アプリを終了しておいて、下さい。

リブートします

SELinuxを確認

[centos@localhost ~]$ getenforce
Enforcing
[centos@localhost ~]$ 

Enforcing → SELinux機能、アクセス制御が有効

無効に設定する

/etc/selinux/config
ファイルの
SELINUX=enforcing

SELINUX=disabled
に変更します

apacheの状態を調べる

httpd は停止しています
[centos@localhost ~]$ 

httpd          	0:off	1:off	2:off	3:off	4:off	5:off	6:off

httpd          	0:off	1:off	2:on	3:on	4:on	5:on	6:off

レベル2から5がon(自動起動)になる

再度、リブートしてみます

SELinuxを確認

[centos@localhost ~]$ getenforce
Disabled
[centos@localhost ~]$ 

無効なのでOK

apacheの状態を調べる

[sudo] password for centos: 
httpd (pid  2021) を実行中...
[centos@localhost ~]$ 

実行中なのでOK

localhostにアクセスしてみる

[centos@localhost ~]$ curl 'http://localhost/'
Hello World[centos@localhost ~]$ 

接続できた

Firfox
http://localhost/
にアクセスする

Hello World

無事表示されました