apache2 on ubuntu - php files downloading

前端 未结 6 1766
野的像风
野的像风 2020-12-05 13:08

On my new Ubuntu system, I\'ve managed to get Apache2 up and running for developing my ZendFramework Web Applications...

I\'ve got my available-sites co

相关标签:
6条回答
  • 2020-12-05 13:28

    if firefox downloads your php files it means that your server doesnt have php or the apache php module installed.

    have you install apache php module? if not, then install it, by typing this into a terminal:

    sudo apt-get install libapache2-mod-php5
    

    and if yes, do you have your index.php located in /var/www/?

    Make sure to enable php with the command

    sudo a2enmod php5
    
    0 讨论(0)
  • 2020-12-05 13:33

    If you are using userdir (http://localhost/~user/phpinfo.php) you will want to:

    vi /etc/apache2/mods-enabled/php5.conf
    

    Change

    <IfModule mod_userdir.c>
       <Directory /home/*/public_html>
           php_admin_value engine Off
       </Directory>
    </IfModule>
    

    to comment the php_admin_value

    <IfModule mod_userdir.c>
       <Directory /home/*/public_html>
           #php_admin_value engine Off
       </Directory>
    </IfModule>
    

    then

    service apache2 restart
    
    0 讨论(0)
  • 2020-12-05 13:33

    You need to enable the PHP extension. Do this with the command sudo a2enmod php.

    0 讨论(0)
  • 2020-12-05 13:41

    I have installed php 7.0 and getting the dailog box. I have installed apache php module for 7.0 version and it fix my problem.

    sudo apt-get install libapache2-mod-php7.0

    0 讨论(0)
  • 2020-12-05 13:42

    I'll assume you installed PHP already and installed the PHP module for Apache here...

    Did you restart apache? If not: sudo service apache2 restart

    Make sure that your httpd.conf file is also being executed. If necessary, restart it after making an edit that would cause an error on load. If it doesn't fail to restart, it's not running the .conf file.

    If the problem still continues, close your browser, reopen it, and clear your cache. It might be the browser just caching the page response.

    0 讨论(0)
  • 2020-12-05 13:53

    For me, the solution was to create the following 2 symbolic links:

    ln -s /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php5.conf
    ln -s /etc/apache2/mods-available/php5.load /etc/apache2/mods-enabled/php5.load
    

    and to restart Apache:

    /etc/init.d/apache2 restart
    

    Hitting the http://my_server/test.php file, which has contents:

    <?php
       phpinfo();
    ?>
    

    came right up, and the browser didn't try to download the php file. Didn't have to restart the browser, either.

    0 讨论(0)
提交回复
热议问题