Compare commits

..

28 commits
v1.0 ... master

Author SHA1 Message Date
bfc48b1583
Update default.rb 2021-03-02 14:06:30 +01:00
8f95f8f8b8 Changing MySQL user 2020-12-29 13:36:36 +01:00
388d25652f Changing MySQL user 2020-12-29 13:35:27 +01:00
b70a93f595
Update mysql-50-server.cnf 2020-12-29 13:27:49 +01:00
17ff919f72 Adding MySQL log folder 2020-12-29 13:11:49 +01:00
f7e194dca5
Update mail.php 2020-12-29 10:31:17 +01:00
f7eff3c3df
Update mail.php 2020-12-29 10:30:54 +01:00
074e0a1928
Update default.rb 2020-12-28 19:38:56 +01:00
5678637de3
Update default.rb 2020-01-22 15:28:50 +01:00
82ec3f81e8
Update README.md 2020-01-22 14:59:39 +01:00
5eeffb9542
Update README.md 2020-01-22 14:59:06 +01:00
dad5904d3f
Bugfix 2020-01-22 14:58:08 +01:00
ed3f51dfd1
Update default.rb 2020-01-22 14:38:43 +01:00
4187167f3f
Update README.md 2020-01-22 14:36:24 +01:00
0e912a84bc
Fixing Mysql boot 2020-01-22 14:32:46 +01:00
85f1d26468
Fixing MySQL boot 2020-01-22 14:32:19 +01:00
76e2b399cd
Upgrade PHP+ Upgrade MariaDB 2020-01-22 14:31:44 +01:00
9ff87bbe3f
Update Vagrantfile 2020-01-22 11:57:46 +01:00
f86467c1fb
Adding Chef custom configuration file 2019-11-13 21:18:21 +01:00
62dc7fc33d
Fixing Chef license issue 2019-11-13 21:17:50 +01:00
292f7e8ada
Update create-vhost.sh 2018-09-25 13:02:07 +02:00
42ca253820
Update create-vhost.sh 2018-09-25 12:59:15 +02:00
5e6481b61a
Update README.md 2018-09-24 10:22:06 +02:00
c45b886e91
Update README.md 2018-09-04 12:07:30 +02:00
b04d238715
Update README.md 2018-09-04 12:05:58 +02:00
677855954e
Adding support for Landrush 2018-09-04 11:39:59 +02:00
ce42c0c2a9
Upgrading to PHP7.2 2018-06-12 11:04:30 +02:00
9f34795e82
Upgrade nodejs 10 2018-06-11 17:56:37 +02:00
9 changed files with 99 additions and 137 deletions

1
CustomConfiguration.chef Normal file
View file

@ -0,0 +1 @@
Chef::Config.chef_license = 'accept'

View file

