LoginSignup
0
0

More than 1 year has passed since last update.

サブドメインを使ってPHPを動作させる方法

Last updated at Posted at 2022-06-21
../

既存のサーバー、既存のドメインで httpd + Tomcat が動作している環境で、テスト的にPHPを試してみたい場合の最も簡単な方法は、サブドメインを使う方法かなと思う。例えば、既に kankeri.com で httpd + Tomcatが動作している場合、Tomcatに干渉しないでPHPをテストしたいときは、php.kankeri.com のようなサブドメインを使うと非常に簡単である。

ただし、委任先のDNSサーバにサブドメインを追加する作業が必要であり、反映されるまで若干待つかもしれない。CNAMEを1行追加するだけである。以下の感じである。

php 	CNAME 	kankeri.com.

そして、httpdのVirtualHostに php.kankeri.com:80 を追加する。以下の感じである。例えば、vhost-php.conf を作成して記述する。phpのコードは、/opt/php74/webapps/php に置く場合で示している。

vhost-php.conf
$ vi /etc/httpd/conf.d/vhost-php.conf 
<VirtualHost php.kankeri.com:80>
	ServerName php.kankeri.com
	ServerAdmin webmaster@kankeri.com
	DocumentRoot "/opt/php74/webapps/php"
	DirectoryIndex index.php index.html index.htm

	<Directory "/opt/php74/webapps/php">
	    Options FollowSymLinks
	    AllowOverride None
	    Require all granted
	</Directory>
	ErrorLog  logs/php-error_log
	CustomLog logs/php-access_log combined
</VirtualHost>

既存の kankeri.com:80 に干渉しないので、構築しやすく、テストしやすいと思う。
サブドメインを使いたくない場合は「 CentOS Stream 8でNginxとTomcatを共存させる手順」を参照のこと。

../
0
0
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
0
0