简体   繁体   English

PHP 在 EC2 + ubuntu + apache2 中的虚拟主机上不起作用

[英]PHP doesn't work on virtual host in EC2 + ubuntu + apache2

PHP doesn't work. PHP 不起作用。

Development environment is the below.开发环境如下。

  • EC2 Server EC2服务器
  • Apache/2.4.7 Apache/2.4.7
  • PHP 5.5.9-1ubuntu4.9 PHP 5.5.9-1ubuntu4.9

If I set DocumentRoot /var/www/html , php works well.如果我设置 DocumentRoot /var/www/html ,php 运行良好。

On the other hand if I set /home/ubuntu/public_html , php doesn't work, but html works.另一方面,如果我设置/home/ubuntu/public_html ,php 不起作用,但 html 起作用。

$ vi /etc/apache2/sites-available/000-default.conf

    ServerAdmin webmaster@localhost
    DocumentRoot /home/ubuntu/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

I resolved it by the below method.我通过以下方法解决了它。

sudo vi /etc/apache2/mods-enabled/php5.conf须藤vi /etc/apache2/mods-enabled/php5.conf

▼Before ▼之前

php_admin_flag engine Off php_admin_flag 引擎关闭

▼Change ▼变化

php_admin_flag engine On php_admin_flag 引擎开启

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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