简体   繁体   中英

PHP not working on apache2 server

I have an apache2 server running with all these installed: apache2 php5 php5-gd php-xml-parser php5-intl php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl

I have created a file test.php:

<?php phpinfo(); ?>

On the server, when opened the web page all that appears is the actual php code, when it should look like this:

在此处输入图片说明

What is the problem I have looked at the apache logs but nothing looks odd.

Any ideas?

Since you're using apache, you need libapache2-mod-php5 to make PHP available to the webserver.

On a debian/ubuntu system, it's generally easiest to use tasksel and select LAMP from there.

When I have had that problem starting fresh, this has been what I forgot. Create the file .htaccess in the website root (same as phpinfo.php) with the following contents.

#allows these file types to be read and displayed
AddType application/x-httpd-php php php4 php3 html htm

Linux, Apache, MySQL, PHP (LAMP) Stacks are pretty simple to setup. Can you maybe link the tutorial you used, so we can see if there are any steps missing?

I would normally use one of these to setup a stack:

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu

http://www.if-not-true-then-false.com/2010/lamp-linux-apache-mysql-php-on-fedora-centos-red-hat-rhel/

http://www.if-not-true-then-false.com/ is rock solid, with loads of theory.

Things that will help us help you:

  • What OS?
  • What Distro?

This normally happens to me if I missed a step in installation.

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