Skip to content

Commit 8c781d9

Browse files
authored
Merge pull request pterodactyl#485 from Pterodactyl/feature/vagrantfile
add vagrantfile
2 parents 265b697 + 659bb3a commit 8c781d9

File tree

9 files changed

+444
-0
lines changed

9 files changed

+444
-0
lines changed

.dev/vagrant/.env.vagrant

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_ENV=develop
2+
APP_DEBUG=true
3+
APP_KEY=SomeRandomString3232RandomString
4+
APP_THEME=pterodactyl
5+
APP_TIMEZONE=UTC
6+
APP_CLEAR_TASKLOG=720
7+
APP_DELETE_MINUTES=10
8+
APP_URL=http://192.168.50.2/
9+
10+
DB_HOST=localhost
11+
DB_PORT=3306
12+
DB_DATABASE=panel
13+
DB_USERNAME=pterodactyl
14+
DB_PASSWORD=pterodactyl
15+
16+
CACHE_DRIVER=memcached
17+
MEMCACHED_HOST=127.0.0.1
18+
SESSION_DRIVER=database
19+
20+
MAIL_DRIVER=smtp
21+
MAIL_HOST=127.0.0.1
22+
MAIL_PORT=1025
23+
MAIL_USERNAME=
24+
MAIL_PASSWORD=
25+
MAIL_ENCRYPTION=
26+
MAIL_FROM=support@pterodactyl.io
27+
28+
API_PREFIX=api
29+
API_VERSION=v1
30+
API_DEBUG=true
31+
32+
QUEUE_DRIVER=database
33+
QUEUE_HIGH=high
34+
QUEUE_STANDARD=standard
35+
QUEUE_LOW=low
36+
37+
SQS_KEY=aws-public
38+
SQS_SECRET=aws-secret
39+
SQS_QUEUE_PREFIX=aws-queue-prefix

.dev/vagrant/mailhog.service

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Mailhog
3+
4+
[Service]
5+
# On some systems the user and group might be different.
6+
# Some systems use `apache` as the user and group.
7+
User=www-data
8+
Group=www-data
9+
Restart=on-failure
10+
ExecStart=/usr/bin/mailhog
11+
12+
[Install]
13+
WantedBy=multi-user.target

