〇ユーザ作成
[root@ns] useradd centos ← 一般ユーザの作成
[root@ns] passwd centos ← centosのパスワード作成
ユーザー centos のパスワードを変更。
新しいパスワード: ← centosのパスワード応答
新しいパスワードを再入力してください: ← centosのパスワード応答(確認)
passwd: 全ての認証トークンが正しく更新できました。
○apacheのインストール
apacheのインストール
rootユーザで
[root@localhost]# yum install httpd ←apacheダウンロードインストール
Is this ok [y/d/N]:y ←yで答える
[root@localhost]# yum install php php-mbstring ← php、php-mbstringインストール
Is this ok [y/d/N]:y ←yで答える
[root@localhost ~]# yum -y install ruby python ← ruby pythonインストール
設定その1
設定ファイルのhttpd.confを修正する。
[root@localhost]# vi /etc/httpd/conf/httpd.conf← httpd設定ファイル編集
ServerAdmin root@localhost ↓ ServerAdmin ne18001@azec.ac.jp ← エラーページ等に表示される管理者メールアドレスを指定 #ServerName www.example.com:80 ↓ ServerName 決めた架空ドメイン:80 ← サーバー名を指定 <Directory "/var/www/html"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs-2.0/mod/core.html#options # for more information. # Options Indexes FollowSymLinks ↓ Options Includes ExecCGI FollowSymLinks ← CGI,SSIの許可
AllowOverride None
↓
AllowOverride All ← .htaccessの許可
AddDefaultCharset UTF-8 ↓ #AddDefaultCharset UTF-8 ← コメントアウト(文字化け対策) #AddHandler cgi-script .cgi ↓ AddHandler cgi-script .cgi .pl .rb .py ← #を外しCGIスクリプトに.pl .rb .pyを追加 修正したら、l上書き保存
その2
[root@centos ~]# chown centos. /var/www/html/ ← ドキュメントルート所有者を変更(centosは例)
[root@centos ~]# ll /var/www/ ← ドキュメントルート所有者変更確認
drwxr-xr-x. 2 root root 6 11月 5 10:47 cgi-bin
drwxr-xr-x. 2 centos centos 6 11月 5 10:47 html
[root@localhost ~]# systemctl stop firewalld←ファイヤーウォール停止。
[root@localhost ~]# systemctl disable firewalld ←自動起動停止
[root@host0 ~]# systemctl start httpd ← 起動
[root@host0 ~]# systemctl enable httpd ← 自動起動
http://LinuxのIPアドレス/
でTesting123の画面が出ればOK
その3 CGI等の確認
[root@localhost]# vi /var/www/html/test.shtml ← SSIテスト用ページ作成
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>テスト</title>
<body>
学籍番号名前 SSIテスト
<!--#config timefmt="%Y/%m/%d %H:%M:%S" -->
<!--#echo var="DATE_LOCAL" -->
</body>
</html>
[root@localhost]# chmod 755 /var/www/html/test.shtml
ブラウザで
http://IPアドレス/test.shtmlにアクセス
Internal Server Errorが表示される。
原因はパーミッションです。
してSSIテスト現時間ページが表示されればOK
PHPの動作確認PHPで簡単なテストページを表示してみる。
[root@localhost]# vi /var/www/html/test.php ← PHPテスト用ページ作成
<?php
phpinfo();
?>
http://IPアドレス/test.phpにアクセスしてphpinfoページが表示されれば
OK