正在加载图片...
libapache2-mod-php5 Enable this module by doing sudo a2enmod php5 which createsa symbolic link /etc/apache2/mods-enabled/php5 pointing to /etc/apache2/mods-availble/php5 Except if you use deprecated PHP code beginning ony byinstead ofphp"(which is highly inadvisable),open,as root,the file /etc/php5/apache2/php.ini,look for the line"short_open_tag= On",change it to"short_open_tag=Off(not including the quotation marks)and add a line of comment(beginning by a semi-colon)giving the reason,the author and the date of this change.This way.if you later want some XML or XHTML file to be served as PHP,will be ignored by PHP instead of being a PHP code mistake Relaunch Apache 2 again: s sudo service apache2 restart Checking PHP 5 installation In /var/www.create a text file called "test php".grant the world (or.at least.Ubuntu user "apache") host/test php"if you deseription of PHF configuration,it proves PHP 5 works with Apache Troubleshooting PHP5 Does your browser ask ifyou want the php file instead of displaying it?If Apache isno actually parsing the php after you restarted it,install libapache2-mod-php5.It is installed when you install the php5 package,but may have been removed inadvertently by packages which need to run a different version of php. Ifsudo a2enmod php5 retumns"S This nodule does not exist!you should purge (not just remove) the libapachemod-php5 package and reinstall it Be sure to clear your browser's cache before testing your site again.To do this in Firefox 4:Edit- Preferences PrivacyHistory:clear your recent historyDetails:choose"Everything"in"Time range to clean"and check only"cache".then click on"Clear now" Remember that.for Apache to be called the URI in your web browser must begin with "http://"If it begins with" the file is read directly by the boser. so you get(X)HTML and CSS,but no PHP.If you didn't configure any host alias or virtual host,then a local URI begins with "http://localhost"."http://127.0.0.1"or http://followed by your IP number If the problem persists,check your PHP file authorisations(it should be readable at least by Ubuntu user"apache").and check if the PHP code is correct.For instance,copy your PHP file,replace your whole PHP file c ()(withou the):if you get the PHPtes page in your web browser,then the problem is in your PHP code,not in Apache or PHP configuratic nor in file permissions.If this doesn't work,then it is a problem of file authorisation,Apache or PHP configuration,cache not emptied,or Apache not runningor not restarted.Use the display of that test file in your web browser to see the list of files influencing PHP behaviour libapache2-mod-php5 Enable this module by doing $ sudo a2enmod php5 which creates a symbolic link /etc/apache2/mods-enabled/php5 pointing to /etc/apache2/mods-availble/php5 . Except if you use deprecated PHP code beginning only by "<?" instead of "<?php" (which is highly inadvisable), open, as root, the file /etc/php5/apache2/php.ini , look for the line "short_open_tag = On", change it to "short_open_tag = Off" (not including the quotation marks) and add a line of comment (beginning by a semi-colon) giving the reason, the author and the date of this change. This way, if you later want some XML or XHTML file to be served as PHP, the "<?xml" tag will be ignored by PHP instead of being seen as a PHP code mistake. Relaunch Apache 2 again: $ sudo service apache2 restart Checking PHP 5 installation In /var/www , create a text file called "test.php", grant the world (or, at least, Ubuntu user "apache") permission to read it, write in it the only line: "<?php phpinfo(); ?>" (without the quotation marks) then, with your web browser, go to the URI "http://localhost/test.php": if you can see a description of PHP5 configuration, it proves PHP 5 works with Apache. Troubleshooting PHP 5 Does your browser ask if you want to download the php file instead of displaying it? If Apache is not actually parsing the php after you restarted it, install libapache2-mod-php5. It is installed when you install the php5 package, but may have been removed inadvertently by packages which need to run a different version of php. If sudo a2enmod php5 returns "$ This module does not exist!", you should purge (not just remove) the libapache2-mod-php5 package and reinstall it. Be sure to clear your browser's cache before testing your site again. To do this in Firefox 4: Edit → Preferences … Privacy → History: clear your recent history → Details : choose "Everything" in "Time range to clean" and check only "cache", then click on "Clear now". Remember that, for Apache to be called, the URI in your web browser must begin with "http://". If it begins with "file://", then the file is read directly by the browser, without Apache, so you get (X)HTML and CSS, but no PHP. If you didn't configure any host alias or virtual host, then a local URI begins with "http://localhost", "http://127.0.0.1" or http://" followed by your IP number. If the problem persists, check your PHP file authorisations (it should be readable at least by Ubuntu user "apache"), and check if the PHP code is correct. For instance, copy your PHP file, replace your whole PHP file content by "<?php phpinfo(); ?>" (without the quotation marks): if you get the PHP test page in your web browser, then the problem is in your PHP code, not in Apache or PHP configuration nor in file permissions. If this doesn't work, then it is a problem of file authorisation, Apache or PHP configuration, cache not emptied, or Apache not running or not restarted. Use the display of that test file in your web browser to see the list of files influencing PHP behaviour
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有