.dev/vagrant/mariadb.cnf

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# MariaDB database server configuration file.
2+
#
3+
# You can copy this file to one of:
4+
# - "/etc/mysql/my.cnf" to set global options,
5+
# - "~/.my.cnf" to set user-specific options.
6+
#
7+
# One can use all long options that the program supports.
8+
# Run program with --help to get a list of available options and with
9+
# --print-defaults to see which it would actually understand and use.
10+
#
11+
# For explanations see
12+
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
13+
14+
# This will be passed to all mysql clients
15+
# It has been reported that passwords should be enclosed with ticks/quotes
16+
# escpecially if they contain "#" chars...
17+
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
18+
[client]
19+
port = 3306
20+
socket = /var/run/mysqld/mysqld.sock
21+
22+
# Here is entries for some specific programs
23+
# The following values assume you have at least 32M ram
24+
25+
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
26+
[mysqld_safe]
27+
socket = /var/run/mysqld/mysqld.sock
28+
nice = 0
29+
30+
[mysqld]
31+
#
32+
# * Basic Settings
33+
#
34+
user = mysql
35+
pid-file = /var/run/mysqld/mysqld.pid
36+
socket = /var/run/mysqld/mysqld.sock
37+
port = 3306
38+
basedir = /usr
39+
datadir = /var/lib/mysql
40+
tmpdir = /tmp
41+
lc_messages_dir = /usr/share/mysql
42+
lc_messages = en_US
43+
skip-external-locking
44+
#
45+
# Instead of skip-networking the default is now to listen only on
46+
# localhost which is more compatible and is not less secure.
47+
bind-address = 0.0.0.0
48+
#
49+
# * Fine Tuning
50+
#
51+
max_connections = 100
52+
connect_timeout = 5
53+
wait_timeout = 600
54+
max_allowed_packet = 16M
55+
thread_cache_size = 128
56+
sort_buffer_size = 4M
57+
bulk_insert_buffer_size = 16M
58+
tmp_table_size = 32M
59+
max_heap_table_size = 32M
60+
#
61+
# * MyISAM
62+
#
63+
# This replaces the startup script and checks MyISAM tables if needed
64+
# the first time they are touched. On error, make copy and try a repair.
65+
myisam_recover_options = BACKUP
66+
key_buffer_size = 128M
67+
#open-files-limit = 2000
68+
table_open_cache = 400
69+
myisam_sort_buffer_size = 512M
70+
concurrent_insert = 2
71+
read_buffer_size = 2M
72+
read_rnd_buffer_size = 1M
73+
#
74+
# * Query Cache Configuration
75+
#
76+
# Cache only tiny result sets, so we can fit more in the query cache.
77+
query_cache_limit = 128K
78+
query_cache_size = 64M
79+
# for more write intensive setups, set to DEMAND or OFF
80+
#query_cache_type = DEMAND
81+
#
82+
# * Logging and Replication
83+
#
84+
# Both location gets rotated by the cronjob.
85+
# Be aware that this log type is a performance killer.
86+
# As of 5.1 you can enable the log at runtime!
87+
#general_log_file = /var/log/mysql/mysql.log
88+
#general_log = 1
89+
#
90+
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
91+
#
92+
# we do want to know about network errors and such
93+
log_warnings = 2
94+
#
95+
# Enable the slow query log to see queries with especially long duration
96+
#slow_query_log[={0|1}]
97+
slow_query_log_file = /var/log/mysql/mariadb-slow.log
98+
long_query_time = 10
99+
#log_slow_rate_limit = 1000
100+
log_slow_verbosity = query_plan
101+
102+
#log-queries-not-using-indexes
103+
#log_slow_admin_statements
104+
#
105+
# The following can be used as easy to replay backup logs or for replication.
106+
# note: if you are setting up a replication slave, see README.Debian about
107+
# other settings you may need to change.
108+
#server-id = 1
109+
#report_host = master1
110+
#auto_increment_increment = 2
111+
#auto_increment_offset = 1
112+
log_bin = /var/log/mysql/mariadb-bin
113+
log_bin_index = /var/log/mysql/mariadb-bin.index
114+
# not fab for performance, but safer
115+
#sync_binlog = 1
116+
expire_logs_days = 10
117+
max_binlog_size = 100M
118+
# slaves
119+
#relay_log = /var/log/mysql/relay-bin
120+
#relay_log_index = /var/log/mysql/relay-bin.index
121+
#relay_log_info_file = /var/log/mysql/relay-bin.info
122+
#log_slave_updates
123+
#read_only
124+
#
125+
# If applications support it, this stricter sql_mode prevents some
126+
# mistakes like inserting invalid dates etc.
127+
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
128+
#
129+
# * InnoDB
130+
#
131+
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
132+
# Read the manual for more InnoDB related options. There are many!
133+
default_storage_engine = InnoDB
134+
# you can't just change log file size, requires special procedure
135+
#innodb_log_file_size = 50M
136+
innodb_buffer_pool_size = 256M
137+
innodb_log_buffer_size = 8M
138+
innodb_file_per_table = 1
139+
innodb_open_files = 400
140+
innodb_io_capacity = 400
141+
innodb_flush_method = O_DIRECT
142+
#
143+
# * Security Features
144+
#
145+
# Read the manual, too, if you want chroot!
146+
# chroot = /var/lib/mysql/
147+
#
148+
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
149+
#
150+
# ssl-ca=/etc/mysql/cacert.pem
151+
# ssl-cert=/etc/mysql/server-cert.pem
152+
# ssl-key=/etc/mysql/server-key.pem
153+
154+
#
155+
# * Galera-related settings
156+
#
157+
[galera]
158+
# Mandatory settings
159+
#wsrep_on=ON
160+
#wsrep_provider=
161+
#wsrep_cluster_address=
162+
#binlog_format=row
163+
#default_storage_engine=InnoDB
164+
#innodb_autoinc_lock_mode=2
165+
#
166+
# Allow server to accept connections on all interfaces.
167+
#
168+
#bind-address=0.0.0.0
169+
#
170+
# Optional setting
171+
#wsrep_slave_threads=1
172+
#innodb_flush_log_at_trx_commit=0
173+
174+
[mysqldump]
175+
quick
176+
quote-names
177+
max_allowed_packet = 16M
178+
179+
[mysql]
180+
#no-auto-rehash # faster start of mysql but no tab completion
181+
182+
[isamchk]
183+
key_buffer = 16M
184+
185+
#
186+
# * IMPORTANT: Additional settings that can override those from this file!
187+
# The files must end with '.cnf', otherwise they'll be ignored.
188+
#
189+
!includedir /etc/mysql/conf.d/

