Apache仮想ホストの問題

Apache仮想ホストの問題

私はcentos 7を使ってサーバーをセットアップしていて、ApacheとPHPをインストールしました。 "localhost/xxx.xxx"を避けるために仮想ホストを設定しようとしましたが、現在localhostにアクセスできなくなりました。しかし、仮想ホストとして設定されたWebサイトを作成し、Apacheが動作していた前のページに戻ると、開こうとしているPHPページが開きます。設定された仮想ホストを削除しようとしましたが、何をすべきか覚えていません。

ベストアンサー1

これはノーマル見たら。最初の仮想ホストエントリなので、localhostが表示されます。

しかし、それでも設定できますhttpd.conf

<VirtualHost localhost:80>
    ServerAdmin localhost
    DocumentRoot /path/to/htdocs/
    ServerName localhost
</VirtualHost>

http://yourwebsite.comプロジェクトをローカルのように実行する

<VirtualHost somewebsite.com:80>
    ServerAdmin [email protected]
    DocumentRoot /path/to/htdocs/yourwebsiteFolder
    ServerName www.yourwebsite.com
    ServerAlias yourwebsite.com
</VirtualHost>

次に、次のコマンドを使用してhttpdデーモンを再起動します。sudo systemctl restart httpd.service

仮想ホストの例もっとお手伝いします。

おすすめ記事