@ -3,11 +3,11 @@
## Description
This repository contains a starter kit providing a fully functional **Ubuntu Server 16.04 LTS** (headless) LAMP local development environment on top of Vagrant.
This repository contains a starter kit providing a fully functional **Ubuntu Server 18.04 LTS** (headless) LAMP local development environment on top of Vagrant.
This starter kit uses a virtualization application (**VirtualBox**), a virtualization wrapper (**Vagrant**) and a recipes manager (**Chef Solo**). See "[Installation](#installation)" below.
The Vagrant Virtual Machine (or VM) will run a Ubuntu Server instance. The **box image used was created by me**. It is hosted on VagrantUp as [axeloz/ubuntu-server-16.04](https://app.vagrantup.com/axeloz/boxes/ubuntu-server-16.04). It is a clean install of Ubuntu with just a little bit of configuration in it. You may use a different box or use your own by editing the `config.vm.box` setting into the [Vagrantfile](https://github.com/axeloz/vagrant-lamp/blob/master/Vagrantfile). I highly recommend to use an Ubuntu distribution. It might also work on Debian but this is untested. Changing the Vagrant box is at your own risk as I cannot guaranty the compatibility.
The Vagrant Virtual Machine (or VM) will run a Ubuntu Server instance. The Ubuntu box is hosted on VagrantUp as [hashicorp/bionic64](https://app.vagrantup.com/hashicorp/boxes/bionic64). It is a clean install of Ubuntu with just a little bit of configuration in it. You may use a different box or use your own by editing the `config.vm.box` setting into the [Vagrantfile](https://github.com/axeloz/vagrant-lamp/blob/master/Vagrantfile). I highly recommend to use an Ubuntu distribution. It might also work on Debian but this is untested. Changing the Vagrant box is at your own risk as I cannot guaranty the compatibility.
### Why should I use this starter kit?
@ -41,12 +41,10 @@ Let me know if you encounter any issue.
- Browser Sync (https://www.browsersync.io)
- CURL (https://curl.haxx.se)
- Deployer (https://deployer.org)
- Drush@8.1.10 (https://github.com/drush-ops/drush)
- Drupal Console (https://drupalconsole.com/)
- Git (https://git-scm.com/)
- Git-LFS (https://git-lfs.github.com)
- Gulp (http://gulpjs.com/)
- PHP7.1 (http://www.php.net) :
- PHP7.4 (http://www.php.net) :
- CURL
- Dev
- GD
@ -70,7 +68,7 @@ Let me know if you encounter any issue.
- MongoDB (https://www.mongodb.com/)
- Multitail (https://www.vanheusden.com/multitail/)
- Nano
- NodeJS 7 (https://nodejs.org/en/) et NPM (https://www.npmjs.com/)
- NodeJS 7 (https://nodejs.org/en/) et YARN (http://yarnpkg.com)
- NTPDate
- Redis (https://redis.io/)
- SASS (http://sass-lang.com)
@ -85,6 +83,7 @@ Need more tools? See [Contributing](#contributing)
- Download and install VirtualBox (http://www.virtualbox.org/)
- Download and install Vagrant (https://www.vagrantup.com/)
- Install Landrush plugin `vagrant plugin install landrush`
- Clone the latest version of this repository (https://github.com/axeloz/vagrant-lamp) into your Home directory, wherever you want it to be. For example for Mac: `/Users/my-user/Sites/vagrant-lamp`
- Open your terminal app, `cd` to the `vagrant-lamp` directory
- Run a `vagrant up` command. During the first boot, Vagrant will download the Linux Ubuntu 16.04 box from VagrantUp, create a new VirtualBox VM, boot the VM and run the Chef recipes. This will install all the dependencies, it may take some time.
@ -119,7 +118,8 @@ In order to upgrade, just:
- To sudo in the VM, just run `sudo <command>`. The `vagrant` user belongs to the sudoers and you may `sudo` with no password asked
- The IP address `192.168.99.100` is created by VM
- The VM is also available on hostname `localhost`
- In order to access your local websites: http://localhost:8080
- In order to access your local websites: http://vagrant.vm
- You may use the wildcard: http://*.vagrant.vm
- In order to access Mailcatcher: http://localhost:1080
- In order to access to MariaDB: mysql://vagrant:vagrant@localhost:3307 from the host. Use mysql://vagrant:vagrant@localhost:3306 from the VM.
- In order to access the Mailcatcher's SMTP from the host: smtp://localhost:1025
@ -145,13 +145,13 @@ The SSH identity forwarding is enabled from the host to the VM (`config.ssh.forw
### Apache
#### Access
Your local environment is available from your host computer at the address: http://localhost:8080. This will launch the [projects browser](#projects-browser).
Your local environment is available from your host computer at the address: http://vagrant.vm. This will launch the [projects browser](#projects-browser).
The default document root is: `/vagrant/www`
#### Dedicated Apache virtual host
In some cases, you might need to create a dedicated virtual host to access your projects. For example: http://myproject.local:8080.
In some cases, you might need to create a dedicated virtual host to access your projects. For example: http://myproject.vagrant.vm.
For Mac and Unix systems: in order to do so, the script [create-vhost.sh](https://github.com/axeloz/vagrant-lamp/blob/master/create-vhost.sh) is provided. Make sure it is executable (`chmod +x create-vhost.sh`) and run it from the **host** (`./create-vhost.sh`). Just follow the instructions, the script will then create an entry into the `/etc/hosts` file and will add the virtual host to Apache into the `vagrant-lamp/apache/conf` folder. Finally, it will reload Apache.
@ -224,7 +224,7 @@ For any other unlisted issue, please add a ticket on Github: https://github.com/
When you run a files watcher on the VM, the `watch` command is running on the VM but the watched files are located on the host computer and mounted using NFS on the VM. For this reason, the watcher does not always catch file changes properly. I tried to fix this issue, let me know if you come accross this matter.
For example for Laravel, the `npm run watch` command doesn't seem to work properly. Use `npm run watch-poll` instead.
For example for Laravel, the `yarn run watch` command doesn't seem to work properly. Use `yarn run watch-poll` instead.
## Contributing

7
Vagrantfile vendored
View file

@ -13,8 +13,10 @@ Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "axeloz/ubuntu-server-16.04"
config.vm.box = "hashicorp/bionic64"
config.landrush.enabled = true
config.landrush.tld = 'vm'
#config.ssh.private_key_path="~/.ssh/id_rsa"
config.ssh.username = 'vagrant'
@ -74,7 +76,7 @@ Vagrant.configure("2") do |config|
#vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = "1024"
vb.memory = "2048"
vb.name = "w_vagrant_lamp"
# Fixing issue of VM loosing sync of the date and time while sleeping.
@ -100,6 +102,7 @@ Vagrant.configure("2") do |config|
# SHELL
config.vm.provision "chef_solo" do |chef|
chef.custom_config_path = "CustomConfiguration.chef"
chef.add_recipe "lamp"
end

View file

@ -16,6 +16,8 @@ package 'curl'
package 'unzip'
package 'lsb-release'
package 'ca-certificates'
package 'software-properties-common'
#####################################
# NTPDATE
@ -37,31 +39,31 @@ apt_repository 'php7' do
cache_rebuild true
end
package 'php7.1'
package 'php7.1-curl'
package 'php7.1-dev'
package 'php7.1-gd'
package 'php7.1-json'
package 'php7.1-mysql'
package 'php7.1-readline'
package 'php7.1-xml'
package 'php7.1-intl'
package 'php7.1-mbstring'
package 'php7.4'
package 'php7.4-curl'
package 'php7.4-dev'
package 'php7.4-gd'
package 'php7.4-json'
package 'php7.4-mysql'
package 'php7.4-readline'
package 'php7.4-xml'
package 'php7.4-intl'
package 'php7.4-mbstring'
package 'php7.1-mcrypt'
package 'php-xdebug'
package 'php7.1-zip'
package 'php7.1-sqlite3'
package 'php7.1-msgpack'
package 'php7.1-gmp'
package 'php7.1-geoip'
package 'php7.1-redis'
package 'php7.4-zip'
package 'php7.4-sqlite3'
package 'php7.4-msgpack'
package 'php7.4-gmp'
package 'php7.4-geoip'
package 'php7.4-redis'
#####################################
# MEMCACHE
#####################################
package 'memcached'
package 'php7.1-memcached'
package 'php-memcached'
service 'memcached' do
action [:enable, :start]
@ -72,7 +74,7 @@ end
# APACHE
#####################################
package 'apache2'
package 'libapache2-mod-php7.1'
package 'libapache2-mod-php7.4'
template '/etc/apache2/conf-enabled/users.conf' do
source 'users.conf'
@ -83,7 +85,7 @@ template '/etc/apache2/sites-enabled/000-default.conf' do
manage_symlink_source true
end
template '/etc/php/7.1/apache2/php.ini' do
template '/etc/php/7.4/apache2/php.ini' do
source 'php.ini.erb'
end
@ -101,7 +103,7 @@ end
#####################################
# GIT
#####################################
package 'python-software-properties'
#package 'python-software-properties'
apt_repository 'git-core' do
action :add
@ -134,9 +136,20 @@ end
# MYSQL
#####################################
execute 'add_mariadb_repo' do
user 'root'
command 'apt-key adv --fetch-keys "https://mariadb.org/mariadb_release_signing_key.asc" && add-apt-repository "deb [arch=amd64,arm64,ppc64el] http://mirror.realcompute.io/mariadb/repo/10.4/ubuntu bionic main"'
end
apt_update
package 'mariadb-server'
package 'mariadb-client'
service 'mysql' do
action [:enable]
end
template '/etc/init.d/mysql' do
source 'mysql-init-d'
end
@ -145,6 +158,7 @@ template '/etc/mysql/mariadb.conf.d/50-server.cnf' do
source 'mysql-50-server.cnf'
end
directory '/var/run/mysqld' do
user 'root'
action :create
@ -153,35 +167,57 @@ directory '/var/run/mysqld' do
mode '0775'
end
service 'mysql' do
supports :start => true, :stop => true, :restart => true, :reload => true, :status => true
action [:enable, :reload]
end
execute 'mysql_create_databases' do
user 'vagrant'
user 'root'
notifies :stop, 'service[mysql]', :before
command '/usr/bin/env mysql_install_db'
creates '/vagrant/mysql/data/mysql'
notifies :start, 'service[mysql]', :immediately
end
execute 'mysql_create_user' do
execute 'mysql_create_user_1' do
command '/usr/bin/env mysql -uroot -e "CREATE USER \'vagrant\'@\'%\' IDENTIFIED BY \'vagrant\'; GRANT ALL PRIVILEGES ON *.* TO \'vagrant\'@\'%\' WITH GRANT OPTION;"'
not_if '/usr/bin/env mysql -uroot -e "SELECT User FROM mysql.user WHERE User = \'vagrant\'" |grep vagrant'
not_if '/usr/bin/env mysql -uroot -e "SELECT User FROM mysql.user WHERE User = \'vagrant\' AND Host = \'%\'" |grep vagrant'
end
execute 'mysql_create_user_2' do
command '/usr/bin/env mysql -uroot -e "CREATE USER \'vagrant\'@\'localhost\' IDENTIFIED BY \'vagrant\'; GRANT ALL PRIVILEGES ON *.* TO \'vagrant\'@\'localhost\' WITH GRANT OPTION;"'
not_if '/usr/bin/env mysql -uroot -e "SELECT User FROM mysql.user WHERE User = \'vagrant\' AND Host = \'localhost\'" |grep vagrant'
end
#####################################
# YARN
#####################################
execute 'add_yarn' do
user 'root'
command 'curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list'
creates '/etc/apt/sources.list.d/yarn.list'
end
apt_update
package 'yarn'
#####################################
# NODEJS
#####################################
execute 'install_nodejs' do
user 'root'
command 'curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -'
command 'curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -'
creates '/usr/bin/nodejs'
end
package 'nodejs'
#####################################
# NPM
#####################################
# execute 'install_gulp' do
# user 'root'
# command 'npm install -g npm'
# creates '/usr/bin/npm'
# end
#####################################
# MAILCATCHER
@ -210,48 +246,6 @@ service 'mailcatcher' do
action [:enable, :start]
end
#####################################
# WP_CLI
#####################################
bash 'install_wpcli' do
code <<-EOH
/usr/bin/env curl -sO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
if [ $? -eq 0 ] && [ -f "wp-cli.phar" ]; then
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
fi
EOH
creates '/usr/local/bin/wp'
end
#####################################
# DRUSH
#####################################
# Installs drush@8.1.10
bash 'install_drush' do
code <<-EOH
/usr/bin/env curl -sLO https://github.com/drush-ops/drush/releases/download/8.1.10/drush.phar
if [ $? -eq 0 ] && [ -f "drush.phar" ]; then
chmod +x drush.phar
mv drush.phar /usr/local/bin/drush
fi
EOH
creates '/usr/local/bin/drush'
end
#####################################
# DRUPAL CONSOLE
#####################################
bash 'install_drupal_console' do
code <<-EOH
php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar
if [ $? -eq 0 ] && [ -f "drupal.phar" ]; then
chmod +x drupal.phar
mv drupal.phar /usr/local/bin/drupal
fi
EOH
creates '/usr/local/bin/drupal'
end
#####################################
@ -259,27 +253,17 @@ end
#####################################
execute 'install_browsersync' do
user 'root'
command 'npm install -g browser-sync'
command 'yarn global add browser-sync'
creates '/usr/bin/browser-sync'
end
#####################################
# NPM
#####################################
execute 'install_gulp' do
user 'root'
command 'npm install -g npm'
creates '/usr/bin/npm'
end
#####################################
# BOWER
#####################################
execute 'install_bower' do
user 'root'
command 'npm install -g bower'
command 'yarn global add bower'
creates '/usr/bin/bower'
end
@ -297,7 +281,7 @@ end
# MONGODB
#####################################
package 'mongodb'
service 'mysql' do
service 'mongodb' do
action [:enable, :start]
end

View file

@ -15,11 +15,10 @@
# * Basic Settings
#
user = vagrant
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
pid-file = /vagrant/mysql/mysqld.pid
socket = /vagrant/mysql/mysqld.sock
port = 3306
basedir = /usr
#datadir = /var/lib/mysql
datadir = /vagrant/mysql/data
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
@ -73,7 +72,7 @@ long_query_time = 10
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
log_bin = /vagrant/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
@ -126,4 +125,4 @@ collation-server = utf8mb4_general_ci
# This group is only read by MariaDB-10.0 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.0]
[mariadb-10.0]

View file

@ -108,7 +108,7 @@ case "${1:-''}" in
log_end_msg 0
else
# Could be removed during boot
install -m 755 -o vagrant -g vagrant -d /var/run/mysqld
install -m 755 -o root -g root -d /var/run/mysqld
# Start MariaDB!
/usr/bin/mysqld_safe "${@:2}" 2>&1 >/dev/null | $ERR_LOGGER &

View file

@ -19,13 +19,6 @@ then
fi
# Checking whether /etc/hosts file exists
if [ ! -f "/etc/hosts" ]
then
error "Could not find the /etc/hosts file. I must abort..."
exit 1
fi
echo
echo "= APPLICATION CONFIGURATION ="
echo
@ -124,11 +117,13 @@ append=false
echo
while true
do
read -p "What is the hostname of the vhost you want to add? " hostname
read -p "What is the subdomain of \"vagrant.vm\" would you like to add? " hostname
if [ -z "$hostname" ]
then
error "The hostname cannot be empty, please retry..."
error "The subdomain cannot be empty, please retry..."
else
hostname=
elif [ -f "$vagrantroot/apache/conf/$hostname.conf" ]
then
error "The configuration file '$vagrantroot/apache/conf/$hostname.conf' already exists."
@ -234,31 +229,12 @@ echo
success "Thank you, everything is now fine. We are processing your request"
echo
# Managing the /etc/hosts file
echo "= ADDING HOSTNAME TO LOCAL HOSTS FILE ="
test=`cat /etc/hosts |grep "$hostname"`
if [ $? -ne 0 ]
then
echo "You will have to enter your password."
sudo -- sh -c -e "echo '127.0.0.1 $hostname' >> /etc/hosts"
if [ $? -ne 0 ]
then
error "Could not edit the '/etc/hosts' automatically"
error "You should add the following line manually:"
error " 127.0.0.1 $hostname"
else
success "Hostname successfully added to host's file"
fi
else
success "The '$hostname' entry already exists in '/etc/hosts'"
fi
# Managing the Apache configuration
echo
echo "= ADDING VHOST TO APACHE ="
vhost="<VirtualHost *:80>
ServerName $hostname
ServerName $hostname.vagrant.vm
DocumentRoot $public
<Directory $path>
AllowOverride All
@ -273,7 +249,7 @@ if [ $? -ne 0 ]
then
error "Could not create the '$vagrantroot/apache/conf/$hostname.conf' file automatically"
error "You should create it with the following line manually:"
error " 127.0.0.1 $hostname"
error "$vhost"
else
success "Hostname successfully added to host's file"
fi
@ -294,6 +270,5 @@ echo
echo
success "END, thank you!"
success "You may now access the vhost:"
success "http://$hostname:8080/"
success "http://$hostname.vagrant.vm/"
echo

0
mysql/logs/.gitkeep Normal file
View file

View file

@ -3,8 +3,8 @@
if (isset($_POST['to'])) {
$to = isset($_POST['to']) && !empty($_POST['to']) ? $_POST['to'] : 'noreply@wcie.fr';
$from = isset($_POST['from']) && !empty($_POST['from']) ? $_POST['from'] : 'a.devignon@wcie.fr';
$to = isset($_POST['to']) && !empty($_POST['to']) ? $_POST['to'] : 'noreply@domain.fr';
$from = isset($_POST['from']) && !empty($_POST['from']) ? $_POST['from'] : 'paul@domain.fr';
$subject = isset($_POST['subject']) && !empty($_POST['subject']) ? $_POST['subject'] : 'Test subject';
$message = isset($_POST['message']) && !empty($_POST['message']) ? $_POST['message'] : 'This is a test message';
@ -57,12 +57,12 @@ if (isset($_POST['to'])) {
<form action="mail.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>From:</label>
<input type="email" class="form-control" name="from" value placeholder="noreply@wcie.fr" />
<input type="email" class="form-control" name="from" value placeholder="noreply@domain.fr" />
</div>
<div class="form-group">
<label>To:</label>
<input type="email" class="form-control" name="to" value placeholder="a.devignon@wcie.fr" />
<input type="email" class="form-control" name="to" value placeholder="paul@domain.fr" />
</div>
<div class="form-group">