LoginSignup
8
1

More than 1 year has passed since last update.

Apacheでwebページ表示

Posted at

仮想マシンを使用してApacheでwebページ表示する

ポート番号を追加してポートを開放

80番ポートを開放する

firewall-cmd --permanent --zone=public --add-service=http

再起動

firewall-cmd --reload

webサーバーのインストール・起動など

# apacheインストール
sudo yum install httpd

# apache起動コマンド
sudo systemctl start httpd

# 停止コマンド
sudo systemctl stop httpd

# ステータス確認
systemctl status httpd

# 自動起動のコマンド
sudo chkconfig httpd on

webブラウザで開く

http://localhost:8080/にアクセス

スクリーンショット 2021-12-20 22.53.52.png

Apacheの初期画面が表示できる

表示したいhtmlファイルをドキュメントルート配下に配置する

CentOSの公開ディレクトリの確認

/etc/httpd/conf/httpd.confファイルのDocumentRootに記述されているpathがwebサーバーで公開するディレクトリとなっている

中身を確認する

cat /etc/httpd/conf/httpd.conf

以下のようなものが記述されている

DocumentRoot /var/www/html/

上記の場合は/var/www/html/配下にhtmlファイルを置けばwebサーバーを通じて表示できる。

/var/www/htmlにindex.html作成して配置

スクリーンショット 2021-12-20 22.55.09.png

作成したhtmlが表示できる

まとめ

htmlファイルだけじゃなくて、Laravelなども動かしていきたい。

8
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
1