Skip to content

Instantly share code, notes, and snippets.

@ericlbarnes
Last active January 8, 2016 00:32
Show Gist options
  • Save ericlbarnes/8077336 to your computer and use it in GitHub Desktop.
Save ericlbarnes/8077336 to your computer and use it in GitHub Desktop.
vagrant
# File - vagrant/apache2.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName domain
.app
ServerAdmin webmaster@localhost
DocumentRoot /var/www/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/public>
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.html
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
# File - vagrant/setup.sh
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib
sudo apt-get install -y php5 apache2 php5-dev php5-pgsql php5-mcrypt php5-curl php-apc php5-xdebug php5-gd
# Postgres
echo ">>> Configuring Postgres"
sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /etc/postgresql/9.1/main/postgresql.conf
echo "host all all 0.0.0.0/0 md5" | sudo tee -a /etc/postgresql/9.1/main/pg_hba.conf
sudo service postgresql start
sudo -u postgres psql -c "CREATE ROLE root LOGIN UNENCRYPTED PASSWORD 'password' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;"
sudo -u postgres /usr/bin/createdb --echo --owner=root databasename
sudo service postgresql start
# PHP Config
echo ">>> Configuring PHP"
sudo pecl install mailparse
echo "extension=mailparse.so" | sudo tee -a /etc/php5/apache2/php.ini
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini
# Setup Apache
echo ">>> Configuring Apache"
sudo a2enmod rewrite
sudo cp /vagrant/vagrant/apache2.conf /etc/apache2/sites-available/000-default.conf
sudo service apache2 restart
sudo service postgresql restart
# Snappy
cd /vagrant
php artisan migrate --seed --env=local
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 5432, host: 54320
config.vm.synced_folder "./", "/var/www", owner: "www-data", group: "www-data", :mount_options => [ "dmode=777", "fmode=777" ]
config.vm.provision :shell, :path => "vagrant/setup.sh"
end
@rodrigore
Copy link

How do you connect to postgres with a external client (like Navicat, Induction)?


Edit:

I solved: postgres://root@127.0.0.1:54320/vagrant

Hostname: 127.0.0.1
Username: root
Port: 54320
Database: vagrant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment