以下は正しく行えている前提で回答致します。
(phpファイル内容が表示できているので問題ないと想定しています。)
- CentOS, PHP, Apacheのインストール
- Firewallの無効化、または適切な設定(HTTPプロトコルの通信許可設定)
- Apacheの設定、起動(/etc/httpd/conf/httpd.conの設定など)
- MySQLは現段階でPHPを動作させる部分には関係ないので除いています
CentOS、Apacheのバージョンが未記載ですが、CentOS7にyumコマンドでインストール可能なApache 2.4.6を想定して回答致します。
検証した環境(ゲストOS:Vagrant上のサーバ)
- CentOS7
- Apache 2.4.6
- php 5.4.16
yumコマンドでApache, phpをインストールすると上記バージョンのApache, phpがインストールされます。
その状態でドキュメントルート(/var/www/html)に記載いただいているphpソースをindex.phpとして保存しブラウザからアクセスすると問題なく「Hello from vagrant」と表示されます。
Apacheの設定ファイルはご認識の通り「/etc/httpd/conf/httpd.conf」ですが、標準では「/etc/httpd/conf.d/」内のxxxx.confも読み込むようになっています。
phpに関しては「/etc/httpd/conf.d/php.conf」に設定があります。
参考に検証した環境のphp.confファイルを以下に記載します。
shell
1#
2# Cause the PHP interpreter to handle files with a .php extension.
3#
4<FilesMatch \.php$>
5 SetHandler application/x-httpd-php
6</FilesMatch>
7
8#
9# Allow php to handle Multiviews
10#
11AddType text/html .php
12
13#
14# Add index.php to the list of files that will be served as directory
15# indexes.
16#
17DirectoryIndex index.php
18
19#
20# Uncomment the following lines to allow PHP to pretty-print .phps
21# files as PHP source code:
22#
23#<FilesMatch \.phps$>
24# SetHandler application/x-httpd-php-source
25#</FilesMatch>
26
27#
28# Apache specific PHP configuration options
29# those can be override in each configured vhost
30#
31php_value session.save_handler "files"
32php_value session.save_path "/var/lib/php/session"
「FilesMatch」ディレクティブ部分と「AddType」にて拡張子がphpのファイルをphpファイルとして扱うように指定されています。
ご自身の環境ではどのようになっていますでしょうか。
調べてみると,CentOSのApacheの設定に問題があるようなので
拡張子がphpのファイルをApacheがphpとして扱えていないように思われますので、上記設定をご確認ください。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/09/10 14:42
2015/09/10 15:15
2015/09/13 05:10
2015/09/13 07:46
2015/09/13 15:52
2015/11/11 04:13 編集
2015/11/10 02:11
2015/11/11 04:12
2015/11/11 16:28