diff --git a/apc.nginx.conf b/apc.nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..d2ebef42933667f277d7e64a8d498775e9c7e5b8 --- /dev/null +++ b/apc.nginx.conf @@ -0,0 +1,25 @@ +server { + listen 80; + listen 8080; + + server_name apc.dev.gliders.vm; + root /home/gliders/code/APC-Admin; + + error_log /var/log/nginx/apc.error.log; + access_log /var/log/nginx/apc.access.log; + + location / { + try_files $uri @apc; + } + + # pass the PHP scripts to FastCGI server from upstream phpfcgi + location @apc { + fastcgi_pass phpfcgi; + fastcgi_index index.php; + fastcgi_buffers 256 4k; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root/index.php; + fastcgi_param SCRIPT_NAME index.php; + fastcgi_param HTTPS off; + } +} diff --git a/gliders.nginx.conf b/gliders.nginx.conf index 59dea88e0a7907db07a8fad7a9c968b53b4b1210..63d097ddb4e4c05322b348ea50dfdd70b038e49b 100644 --- a/gliders.nginx.conf +++ b/gliders.nginx.conf @@ -1,31 +1,96 @@ # https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/ # NOTE: This makes any .php file other than app, app_dev and config.php # downloadable. If you want one to run, add it to the "pass the PHP scripts to -# upstream FCGI" location section below. Be careful adding PHP files with +# upstream FCGI" location section below. Be careful adding files with # sensitive data like passwords inside them. map $host $symfony_root { - default /home/gliders/code/gliders-website; + # default /home/gliders/code/gliders-website; + default /var/gliders/www; +} + +map $host $symfony_root_dev { + default /var/gliders/www_dev; } server { listen 80; - listen 8080; - server_name gliders.vm dev.gliders.vm; + server_name gliders.vm; root $symfony_root/web; error_log /var/log/nginx/gliders.error.log; access_log /var/log/nginx/gliders.access.log; + # Enable compression. Very helpful when we're getting stuff like + # large amounts of vehicle tracks in JSON form! + gzip on; + gzip_types text/plain application/xml text/html text/css application/json application/x-javascript text/xml text/javascript; + # strip app.php/ prefix if it is present rewrite ^/app\.php/?(.*)$ /$1 permanent; + location / { + index app.php; + try_files $uri @rewriteapp; + } + + location ~ ^/(images|fonts|css|js) { + access_log off; + error_log off; + try_files $uri =404; + expires 1y; + add_header Cache-Control "public"; + } + + location /static/logs { + alias /var/gliders/logs; + } + + location @rewriteapp { + rewrite ^(.*)$ /app.php/$1 last; + } + + # pass the PHP scripts to FastCGI server from upstream phpfcgi + location ~ ^/(app|app_dev|config)\.php(/|$) { + fastcgi_pass phpfcgi; + include fastcgi_params; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + fastcgi_param SCRIPT_FILENAME $symfony_root/web$fastcgi_script_name; + fastcgi_param HTTPS off; + } +} + +server { + listen 80; + + server_name dev.gliders.vm; + root $symfony_root_dev/web; + + error_log /var/log/nginx/dev.gliders.error.log; + access_log /var/log/nginx/dev.gliders.access.log; + + # Enable compression. Very helpful when we're getting stuff like + # large amounts of vehicle tracks in JSON form! + gzip on; + gzip_types text/plain application/xml text/html text/css application/json application/x-javascript text/xml text/javascript; + + # strip app.php/ prefix if it is present + rewrite ^/app_dev\.php/?(.*)$ /$1 permanent; + location / { index app_dev.php; try_files $uri @rewriteapp; } + location ~ ^/(images|fonts|css|js) { + access_log off; + error_log off; + try_files $uri =404; + expires 1y; + add_header Cache-Control "public"; + } + location /static/logs { alias /var/gliders/logs; } @@ -39,43 +104,8 @@ server { fastcgi_pass phpfcgi; include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.*)$; - fastcgi_param SCRIPT_FILENAME $symfony_root/web$fastcgi_script_name; + fastcgi_param SCRIPT_FILENAME $symfony_root_dev/web$fastcgi_script_name; fastcgi_param HTTPS off; } } -# We don't yet have an SSL cert (not like a VM on my own machine needs one...) -# server { -# listen 443; -# -# server_name gliders.vm *.gliders.vm; -# root /home/gliders/code/gliders-website/web; -# -# ssl on; -# ssl_certificate /etc/ssl/certs/symfony2.crt; -# ssl_certificate_key /etc/ssl/private/symfony2.key; -# -# error_log /var/log/nginx/symfony2.error.log; -# access_log /var/log/nginx/symfony2.access.log; -# -# # strip app.php/ prefix if it is present -# rewrite ^/app\.php/?(.*)$ /$1 permanent; -# -# location / { -# index app.php; -# try_files $uri @rewriteapp; -# } -# -# location @rewriteapp { -# rewrite ^(.*)$ /app.php/$1 last; -# } -# -# # pass the PHP scripts to FastCGI server from upstream phpfcgi -# location ~ ^/(app|app_dev|config)\.php(/|$) { -# fastcgi_pass phpfcgi; -# fastcgi_split_path_info ^(.+\.php)(/.*)$; -# include fastcgi_params; -# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; -# fastcgi_param HTTPS on; -# } -# } diff --git a/install.sh b/install.sh index 6bbd5c9471c7bc3dcacf7c44bfa922fc0682cf95..a24d2487ebb119862274a97afe95c4ef1820d8e2 100644 --- a/install.sh +++ b/install.sh @@ -17,7 +17,7 @@ yum check-update yum update # Install needed tools -yum install git rsync wget vim ansible tmux htop iotop dstat lsof +yum install git rsync wget vim ansible tmux htop iotop dstat lsof telnet # And inotify tools yum install inotify-tools incron @@ -90,8 +90,23 @@ virtualenv /home/gliders/pythonenv cd /home/gliders/code ssh-keygen # Add contents of /home/gliders/.ssh/id_rsa.pub to GitLab, then: -git clone git@gitlab.noc.soton.ac.uk:allore/Website-Scripts.git -git clone git@gitlab.noc.soton.ac.uk:owanes/gliders-testwebsite.git +git clone git@gitlab.noc.soton.ac.uk:owanes/gliders-tools.git +git clone git@gitlab.noc.soton.ac.uk:owanes/gliders-website.git + +# Install the gliders DB and parser python libraries, +# then fetch all our log files and parse them! +cd gliders-tools +python setup.py install + +echo "please enter your mysql root user password when prompted (three times)" +mysql -u root -p < new_schema.sql +echo "CREATE USER 'gliders'@'%' IDENTIFIED BY PASSWORD 'gliders9876';" | mysql -u root -p +echo "GRANT ALL ON gliders.* TO 'gliders'@'%';" | mysql -u root -p +cd bin +./migrate_data.sh + +cd /home/gliders/code/gliders-website +./bin/deploy.sh # Restart (needed to get firewall to open ports for web, kernel might be # updated etc.)