httpd はデフォルトでインストールされている
[root@falcon21 ~]# yum -y install php php-mbstring
インストール:
php.x86_64 0:5.4.16-46.el7 php-mbstring.x86_64 0:5.4.16-46.el7
依存性関連をインストールしました:
httpd.x86_64 0:2.4.6-88.el7.centos httpd-tools.x86_64 0:2.4.6-88.el7.centos
libzip.x86_64 0:0.10.1-8.el7 mailcap.noarch 0:2.1.41-2.el7
php-cli.x86_64 0:5.4.16-46.el7 php-common.x86_64 0:5.4.16-46.el7
完了しました!
------------------------------------------------------------
[root@falcon21 ~]# vi /etc/httpd/conf/httpd.conf
96 ServerName falcon21.space:80
144 Options Indexes ExecCGI FollowSymLinks
151 AllowOverride All
164 DirectoryIndex index.html index.html.var index.htm index.cgi index.php index.rb
316 #AddDefaultCharset UTF-8
354 TraceEnable off
****************************************
[root@falcon21 ~]# vi /etc/httpd/conf.d/autoindex.conf
23 <Directory "/usr/share/httpd/icons">
24 Options MultiViews
25 AllowOverride None
26 Require all granted
27 </Directory>
---------------------------------------------
[root@falcon21 ~]# rm -f /etc/httpd/conf.d/welcome.conf
[root@falcon21 ~]# rm -f /var/www/error/noindex.html
perl パスを通す
[root@falcon21 ~]# ln -s /usr/bin/perl /usr/local/bin/perl
[root@falcon21 ~]# whereis perl
perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
ドキュメントルート所有者変更
[root@falcon21 ~]# chown hayato. /var/www/html/
Webサーバー起動
[[root@falcon21 ~]# systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@falcon21 ~]# systemctl status httpd -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 日 2019-02-17 13:21:55 JST; 4min 38s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 13643 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 13641 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 13641 (code=exited, status=1/FAILURE)
2月 17 13:21:55 falcon21.space systemd[1]: Starting The Apache HTTP Server...
2月 17 13:21:55 falcon21.space httpd[13641]: AH00526: Syntax error on line 80 of /etc/httpd/conf/httpd.conf:
2月 17 13:21:55 falcon21.space httpd[13641]: NameVirtualHost takes one argument, A numeric IP address:port, or the name of a host
2月 17 13:21:55 falcon21.space systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
2月 17 13:21:55 falcon21.space kill[13643]: kill: cannot find process ""
2月 17 13:21:55 falcon21.space systemd[1]: httpd.service: control process exited, code=exited status=1
2月 17 13:21:55 falcon21.space systemd[1]: Failed to start The Apache HTTP Server.
2月 17 13:21:55 falcon21.space systemd[1]: Unit httpd.service entered failed state.
2月 17 13:21:55 falcon21.space systemd[1]: httpd.service failed.
httpd.confを修正
[root@falcon21 ~]# systemctl start httpd
[root@falcon21 ~]# systemctl status httpd -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since 日 2019-02-17 13:34:11 JST; 18s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 13643 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Main PID: 13667 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─13667 /usr/sbin/httpd -DFOREGROUND
├─13668 /usr/sbin/httpd -DFOREGROUND
├─13669 /usr/sbin/httpd -DFOREGROUND
├─13670 /usr/sbin/httpd -DFOREGROUND
├─13671 /usr/sbin/httpd -DFOREGROUND
└─13672 /usr/sbin/httpd -DFOREGROUND
2月 17 13:34:11 falcon21.space systemd[1]: Starting The Apache HTTP Server...
2月 17 13:34:11 falcon21.space httpd[13667]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf/httpd.conf:80
2月 17 13:34:11 falcon21.space systemd[1]: Started The Apache HTTP Server.
[root@falcon21 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Webページ表示確認
[root@falcon21 ~]# echo test >> /var/www/html/index.html
http://192.168.2.101/ にアクセス ok
falcon21.space ドメインでは、アクセスできない。ssl 設定が必要
[root@falcon21 ~]# rm -f /var/www/html/index.htm
CGI確認
[root@falcon21 ~]# vi /var/www/html/test.cgi
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
print "<title>テスト</title>\n";
print "</head>\n";
print "<body>\n";
print "CGIテスト\n";
print "</body>\n";
print "</html>\n";
~
[root@falcon21 ~]# chmod 755 /var/www/html/test.cgi
http://192.168.2.101/test.cgi にアクセス ok
SSI .shtmlページ確認
[root@falcon21 ~]# vi /var/www/html/test.shtml
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>テスト</title>
</head>
<body>
SSIテスト
<!--#config timefmt="%Y/%m/%d %H:%M:%S" -->
<!--#echo var="DATE_LOCAL" -->
</body>
</html>
~
http://192.168.2.101/test.shtml にアクセス ok
.htaccess アクセス制限ページ確認
[root@falcon21 ~]# vi /var/www/html/.htaccess //アクセス制限ファイル作成
DirectoryIndex index.shtml
[root@falcon21 ~]# vi /var/www/html/index.shtml //アクセスページ作成
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>テスト</title>
</head>
<body>
<p>.htaccessによるWebサーバー設定(例としてDirectoryIndex)の変更テスト</p>
このページのファイル名は<!--#echo var="DOCUMENT_NAME" -->
</body>
</html>
http://192.168.2.101/index.shtml にアクセス ok
テスト確認後、削除
[root@falcon21 ~]# rm -f /var/www/html/.htaccess
PHP確認
[root@falcon21 ~]# vi /var/www/html/info.php
<?php
phpinfo();
?>
http://192.168.2.101/info.php にアクセス ok
***********************