简体   繁体   中英

Unable to get php to work in /home/user/public_html

I am configuring my own web server in AWS AMI Linux. I configured httpd to run in /home/user/public_html but PHP won't work in it. May I know what are the configurations to any conf files or php.ini which I need to change?

I installed php5.6 and apache2.4 on AWS Linux AMI. I can run php -v and it shows

PHP 5.6.32 (cli) (built: Nov 13 2017 22:50:59)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

I got it running in /var/www/html but when I changed the httpd.conf to use /home/user/public_html, PHP does not work. The .php files shows

<?php ....some php code.... ?>

The fact it is showing the code and not running the code means you have not loaded the PHP module into apache or you have not associated the .php extension with the module.

The lines you need to look for in your httpd.conf are things like:

AddType application/x-httpd-php .php    
LoadModule php5_module        modules/libphp5.so

Note that AddType sets up the association of .php with the mime type x-hhtpd-php which is what the module then looks to handle. Also note that they LoadModule can supply a complete path but usually on Lunix/Unix these modules would be installed under the Apache installation path in the modules directory (look for all the .so files that appear in LoadModule commands inside httpd.conf).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM