vagrant php not working ?

906 views
Skip to first unread message

Ricky Spires

unread,
Jul 26, 2015, 4:36:33 AM7/26/15
to Vagrant
Hello.

When I run vagrant php is not working.

I have added a info.php file but It asks me to download if I want to view it.

In terminal i can view the php version

$ php -v
PHP
5.5.19


If I ssh in I get

vagrant@precise32:~$ php -v
PHP
5.3.10-1ubuntu3.19 with Suhosin-Patch (cli) (built: Jul  2 2015 15:05:54)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies


Is it the dismatch of version numbers ?

this is my shell script:


#!/usr/bin/env bash

apt
-get
apt
-get install -y vim

# Apache
# ------

# Install
apt
-get install -y apache2

# Remove /var/www default
rm
-rf /var/www

# Symlink /vagrant to /var/www
ln
-fs /vagrant /var/www

# Add ServerName to httpd.conf
echo
"ServerName localhost" > /etc/apache2/httpd.conf

# Setup hosts file
VHOST
=$(cat <<EOF
<VirtualHost *:80>
 
DocumentRoot "/vagrant/public"
 
ServerName localhost
 
<Directory "/vagrant/public">
   
AllowOverride All
 
</Directory>
</
VirtualHost>
EOF
)
echo
"${VHOST}" > /etc/apache2/sites-enabled/000-default

# Enable mod_rewrite
a2enmod rewrite

# Restart apache
service apache2 restart

# PHP 5.4
# -------
apt
-get install -y libapache2-mod-php5
# Add add-apt-repository binary
apt
-get install -y python-software-properties
# Install PHP 5.4
add
-apt-repository ppa:ondrej/php5
# Update
apt
-get update


# PHP stuff
# ---------
# Command-Line Interpreter
apt
-get install -y php5-cli
# MySQL database connections directly from PHP
apt
-get install -y php5-mysql
# cURL is a library for getting files from FTP, GOPHER, HTTP server
apt
-get install -y php5-curl
# Module for MCrypt functions in PHP
apt
-get install -y php5-mcrypt

# cURL
# ----
apt
-get install -y curl


# Mysql
# -----
# Ignore the post install questions
export DEBIAN_FRONTEND=noninteractive
# Install MySQL quietly
apt
-get -q -y install mysql-server-5.5


# Git
# ---
apt
-get install git-core


# Install Composer
# ----------------
curl
-s https://getcomposer.org/installer | php
# Make Composer available globally
mv composer
.phar /usr/local/bin/composer



Thanks
Ricky

Marco De Bortoli

unread,
Jul 26, 2015, 6:55:59 AM7/26/15
to Vagrant
Hi Ricky,

surely, if you developed your application using features specific for PHP 5.5 and you are trying to run those on PHP 5.3 you will have hard time, but that's beyond vagrant. Vagrant won't solve that problem for you.

I hope it helps.

Best,
Debo

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/fcf7bd44-4dca-49b8-9d8f-78fe38f9225a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ricky Spires

unread,
Jul 26, 2015, 3:19:09 PM7/26/15
to Vagrant, marco.debo...@gmail.com
hello.

Thank you for the reply.

The thing is, I am not running any application at the monent. All a am trying to do at this moment is get phpinfo.php to work without the browser trying to download it.

my file structure is

.vagrant
public
      index.html
      phpinfo.php
shell
      custom-bootstrap.sh
Vagrantfile

That's it.

??


 

Alvaro Miranda Aguilera

unread,
Jul 26, 2015, 6:11:06 PM7/26/15
to vagra...@googlegroups.com, marco.debo...@gmail.com
Can you restart/reload apache?

In your script I didn't saw you did that after installing apache.

That will explain why your client tries to download the file instead
of displaying the content by php.
> https://groups.google.com/d/msgid/vagrant-up/19b933eb-65b1-452e-8881-7dc0396a1a5f%40googlegroups.com.

Ricky Spires

unread,
Jul 28, 2015, 5:05:06 AM7/28/15
to vagra...@googlegroups.com
Hello.

Thanks for your replies.

I got it working.

this is my new shell script.

<code>

#!/bin/bash
cat /vagrant/shell/self-promotion.txt
# Update the box
# --------------
# Downloads the package lists from the repositories
# and "updates" them to get information on the newest
# versions of packages and their dependencies
apt-get update

# Install Vim

apt-get install -y vim

# Apache
# ------
# Install
apt-get install -y apache2

# Remove /var/www default
rm -rf /var/www
# Symlink /vagrant to /var/www
ln -fs /vagrant /var/www
# Add ServerName to httpd.conf
echo "ServerName localhost" > /etc/apache2/httpd.conf

# Setup hosts file
VHOST=$(cat <<EOF
<VirtualHost *:80>
DocumentRoot "/vagrant/public"
ServerName localhost
<Directory "/vagrant/public">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
Satisfy Any

</Directory>
</VirtualHost>
EOF
)
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default

# Enable mod_rewrite
a2enmod rewrite
# Restart apache
service apache2 restart

# Mysql
# -----
# Ignore the post install questions
export DEBIAN_FRONTEND=noninteractive
# Install MySQL quietly
apt-get -q -y install mysql-server-5.5

# PHP 5.5
# -------
apt-get install -y php5 libapache2-mod-php5
# Update
apt-get update

# httpd.conf setup
echo "ServerName localhost" >> /etc/apache2/apache2.conf


# Restart apache
service apache2 restart

# PHP stuff
# ---------
# Command-Line Interpreter
apt-get install -y php5-cli
# MySQL database connections directly from PHP
apt-get install -y php5-mysql
# cURL is a library for getting files from FTP, GOPHER, HTTP server
apt-get install -y php5-curl
# Module for MCrypt functions in PHP
apt-get install -y php5-mcrypt
# GD
apt-get install -y php5-gd
# Pear
apt-get install -y php-pear


# cURL
# ----
apt-get install -y curl

# Restart apache
service apache2 restart

# Git
# ---
apt-get install git-core

# Install Composer
# ----------------
curl -s https://getcomposer.org/installer | php
# Make Composer available globally
mv composer.phar /usr/local/bin/composer
</code>

You received this message because you are subscribed to a topic in the Google Groups "Vagrant" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vagrant-up/fH_sYoXH95o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0ey2LnFmDmB6HuGvJLqjtok5Uth-NJxHQtYGvJcGb5sSRg%40mail.gmail.com.

Marco De Bortoli

unread,
Jul 28, 2015, 5:17:11 AM7/28/15
to vagra...@googlegroups.com
Oh that's great news, good to hear.

Cheers,
Debo

Reply all
Reply to author
Forward
0 new messages