I was told on stackoverflow to post this question here:
Scroll down to see result of things I've done based on suggestions
I am setting up my first project using Vagrant. I chose the following package puppetlabs/debian-7.8-64-puppet
for the debian server, because it's the same we are using for our remote development server. Unfortunetely this debian distro only contains the PHP version 5.4, so I tried to install dotdeb so I can use PHP 5.6.11.
I added
deb http://packages.dotdeb.org wheezy all
deb-src http://packages.dotdeb.org wheezy all
deb http://packages.dotdeb.org wheezy-php56 all
deb-src http://packages.dotdeb.org wheezy-php56 all
as mentioned here https://www.dotdeb.org/instructions/ to my /etc/apt/sources.list
and then ran the following commands
wget http://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
## get package list from sources incl. new set source dotdeb
sudo apt-get update
## Install php, APC, gd and cURL
sudo apt-get install -y php5 php5-apcu php5-gd php5-curl
Now, when using php --version
it tells me that I'm using version 5.6.11, so it seems to have worked to install it. But the problem I'm having is, that the webserver doesn't seem to interpret it because it displays the real php code. What am I doing wrong?
Here is my Vagrantfile
without the commentes
config.vm.box = "puppetlabs/debian-7.8-64-puppet"
config.vm.provision :shell, path: "vagrant_ressources/bootstrap.sh"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.synced_folder ".", "/var/www"
And this is my bootstrap.sh
#!/usr/bin/env bash
# Use single quotes instead of double quotes to make it work with special-character passwords
PASSWORD='12345678'
# Update package manager
apt-get update
# Install apache2
sudo apt-get install -y apache2
# Add dotdeb to packages
if [ ! -f /var/log/dotdebconfig ];
then
echo "" | sudo tee --append /etc/apt/sources.list
echo "#dotdeb" | sudo tee --append /etc/apt/sources.list
echo "deb http://packages.dotdeb.org wheezy all" | sudo tee --append /etc/apt/sources.list
echo "deb-src http://packages.dotdeb.org wheezy all" | sudo tee --append /etc/apt/sources.list
echo "deb http://packages.dotdeb.org wheezy-php56 all" | sudo tee --append /etc/apt/sources.list
echo "deb-src http://packages.dotdeb.org wheezy-php56 all" | sudo tee --append /etc/apt/sources.list
wget http://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
## get package list from sources incl. new set source dotdeb
sudo apt-get update
## Install php, APC, gd and cURL
sudo apt-get install -y php5 php5-apcu php5-gd php5-curl
touch /var/log/dotdebconfig
fi
#install mysql and give password to installer
if [ ! -f /var/log/mysqlconfig ];
then
# Set passwords
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $PASSWORD"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $PASSWORD"
# Install MySQL Server and cURL
sudo apt-get -y install mysql-server
sudo apt-get -y install php5-mysql
touch /var/log/mysqlconfig
fi
if [ ! -f /var/log/XXXXXX ];
then
mkdir -p /var/www/htdocs
# Install XXXXXX vhost
sudo a2dissite default
sudo a2enmod rewrite
cd /etc/apache2/sites-available
# copy default vhost conf to sites-available
sudo cp /var/www/vagrant_ressources/XXXXXX.vhost.conf XXXXXX.dev
sudo a2ensite XXXXXX.dev
touch /var/log/XXXXXX
fi
sudo /etc/init.d/apache2 restart
And this is my XXXXXX.vhost.conf (don't know if its needed)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/htdocs
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/htdocs/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Suggestions
Someone told me: "Try installing libapache2-mod-php5"
However, it seems like it's already on my server, because I'm getting the following error message: libapache2-mod-php5 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
Best Answer
Check if php is added to apache configuration.
At least you have to have a line similar to this in your apache conf:
and or a line like this:
If it's the problem, you have to add:
There are some more extra parameters you may tune, full documentation oh how to is here: here
If it's everything in place and still not working, then take a look on if you have the php module installed by issuing
dpkg -l |grep mod-php
Try maybe to reinstall removing it withpurge
and installing it again