.dev/vagrant/motd.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#####################################################
2+
Pterodactyl Panel Vagrant VM
3+
4+
Install: /var/www/html/pterodactyl
5+
Ports:
6+
Panel: 80 (50080 on host)
7+
MailHog: 8025 (58025 on host)
8+
MySQL: 3306 (53306 on host)
9+
10+
Default panel users:
11+
user: admin passwd: Ptero123 (admin user)
12+
user: user passwd: Ptero123 (standard user)
13+
14+
MySQL is accessible using root/pterodactyl or pterodactyl/pterodactyl
15+
16+
Services for pteroq and mailhog are running
17+
#####################################################

.dev/vagrant/provision.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
echo "Provisioning development environment for Pterodactyl Panel."
4+
cp /var/www/html/pterodactyl/.dev/vagrant/motd.txt /etc/motd
5+
chmod -x /etc/update-motd.d/10-help-text /etc/update-motd.d/51-cloudguest
6+
7+
apt-get install -y software-properties-common > /dev/null
8+
9+
echo "Add the ondrej/php ppa repository"
10+
add-apt-repository -y ppa:ondrej/php > /dev/null
11+
echo "Add the mariadb repository"
12+
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash > /dev/null
13+
14+
apt-get update > /dev/null
15+
16+
echo "Install the dependencies"
17+
export DEBIAN_FRONTEND=noninteractive
18+
# set the mariadb root password because mariadb asks for it
19+
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password password pterodactyl'
20+
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password_again password pterodactyl'
21+
# actually install
22+
apt-get install -y php7.1 php7.1-cli php7.1-gd php7.1-mysql php7.1-pdo php7.1-mbstring php7.1-tokenizer php7.1-bcmath php7.1-xml php7.1-fpm php7.1-memcached php7.1-curl php7.1-zip php-xdebug mariadb-server nginx curl tar unzip git memcached > /dev/null
23+
24+
echo "Install composer"
25+
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
26+
27+
echo "Install and run mailhog"
28+
curl -sL -o /usr/bin/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64
29+
chmod +x /usr/bin/mailhog
30+
cp /var/www/html/pterodactyl/.dev/vagrant/mailhog.service /etc/systemd/system/
31+
systemctl enable mailhog.service
32+
systemctl start mailhog
33+
34+
echo "Configure xDebug"
35+
cp /var/www/html/pterodactyl/.dev/vagrant/xdebug.ini /etc/php/7.1/mods-available/
36+
systemctl restart php7.1-fpm
37+
38+
echo "Configure nginx"
39+
cp /var/www/html/pterodactyl/.dev/vagrant/pterodactyl.conf /etc/nginx/sites-available/
40+
rm /etc/nginx/sites-available/default
41+
ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/pterodactyl.conf
42+
systemctl restart nginx
43+
44+
echo "Setup database"
45+
# Replace default config with custom one to bind mysql to 0.0.0.0 to make it accessible from the host
46+
cp /var/www/html/pterodactyl/.dev/vagrant/mariadb.cnf /etc/mysql/my.cnf
47+
systemctl restart mariadb
48+
mysql -u root -ppterodactyl << SQL
49+
CREATE DATABASE panel;
50+
GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'%' IDENTIFIED BY 'pterodactyl' WITH GRANT OPTION;
51+
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'pterodactyl' WITH GRANT OPTION;
52+
FLUSH PRIVILEGES;
53+
SQL
54+
55+
echo "Setup pterodactyl queue worker service"
56+
cp /var/www/html/pterodactyl/.dev/vagrant/pteroq.service /etc/systemd/system/
57+
systemctl enable pteroq.service
58+
59+
60+
echo "Setup panel with base settings"
61+
cp /var/www/html/pterodactyl/.dev/vagrant/.env.vagrant /var/www/html/pterodactyl/.env
62+
cd /var/www/html/pterodactyl
63+
chmod -R 755 storage/* bootstrap/cache
64+
composer install --no-progress
65+
php artisan key:generate --force
66+
php artisan migrate
67+
php artisan db:seed
68+
php artisan pterodactyl:user --firstname Test --lastname Admin --username admin --email testadmin@pterodactyl.io --password Ptero123 --admin 1
69+
php artisan pterodactyl:user --firstname Test --lastname User --username user --email testuser@pterodactyl.io --password Ptero123 --admin 0
70+
71+
echo "Add queue cronjob and start queue worker"
72+
(crontab -l 2>/dev/null; echo "* * * * * php /var/www/html/pterodactyl/artisan schedule:run >> /dev/null 2>&1") | crontab -
73+
systemctl start pteroq
74+
75+
echo " ----------------"
76+
echo "Provisioning is completed."
77+
echo "The panel should be available at http://localhost:50080/"
78+
echo "You may use the default admin user to login: admin/Ptero123"
79+
echo "A normal user has also been created: user/Ptero123"
80+
echo "MailHog is available at http://localhost:58025/"
81+
echo "Connect to the database using root/pterodactyl or pterodactyl/pterodactyl on localhost:53306"
82+
echo "If you want to access the panel using http://pterodactyl.app you can use the vagrant-dns plugin"
83+
echo "Install it with 'vagrant plugin install vagrant-dns', then run 'vagrant dns --install' once"
84+
echo "On first use you'll have to manually start vagrant-dns with 'vagrant dns --start'"

.dev/vagrant/pterodactyl.conf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# If using Ubuntu this file should be placed in:
2+
# /etc/nginx/sites-available/
3+
#
4+
# If using CentOS this file should be placed in:
5+
# /etc/nginx/conf.d/
6+
#
7+
server {
8+
listen 80;
9+
server_name 0.0.0.0;
10+
11+
root /var/www/html/pterodactyl/public;
12+
index index.html index.htm index.php;
13+
charset utf-8;
14+
15+
location / {
16+
try_files $uri $uri/ /index.php?$query_string;
17+
}
18+
19+
location = /favicon.ico { access_log off; log_not_found off; }
20+
location = /robots.txt { access_log off; log_not_found off; }
21+
22+
access_log off;
23+
error_log /var/log/nginx/pterodactyl.app-error.log error;
24+
25+
# allow larger file uploads and longer script runtimes
26+
client_max_body_size 100m;
27+
client_body_timeout 120s;
28+
29+
sendfile off;
30+
31+
location ~ \.php$ {
32+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
33+
# the fastcgi_pass path needs to be changed accordingly when using CentOS
34+
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
35+
fastcgi_index index.php;
36+
include fastcgi_params;
37+
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
38+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
39+
fastcgi_param HTTP_PROXY "";
40+
fastcgi_intercept_errors off;
41+
fastcgi_buffer_size 16k;
42+
fastcgi_buffers 4 16k;
43+
fastcgi_connect_timeout 300;
44+
fastcgi_send_timeout 300;
45+
fastcgi_read_timeout 300;
46+
}
47+
48+
location ~ /\.ht {
49+
deny all;
50+
}
51+
}

0 commit comments

Comments
 (0)