Creating AWS Live Instance
Instance Type
- OS Linux
- Blueprint Plesk
Name
Create an instance with the following name convention LVS_<number>_Cimara_<client_name>
SSH into the Instance as root
SSH into the server with the following command
Ssh -l <user_name> -i <file.pem> <instance_ip>
Example
ssh -l ubuntu -I awslight.pem 13.55.98.23
Install Plesk
- Ssh into the instance
- Run command
- sudo plesk login
- URL will be printed on the terminal. Copy the url into the browser
- Plesk installation wizard will open
- Plesk admin user creation
- Username – admin
- Email – your work email
- Password – generate
- Add domain And create domain user
- Enter domain name
- Username – <client_name>-prod
- Password – generate
- Hosting setting
- On the domain dashboard click hosting setting
- Set preferred domain without www
- Set php version to 7.1.*
- Set up bash access
- Click host access in domain dashboard
- Select /bin/bash in Access to the server over ssh
- Press ok
Add user domain user created above as sudo
- Login to instance as root
- Run command
- sudo usermod -aG sudo <client_name>-prod
- example – sudo usermod -aG sudo esa-prod
Allow domain user to ssh
- Login to instance as root
- Open file with command
- sudo vim /etc/ssh/sshd_config
- Update and save
- PasswordAuthentication no to PasswordAuthentication yes
- Run command
- ssh service: sudo service ssh restart
ssh as domain user
SSH into the server with the following command
sshpass -p <domain_user_password> ssh <domain_user>@<instance_ip>
Example
sshpass -p 9n7@5omYssh esa-prod@13.12.34.234
Install Cimara
Remove folders in httpdocs
- Click on Files from plesk side-bar
- Delete all the files
Clone Cimara
- Go the gitlab
- Create new branch from master <client>-master
- Clone https link
- Ssh with domain user
- Navigate to httpsdocs
- run command (include the dot in the end)
- git clone -b <branch> https://gitlab.com/cimara/cimara.git .
- run command (include the dot in the end)
Copy env file
- Run command
- cp .gitlab-deploy/app-env/.env-app .env
Clone SSL sertificates
- Run Command
Clone laradock
- Run Command
- git clone https://github.com/Laradock/laradock.git
Copy Config files
- Run Command
- cp .gitlab-deploy/laradock-env/.env-laradock laradock/.env
- cp .gitlab-deploy/schedular/laravel-scheduler.conf laradock/php-worker/supervisord.d/laravel-scheduler.conf
- rm laradock/docker-compose.yml
- cp .gitlab-deploy/composer/prod-docker-compose.yml laradock/docker-compose.yml
- cp .gitlab-deploy/apache/default.prod.apache.conf laradock/apache2/sites/default.apache.conf
Update apache settings
- Navigate to the laradock/apache2/sites
- Update default.apache.conf
- Change ServerName to the client domain(Note: 2x occurrence)
Example apache 2 config
<VirtualHost *:80>
RewriteEngine On
ServerName esa.cimara.io
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
DocumentRoot “/var/www/public”SSLEngine on
SSLCertificateFile “/var/www/cimara-ssl-certi/STAR_cimara_io.crt”
SSLCertificateKeyFile “/var/www/cimara-ssl-certi/cimara.key”
SSLCertificateChainFile “/var/www/cimara-ssl-certi/STAR_cimara_io.ca-bundle”
</VirtualHost><VirtualHost *:443>
ServerName esa.cimara.io
DocumentRoot “/var/www/public”SSLEngine on
SSLCertificateFile “/var/www/cimara-ssl-certi/STAR_cimara_io.crt”
SSLCertificateKeyFile “/var/www/cimara-ssl-certi/cimara.key”
SSLCertificateChainFile “/var/www/cimara-ssl-certi/STAR_cimara_io.ca-bundle”
</Virtualhost><Directory “/var/www/public”>
Options Indexes MultiViews
AllowOverride All
<IfVersion < 2.4 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
Update .htaccess
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Stop host apache and Nginx
- Shh as the root user
- Run Command
- sudo service nginx stop
- sudo service apache2 stop
Install docker-compose
- Shh as the root user
- Run command
- sudo curl -L https://github.com/docker/compose/releases/download/1.20.0/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose
- sudo chmod +x /usr/bin/docker-compose
Run docker
- navigate to laradock
- run command
- sudo docker-compose up -d
Install Laravel dependencies
- Run command
- Sudo docker exec -it laradock_workspace_1 /bin/bash
- composer install –ignore-platform-reqs
- chmod 775 node_modules/.bin/webpack
- npm install
- npm install cross-env
- npm run-script prod
Fix file permission
- Run command
- Sudo docker exec -it laradock_apache2_1 bin/bash
- cd ../ (path should be in var)
- chmod 775 www
- exit
- Run Command
- Sudo Chmod 777 Modules/Kernel/Menu/menu.json
- Sudo Chmod -777 -R storage
- mkdir storage/temp_thumbnail
- sudo chmod 777 -R storage/temp_thumbnail
- Sudo Chmod -777 -R bootstrap/cache
Check apache 2 config
- Login as domain user
- Run command
- Sudo docker exec -it laradock_apache2_1 /bin/bash
- Go to /etc/apa che2/sityes-available
- Open default.apache.conf. This should be the one we set earlier
- Go to /etc/apache2/sites-enabled
- 10-docker.conf should exist with the following content
Include /opt/docker/etc/httpd/global.conf
Include /opt/docker/etc/httpd/php.conf<IfVersion < 2.4>
Include /opt/docker/etc/httpd/conf.d/*.conf
</IfVersion>
<IfVersion >= 2.4>
IncludeOptional /opt/docker/etc/httpd/conf.d/*.conf
</IfVersion>
Include /opt/docker/etc/httpd/vhost.conf
Run Laravel-scheduler
Run command
Sudo Docker restart -t 10 laradock_php-workder_1
Create DB instance
- Create MySQL 5.7.26 DB
- Name – LVDB_<number>_Cimara_<client_name>
- Connect it to the sequel pro
- Create a prod and test database
Edit .env file
Update DB settings
Update mail driver to mail gun
Add ORGANISATION_ID
Add ORGANISATION_NAME
Add MEMBERSHIP_URL
Add MEMBERSHIP_AUTH
Update aws
Update GOOGLE_ANALYTICS_TRACKING_CODE
Update FCM_SERVER_KEY
Update FCM_SENDER_ID
Rebuilt docker-compose
docker-compose up -d –force-recreate –build <container-name>
Run Docker errors
When workspace errors
Try Run command
- sudo apt-get install runc=1.0.0~rc7+git20190403.029124da-0ubuntu1~16.04.4
- sudo apt-get install docker-ce
- Try [Run docker]
Create AWS Database
- Go to the database tab
- Click create
- Choose Mysql 5.7.26
- Name – LVDB_1_Cimara_<client_name>
- After created, go to the networking tab and enable public mode
Create AWS Load balancer
- Create Load balancer
- Attach instances
Enable Session Persistence
- Go to inbound traffic tab
- Click enable session persistence
Enable Https
Create a Certificate
- Primary domain – Example – esa.cimara.io
- Alternate domain – Example – test-esa.cimara.io
apache stop errors
Failed to start apache2.service: Unit apache2.service not found.
sudo netstat -nlp
kill <PID>