linux環境でのapacheサーバの構成
1883 ワード
デビアン環境で構築したapacheサーバ
ソフトウェアソース使用アリソース
コマンドライン入力を開く
その後、インストールに成功し、/etc/initにアクセスできます.dシステムサービスの表示
入るとapache 2がインストールに成功したことがわかります
では、apacheサービスをどのように開くのでしょうか.
任意の経路でサービスapache 2[start|stop|status]を起動する|停止する|ステータスを表示する
サーバのルートディレクトリは/var/www/htmlです
そこでshellを書いて次回使いやすいようにしました
スクリプトはapacheが起動しているかどうかを判断し、起動していない場合に起動し、リソースマネージャでhtmlファイルのあるパスを開きます.
ソフトウェアソース使用アリソース
コマンドライン入力を開く
sudo apt install apache2
その後、インストールに成功し、/etc/initにアクセスできます.dシステムサービスの表示
入るとapache 2がインストールに成功したことがわかります
では、apacheサービスをどのように開くのでしょうか.
任意の経路でサービスapache 2[start|stop|status]を起動する|停止する|ステータスを表示する
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2017-12-26 08:52:50 CST; 8min ago
Process: 3733 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 3737 (apache2)
Tasks: 7 (limit: 4915)
CGroup: /system.slice/apache2.service
├─3737 /usr/sbin/apache2 -k start
├─3738 /usr/sbin/apache2 -k start
├─3739 /usr/sbin/apache2 -k start
├─3740 /usr/sbin/apache2 -k start
├─3741 /usr/sbin/apache2 -k start
├─3742 /usr/sbin/apache2 -k start
└─3743 /usr/sbin/apache2 -k start
12 26 08:52:50 kali systemd[1]: Starting The Apache HTTP Server...
12 26 08:52:50 kali apachectl[3733]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
12 26 08:52:50 kali systemd[1]: Started The Apache HTTP Server.
正常に起動したサーバのステータスですサーバのルートディレクトリは/var/www/htmlです
そこでshellを書いて次回使いやすいようにしました
スクリプトはapacheが起動しているかどうかを判断し、起動していない場合に起動し、リソースマネージャでhtmlファイルのあるパスを開きます.
#!/bin/bash
test=$(ps aux | grep apache2 | grep -v 'grep' | wc -l)
if [ $test -gt 0 ];then
echo "$(date) httpd is running..."
else echo "$(date) httpd is not running... starting ..."
service apache2 start
fi
nautilus /var/www/html
echo 'run successfully...'
最終的にこのbashファイルに実行可能な権限を追加したことを覚えています.