mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Development] Vagrant rework to PHP 7, MySQL 5.6, Apache/FPM, Debian
This commit is contained in:
parent
04f13037f2
commit
1394a489bc
15 changed files with 222 additions and 205 deletions
|
|
@ -1,14 +1,14 @@
|
|||
# Description
|
||||
This configuration includes following software:
|
||||
|
||||
* PHP 5.4.19
|
||||
* MySQL 5.5.32
|
||||
* GIT 1.7.9.5
|
||||
* Debian 8.1
|
||||
* PHP 7.0
|
||||
* MySQL 5.6 Percona Server
|
||||
* Apache 2.2.22
|
||||
* Vim
|
||||
* MC (Midnight commander)
|
||||
* Curl
|
||||
* Composer
|
||||
* Curl
|
||||
* Vim
|
||||
* Git
|
||||
|
||||
# Usage
|
||||
|
||||
|
|
@ -25,6 +25,13 @@ While waiting for Vagrant to start up, you should add an entry into /etc/hosts f
|
|||
10.0.0.200 sylius.dev
|
||||
```
|
||||
|
||||
Setup your db password in parameters.yml
|
||||
|
||||
```
|
||||
parameters:
|
||||
database_password: vagrant
|
||||
```
|
||||
|
||||
From now you should be able to access your Sylius project at [http://sylius.dev/](http://sylius.dev/)
|
||||
|
||||
# Troubleshooting
|
||||
|
|
@ -37,3 +44,10 @@ To view the application logs, run the following commands:
|
|||
$ tail -f /dev/shm/sylius/app/logs/prod.log
|
||||
$ tail -f /dev/shm/sylius/app/logs/dev.log
|
||||
```
|
||||
|
||||
To view the apache logs, run the following commands:
|
||||
|
||||
```bash
|
||||
$ tail -f /var/log/apache2/sylius_error.log
|
||||
$ tail -f /var/log/apache2/sylius_access.log
|
||||
```
|
||||
46
etc/vagrant/Vagrantfile
vendored
46
etc/vagrant/Vagrantfile
vendored
|
|
@ -1,34 +1,22 @@
|
|||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "precise64"
|
||||
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
config.ssh.forward_agent = true
|
||||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
# VirtualBox
|
||||
config.vm.provider :virtualbox do |v, override|
|
||||
override.vm.network "private_network", ip: "10.0.0.200"
|
||||
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||
v.customize ["modifyvm", :id, "--memory", 1024]
|
||||
v.customize ["modifyvm", :id, "--name", "sylius"]
|
||||
end
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.define :sylius do |sylius_config|
|
||||
sylius_config.vm.box = "debian/jessie64"
|
||||
|
||||
# VMWare Workstation
|
||||
config.vm.provider "vmware_workstation" do |v, override|
|
||||
override.vm.box = "puphpet/ubuntu1404-x64"
|
||||
override.vm.network "private_network", ip: "113.0.0.11"
|
||||
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||
v.customize ["modifyvm", :id, "--memory", 1024]
|
||||
v.customize ["modifyvm", :id, "--name", "sylius"]
|
||||
end
|
||||
sylius_config.vm.provider "virtualbox" do |v|
|
||||
v.gui = false
|
||||
v.memory = 1024
|
||||
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
|
||||
end
|
||||
|
||||
nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/
|
||||
config.vm.synced_folder "./../../", "/var/www/sylius", id: "vagrant-root" , :nfs => nfs_setting
|
||||
config.vm.provision :shell do |shell|
|
||||
shell.path = "bootstrap.sh"
|
||||
end
|
||||
sylius_config.vm.synced_folder "./../../", "/var/www/sylius", type: "nfs", mount_options: ['rw', 'vers=3', 'tcp', 'fsc', 'nolock', 'actimeo=2']
|
||||
sylius_config.vm.network "private_network", ip: "10.0.0.200"
|
||||
|
||||
config.vm.provision :puppet do |puppet|
|
||||
puppet.manifests_path = "manifests"
|
||||
puppet.options = ['--verbose']
|
||||
end
|
||||
end
|
||||
# Shell provisioning
|
||||
sylius_config.vm.provision :shell, :path => "shell_provisioner/run.sh"
|
||||
end
|
||||
end
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
set -x
|
||||
sudo apt-get update
|
||||
mkdir -p /etc/puppet/modules
|
||||
|
||||
puppet module install example42/puppi --version 2.1.7 --force
|
||||
puppet module install example42/apache --version 2.1.4 --force
|
||||
puppet module install puppetlabs/stdlib --version 4.1.0 --force
|
||||
puppet module install puppetlabs/apt --version 1.4.0 --force
|
||||
puppet module install example42/php --version 2.0.17 --force
|
||||
puppet module install puppetlabs/mysql --version 2.1.0 --force
|
||||
puppet module install willdurand/composer --version 1.1.0 --force
|
||||
puppet module install maestrodev/wget --version 1.2.3 --force
|
||||
puppet module install elasticsearch/elasticsearch --force
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
$host_name = "sylius.dev"
|
||||
$db_name = "sylius"
|
||||
|
||||
group { 'puppet': ensure => present }
|
||||
Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] }
|
||||
File { owner => 0, group => 0, mode => 0644 }
|
||||
|
||||
file { "/dev/shm/sylius":
|
||||
ensure => directory,
|
||||
purge => true,
|
||||
force => true,
|
||||
owner => vagrant,
|
||||
group => vagrant
|
||||
}
|
||||
|
||||
file { "/var/lock/apache2":
|
||||
ensure => directory,
|
||||
owner => vagrant
|
||||
}
|
||||
|
||||
exec { "ApacheUserChange" :
|
||||
command => "sed -i 's/export APACHE_RUN_USER=.*/export APACHE_RUN_USER=vagrant/ ; s/export APACHE_RUN_GROUP=.*/export APACHE_RUN_GROUP=vagrant/' /etc/apache2/envvars",
|
||||
require => [ Package["apache"], File["/var/lock/apache2"] ],
|
||||
notify => Service['apache'],
|
||||
}
|
||||
|
||||
class {'apt':
|
||||
always_apt_update => true,
|
||||
}
|
||||
|
||||
Class['::apt::update'] -> Package <|
|
||||
title != 'python-software-properties'
|
||||
and title != 'software-properties-common'
|
||||
|>
|
||||
|
||||
apt::key { '4F4EA0AAE5267A6C': }
|
||||
|
||||
# when bumping the php version again, please
|
||||
# have a look at the PPA documentary in order to provide a proper PPA alias:
|
||||
# https://launchpad.net/~ondrej/+archive/ubuntu/php5
|
||||
apt::ppa { 'ppa:ondrej/php5':
|
||||
require => Apt::Key['4F4EA0AAE5267A6C']
|
||||
}
|
||||
|
||||
package { [
|
||||
'build-essential',
|
||||
'vim',
|
||||
'curl',
|
||||
'git-core',
|
||||
'mc',
|
||||
'openjdk-7-jre-headless'
|
||||
]:
|
||||
ensure => 'installed',
|
||||
}
|
||||
|
||||
class { 'apache': }
|
||||
|
||||
apache::dotconf { 'custom':
|
||||
content => 'EnableSendfile Off',
|
||||
}
|
||||
|
||||
apache::module { 'rewrite': }
|
||||
|
||||
apache::vhost { "${host_name}":
|
||||
server_name => "${host_name}",
|
||||
serveraliases => [
|
||||
"www.${host_name}"
|
||||
],
|
||||
docroot => "/var/www/sylius/web/",
|
||||
port => '80',
|
||||
env_variables => [
|
||||
'VAGRANT VAGRANT'
|
||||
],
|
||||
priority => '1',
|
||||
}
|
||||
|
||||
class { 'php':
|
||||
service => 'apache',
|
||||
service_autorestart => false,
|
||||
}
|
||||
|
||||
php::module { 'mysql': }
|
||||
php::module { 'cli': }
|
||||
php::module { 'curl': }
|
||||
php::module { 'intl': }
|
||||
php::module { 'mcrypt': }
|
||||
php::module { 'gd': }
|
||||
php::module { 'apc':
|
||||
module_prefix => 'php-',
|
||||
}
|
||||
|
||||
class { 'php::devel':
|
||||
require => Class['php'],
|
||||
}
|
||||
|
||||
class { 'php::pear':
|
||||
require => Class['php'],
|
||||
}
|
||||
|
||||
php::pecl::module { 'mongo':
|
||||
use_package => "no",
|
||||
}
|
||||
|
||||
class { 'composer':
|
||||
command_name => 'composer',
|
||||
target_dir => '/usr/local/bin',
|
||||
auto_update => true,
|
||||
require => Package['php5', 'curl'],
|
||||
}
|
||||
|
||||
php::ini { 'php_ini_configuration':
|
||||
value => [
|
||||
'extension=mongo.so',
|
||||
'date.timezone = "UTC"',
|
||||
'display_errors = On',
|
||||
'error_reporting = -1',
|
||||
'short_open_tag = 0',
|
||||
],
|
||||
notify => Service['apache'],
|
||||
require => Class['php']
|
||||
}
|
||||
|
||||
class { 'mysql::server':
|
||||
override_options => { 'root_password' => '', },
|
||||
}
|
||||
|
||||
database{ "${db_name}":
|
||||
ensure => present,
|
||||
charset => 'utf8',
|
||||
require => Class['mysql::server'],
|
||||
}
|
||||
|
||||
database{ "${db_name}_dev":
|
||||
ensure => present,
|
||||
charset => 'utf8',
|
||||
require => Class['mysql::server'],
|
||||
}
|
||||
|
||||
database{ "${db_name}_test":
|
||||
ensure => present,
|
||||
charset => 'utf8',
|
||||
require => Class['mysql::server'],
|
||||
}
|
||||
|
||||
class { 'elasticsearch':
|
||||
ensure => 'present',
|
||||
package_url => 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.4.deb'
|
||||
} ->
|
||||
service { "elasticsearch-service":
|
||||
name => 'elasticsearch',
|
||||
ensure => running
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<VirtualHost *:80>
|
||||
|
||||
ServerName sylius.dev
|
||||
DocumentRoot /var/www/sylius
|
||||
EnableSendfile off
|
||||
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
</Directory>
|
||||
|
||||
<Directory /var/www/sylius/web>
|
||||
Options Indexes FollowSymLinks MultiViews
|
||||
Options -Indexes
|
||||
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
|
||||
</Directory>
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{HTTP:Authorization} ^(.*)
|
||||
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
|
||||
</IfModule>
|
||||
|
||||
ErrorLog /var/log/apache2/sylius_error.log
|
||||
|
||||
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
|
||||
LogLevel warn
|
||||
|
||||
CustomLog /var/log/apache2/sylius_access.log combined
|
||||
|
||||
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php/php7.0-fpm.sock|fcgi://localhost/var/www/sylius/web/
|
||||
|
||||
</VirtualHost>
|
||||
20
etc/vagrant/shell_provisioner/module/apache.sh
Normal file
20
etc/vagrant/shell_provisioner/module/apache.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Apache
|
||||
apt-get install -y apache2 libapache2-mod-fcgid
|
||||
a2enmod rewrite expires headers proxy proxy_http proxy_fcgi actions fastcgi alias ssl
|
||||
|
||||
# Activate vhost
|
||||
a2dissite 000-default
|
||||
|
||||
chmod -R a+rX /var/log/apache2
|
||||
sed -i 's/640/666/' /etc/logrotate.d/apache2
|
||||
|
||||
echo 'Listen 80
|
||||
Listen 443
|
||||
' > /etc/apache2/ports.conf
|
||||
|
||||
cat ${CONFIG_PATH}/apache/sylius.vhost.conf > /etc/apache2/sites-available/${APP_DOMAIN}.conf
|
||||
a2ensite ${APP_DOMAIN}.conf
|
||||
|
||||
service apache2 restart
|
||||
32
etc/vagrant/shell_provisioner/module/debian.sh
Normal file
32
etc/vagrant/shell_provisioner/module/debian.sh
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Debian
|
||||
|
||||
# Locales
|
||||
sed -i 's/# nl_BE.UTF-8 UTF-8/nl_BE.UTF-8 UTF-8/' /etc/locale.gen
|
||||
locale-gen
|
||||
# echo 'LANG=nl_BE.UTF-8' > /etc/default/locale
|
||||
|
||||
# Timezone
|
||||
echo "Europe/Brussels" > /etc/timezone
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
# Console keyboard
|
||||
sed -i 's/XKBLAYOUT=.*/XKBLAYOUT="be"/' /etc/default/keyboard
|
||||
setupcon --force
|
||||
|
||||
# Host file
|
||||
echo 127.0.0.1 $APP_DOMAIN >> /etc/hosts
|
||||
|
||||
# Add dotdeb repository
|
||||
wget https://www.dotdeb.org/dotdeb.gpg
|
||||
sudo apt-key add dotdeb.gpg
|
||||
|
||||
cat << EOF >/etc/apt/sources.list.d/dotdeb.list
|
||||
deb http://packages.dotdeb.org jessie all
|
||||
deb-src http://packages.dotdeb.org jessie all
|
||||
EOF
|
||||
|
||||
# Sync package index files
|
||||
apt-get update
|
||||
|
||||
39
etc/vagrant/shell_provisioner/module/mysql.sh
Normal file
39
etc/vagrant/shell_provisioner/module/mysql.sh
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Percona server (MySQL)
|
||||
|
||||
# Add repository
|
||||
wget -O - http://www.percona.com/redir/downloads/RPM-GPG-KEY-percona | gpg --import
|
||||
gpg --armor --export 1C4CBDCDCD2EFD2A | apt-key add -
|
||||
|
||||
cat << EOF >/etc/apt/sources.list.d/percona.list
|
||||
deb http://repo.percona.com/apt jessie main
|
||||
deb-src http://repo.percona.com/apt jessie main
|
||||
EOF
|
||||
apt-get update
|
||||
|
||||
# Install server and client
|
||||
echo "percona-server-server-5.6 percona-server-server/root_password password vagrant" | debconf-set-selections
|
||||
echo "percona-server-server-5.6 percona-server-server/root_password_again password vagrant" | debconf-set-selections
|
||||
apt-get -y install percona-server-server-5.6 percona-server-client-5.6
|
||||
|
||||
# Configuration
|
||||
sed -i "s/\[mysqld\]/[mysqld]\ninnodb_file_per_table = 1/" /etc/mysql/my.cnf
|
||||
sed -i 's/bind-address.*/bind-address\t\t= 0.0.0.0/' /etc/mysql/my.cnf
|
||||
service mysql restart
|
||||
|
||||
# Add database
|
||||
MYSQLCMD="mysql -uroot -pvagrant -e"
|
||||
$MYSQLCMD "CREATE DATABASE ${APP_DBNAME} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
|
||||
|
||||
$MYSQLCMD "CREATE USER root@'10.0.0.1' IDENTIFIED BY 'vagrant';"
|
||||
$MYSQLCMD "GRANT ALL PRIVILEGES ON *.* TO root@'10.0.0.1';"
|
||||
|
||||
$MYSQLCMD "FLUSH PRIVILEGES;"
|
||||
|
||||
# Install Percona toolkit and enable functions
|
||||
$MYSQLCMD "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'"
|
||||
$MYSQLCMD "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"
|
||||
$MYSQLCMD "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"
|
||||
apt-get install -y percona-toolkit
|
||||
|
||||
17
etc/vagrant/shell_provisioner/module/php.sh
Normal file
17
etc/vagrant/shell_provisioner/module/php.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# PHP
|
||||
|
||||
apt-get -y install php7.0-cli php7.0-fpm php7.0-dev php7.0-curl php7.0-intl \
|
||||
php7.0-mysql php7.0-sqlite3 php7.0-gd php7.0-mbstring php7.0-xml
|
||||
|
||||
sed -i 's/;date.timezone.*/date.timezone = Europe\/Brussels/' /etc/php/7.0/fpm/php.ini
|
||||
sed -i 's/;date.timezone.*/date.timezone = Europe\/Brussels/' /etc/php/7.0/cli/php.ini
|
||||
sed -i 's/^user = www-data/user = vagrant/' /etc/php/7.0/fpm/pool.d/www.conf
|
||||
sed -i 's/^group = www-data/group = vagrant/' /etc/php/7.0/fpm/pool.d/www.conf
|
||||
|
||||
service php7.0-fpm restart
|
||||
|
||||
# composer
|
||||
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin
|
||||
ln -s /usr/bin/composer.phar /usr/bin/composer
|
||||
7
etc/vagrant/shell_provisioner/module/sylius.sh
Normal file
7
etc/vagrant/shell_provisioner/module/sylius.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd /var/www/sylius
|
||||
|
||||
composer install --optimize-autoloader
|
||||
|
||||
php app/console sylius:install --no-interaction
|
||||
4
etc/vagrant/shell_provisioner/module/tools.sh
Normal file
4
etc/vagrant/shell_provisioner/module/tools.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Tools
|
||||
apt-get install -y zip unzip curl git vim
|
||||
26
etc/vagrant/shell_provisioner/run.sh
Normal file
26
etc/vagrant/shell_provisioner/run.sh
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Shell provisioner
|
||||
MODULE_PATH='/vagrant/shell_provisioner/module'
|
||||
CONFIG_PATH='/vagrant/shell_provisioner/config'
|
||||
|
||||
# IP for the vagrant VM
|
||||
GUEST_IP='10.0.0.200'
|
||||
|
||||
#Config
|
||||
APP_DOMAIN='sylius.dev'
|
||||
APP_DBNAME='sylius'
|
||||
|
||||
# Adding an entry here executes the corresponding .sh file in MODULE_PATH
|
||||
DEPENDENCIES=(
|
||||
debian
|
||||
tools
|
||||
php
|
||||
mysql
|
||||
apache
|
||||
sylius
|
||||
)
|
||||
|
||||
for MODULE in ${DEPENDENCIES[@]}; do
|
||||
source ${MODULE_PATH}/${MODULE}.sh
|
||||
done
|
||||
|
|
@ -24,7 +24,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
if (!getenv("SYLIUS_APP_DEV_PERMITTED") && (
|
||||
isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1', '10.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
)) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1', '10.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '113.0.0.1', '10.0.0.1'], true) || php_sapi_name() === 'cli-server')
|
||||
) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue