AH00558:apache2:Could notreliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName'directive globally tosuppress thismessage
Syntax OK
http://127.0.1.1/
静的な、HTMLのサンプルプログラムを作ってみる
sudo vim /var/www/html/test.html
vimが入っていなかった
vim
sudo apt install vim
sudo vim /var/www/html/test.html
挿入
i
<html>
<hr>
hello
<hr>
</html>
esc :wq
保存終了
http://127.0.1.1/test.html
では、PHPをインストールしてみる
PHPと libapache2-mod-phpをインストール
sudo apt install php libapache2-mod-php
php -v
PHP 7.4.3 (cli) (built: Oct 25 2021 18:20:54) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
バージョンは7.4.3
サンプルプログラムを作ってみる
sudo vim /var/www/html/info.php
挿入
i
<?php
phpinfo();
?>
esc :wq
保存終了
ブラウザーから実行してみる
http://127.0.1.1/info.php
無事起動できた
apacheの状態がどうか確認、起動、停止は
apacheの状態がどうか確認するのは
sudo systemctl status apache2
apacheを停止するのは
sudo systemctl stop apache2
apacheを起動するのは
sudo systemctl start apache2
内容確認
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor pres&gt;
Active: active (running) since Sun 2021-12-12 10:31:30 JST; 1min 46s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 12169 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/&gt;
Main PID: 12174 (apache2)
Tasks: 6 (limit: 6973)
Memory: 9.6M
CGroup: /system.slice/apache2.service
├─12174 /usr/sbin/apache2 -k start
├─12175 /usr/sbin/apache2 -k start
├─12176 /usr/sbin/apache2 -k start
├─12177 /usr/sbin/apache2 -k start
├─12178 /usr/sbin/apache2 -k start
└─12179 /usr/sbin/apache2 -k start
12月 12 10:31:30 Lenovo systemd[1]: Starting The Apache HTTP Server…
12月 12 10:31:30 Lenovo apachectl[12172]: AH00558: apache2: Could not reliably&gt;
12月 12 10:31:30 Lenovo systemd[1]: Started The Apache HTTP Server.
画面が、表示状態なのでqで終了する
apache2を終了
$ sudo systemctl stop apache2
内容確認
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor pres&gt;
Active: inactive (dead) since Sun 2021-12-12 10:34:56 JST; 4s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 12169 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/&gt;
Process: 12413 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SU&gt;
Main PID: 12174 (code=exited, status=0/SUCCESS)
12月 12 10:31:30 Lenovo systemd[1]: Starting The Apache HTTP Server…
12月 12 10:31:30 Lenovo apachectl[12172]: AH00558: apache2: Could not reliably&gt;
12月 12 10:31:30 Lenovo systemd[1]: Started The Apache HTTP Server.
12月 12 10:34:56 Lenovo systemd[1]: Stopping The Apache HTTP Server…
12月 12 10:34:56 Lenovo apachectl[12415]: AH00558: apache2: Could not reliably&gt;
12月 12 10:34:56 Lenovo systemd[1]: apache2.service: Succeeded.
12月 12 10:34:56 Lenovo systemd[1]: Stopped The Apache HTTP Server.
もう一度、起動してみる
$ sudo systemctl start apache2
内容確認
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor pres&gt;
Active: active (running) since Sun 2021-12-12 10:35:28 JST; 4s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 12437 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/&gt;
Main PID: 12441 (apache2)
Tasks: 6 (limit: 6973)
Memory: 10.1M
CGroup: /system.slice/apache2.service
├─12441 /usr/sbin/apache2 -k start
├─12442 /usr/sbin/apache2 -k start
├─12443 /usr/sbin/apache2 -k start
├─12444 /usr/sbin/apache2 -k start
├─12445 /usr/sbin/apache2 -k start
└─12446 /usr/sbin/apache2 -k start
12月 12 10:35:28 Lenovo systemd[1]: Starting The Apache HTTP Server…
12月 12 10:35:28 Lenovo apachectl[12440]: AH00558: apache2: Could not reliably&gt;
12月 12 10:35:28 Lenovo systemd[1]: Started The Apache HTTP Server.