Skip to content

Commit 0e71060

Browse files
committed
Update Vagrantfile
1 parent e0e99b1 commit 0e71060

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

Vagrantfile

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Vagrant.configure("2") do |config|
2222
#config.vm.network "forwarded_port", guest: 3306, host: 3307, host_ip: "127.0.0.1"
2323
# PostgreSQL server
2424
#config.vm.network "forwarded_port", guest: 5432, host: 5433, host_ip: "127.0.0.1"
25+
# Memcached server
26+
#config.vm.network "forwarded_port", guest: 11211, host: 11212, host_ip: "127.0.0.1"
27+
# Redis server
28+
#config.vm.network "forwarded_port", guest: 6379, host: 6380, host_ip: "127.0.0.1"
2529

2630
# Add "192.168.10.10 ${VIRTUALHOST}" in your host file to access by domain
2731
#config.vm.network "private_network", ip: "192.168.10.10"
@@ -43,11 +47,11 @@ Vagrant.configure("2") do |config|
4347
# Provision
4448
config.vm.provision "shell", inline: <<-SHELL
4549
MYSQL_ROOT_PASS="password"
46-
POSTGRES_USER_PASS="password"
50+
PGSQL_ROOT_PASS="password"
4751
VIRTUALHOST="localhost"
4852
CODEIGNITER_PATH="/var/www/codeigniter"
4953
PHP_VERSION=7.2
50-
POSTGRES_VERSION=10
54+
PGSQL_VERSION=10
5155
5256
grep -q "127.0.0.1 ${VIRTUALHOST}" /etc/hosts || echo "127.0.0.1 ${VIRTUALHOST}" >> /etc/hosts
5357
@@ -66,7 +70,7 @@ Vagrant.configure("2") do |config|
6670
php$PHP_VERSION apache2 composer \
6771
php-intl php-mbstring php-xml php-zip php-xdebug \
6872
php-mysql mysql-server mysql-client \
69-
php-pgsql postgresql-$POSTGRES_VERSION \
73+
php-pgsql postgresql-$PGSQL_VERSION \
7074
php-sqlite3 sqlite3 \
7175
php-memcached memcached \
7276
php-redis redis-server \
@@ -75,28 +79,38 @@ Vagrant.configure("2") do |config|
7579
python-pip
7680
7781
pip install sphinx sphinxcontrib-phpdomain
78-
python "${CODEIGNITER_PATH}/user_guide_src/cilexer/setup.py" install
79-
pygmentize -L
8082
8183
apt-get autoclean
8284
85+
echo "================================================================================"
86+
echo "Preparing User Guide"
87+
echo "================================================================================"
88+
89+
cd "${CODEIGNITER_PATH}/user_guide_src/cilexer"
90+
python setup.py install
91+
cd ..
92+
make html
93+
8394
echo "================================================================================"
8495
echo "Configuring Databases"
8596
echo "================================================================================"
8697
98+
sed -i "s/^bind-address/#bind-address/" /etc/mysql/mysql.conf.d/mysqld.cnf
8799
mysql -e "CREATE DATABASE IF NOT EXISTS codeigniter COLLATE 'utf8_general_ci';
88100
UPDATE mysql.user SET Host='%' WHERE user='root';
89101
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
90102
FLUSH PRIVILEGES;" -uroot -p$MYSQL_ROOT_PASS
91-
sed -i "s/^bind-address/#bind-address/" /etc/mysql/mysql.conf.d/mysqld.cnf
92103
systemctl restart mysql
93104
94-
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/$POSTGRES_VERSION/main/postgresql.conf
95-
grep -q "host all all all md5" /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf || echo "host all all all md5" >> /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf
96-
sudo -u postgres psql -tc "SELECT 1 FROM pg_database WHERE datname = 'codeigniter';" | grep -q 1 || sudo -u postgres psql -c "CREATE DATABASE codeigniter;"
97-
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '${POSTGRES_USER_PASS}';"
105+
sed -i "s/^#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/$PGSQL_VERSION/main/postgresql.conf
106+
grep -q "host all root all md5" /etc/postgresql/$PGSQL_VERSION/main/pg_hba.conf || echo "host all root all md5" >> /etc/postgresql/$PGSQL_VERSION/main/pg_hba.conf
107+
sudo -u postgres psql -tc "SELECT 1 FROM pg_roles WHERE rolname='root'" | grep -q 1 || sudo -u postgres psql -c "CREATE ROLE root WITH SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN"
108+
sudo -u postgres psql -c "ALTER ROLE root WITH PASSWORD '${PGSQL_ROOT_PASS}'"
109+
sudo -u postgres psql -tc "SELECT 1 FROM pg_database WHERE datname='codeigniter'" | grep -q 1 ||sudo -u postgres psql -c "CREATE DATABASE codeigniter"
110+
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE codeigniter TO root"
98111
systemctl restart postgresql
99112
113+
100114
echo "================================================================================"
101115
echo "Configuring Virtual Hosts"
102116
echo "================================================================================"
@@ -109,11 +123,11 @@ Vagrant.configure("2") do |config|
109123
110124
if [ ! -d /home/vagrant/codeigniter ]; then ln -s $CODEIGNITER_PATH /home/vagrant/codeigniter; fi
111125
112-
sed -i "s/APACHE_RUN_USER=www-data/APACHE_RUN_USER=vagrant/" /etc/apache2/envvars
113-
sed -i "s/APACHE_RUN_GROUP=www-data/APACHE_RUN_GROUP=vagrant/" /etc/apache2/envvars
114-
grep -q "Listen 81" /etc/apache2/ports.conf || sed -i "s/Listen 80/Listen 80\\nListen 81\\nListen 82/" /etc/apache2/ports.conf
126+
sed -i "s/^APACHE_RUN_USER=www-data/APACHE_RUN_USER=vagrant/" /etc/apache2/envvars
127+
sed -i "s/^APACHE_RUN_GROUP=www-data/APACHE_RUN_GROUP=vagrant/" /etc/apache2/envvars
128+
grep -q "Listen 81" /etc/apache2/ports.conf || sed -i "s/^Listen 80/Listen 80\\nListen 81\\nListen 82/" /etc/apache2/ports.conf
115129
116-
echo "
130+
echo "ServerName ${VIRTUALHOST}
117131
<Directory ${CODEIGNITER_PATH}>
118132
DirectoryIndex index.html index.php
119133
Options All

0 commit comments

Comments
 (0)