Chapters
30 Chapters
|
2:45:48
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.5.9
Subscribe to download the code!Compatible PHP versions: >=5.5.9
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
28.
Deploy to AWS!
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial is built using an older version of Symfony, but the core concepts of Ansible are still valid. New versions of Ansible may contain some features that we don't use here.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.1.*", // v3.1.4
"doctrine/orm": "^2.5", // v2.7.2
"doctrine/doctrine-bundle": "^1.6", // 1.6.4
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.0
"symfony/swiftmailer-bundle": "^2.3", // v2.3.11
"symfony/monolog-bundle": "^2.8", // 2.11.1
"symfony/polyfill-apcu": "^1.0", // v1.2.0
"sensio/distribution-bundle": "^5.0", // v5.0.12
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.16
"incenteev/composer-parameter-handler": "^2.0", // v2.1.2
"doctrine/doctrine-migrations-bundle": "^1.2", // v1.2.0
"snc/redis-bundle": "^2.0", // 2.0.0
"predis/predis": "^1.1", // v1.1.1
"composer/package-versions-deprecated": "^1.11" // 1.11.99
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.0.8
"symfony/phpunit-bridge": "^3.0", // v3.1.4
"doctrine/data-fixtures": "^1.1", // 1.3.3
"hautelook/alice-bundle": "^1.3" // v1.4.1
}
}
16 Comments
Update. The latest images in AWS don't have a usable Python 2 installed...
Possible fixes: `ansible_python_interpreter=/usr/bin/python3` or install python in pre_tasks using local_action
> https://github.com/ansible/...
Hey Daniel,
Yes, you're right. Probably go with a new version of Python would be better. We mentioned it in the next tutorial about Ansistrano: https://symfonycasts.com/sc... . But would be a good idea to mention it here as well.
Thank you for this tip!
Cheers!
Hi. When you deploy to AWS, you choose Ubuntu 14.04. I did the same and all the code runs perfectly. However, I would like to know why did you choose Ubuntu 14.04 instead of 16.04 or Amazon Linux? Is there any particular reason? I'm worry about possible security issues using and old version of Ubuntu. Maybe you can give more perspective about this.
Hey Cesar,
Good question! There's no particular reason doing so, except we just wanted to match the same Ubuntu release as we use in VirtualBox. However, keep in mind that if you use different versions for Vagrant and AWS - your playbook probably could fail without some extra work. I mean, if your playbook works well for Vagrant with Ubuntu 14.04 - it does not mean it'll 100% work for the different Ubuntu version (like 16.04) in AWS. Probably you'll need to install more packages, or some packages have different names, or you need to configure something in a different way. So I'd recommend you to use the same versions for Vagrant and AWS just due to simplicity.
But there was a reason why we use 14.04 for Vagrant: https://knpuniversity.com/s... - in short, because it's a bit simpler to set up for Vagrant/Ansible. But in that screencast you'll find a big note how to set up 16.04 - the latest LTS (long-term support) release. However, Ubuntu 14.04 is an LTS release as well which means it's still supporting, see their roadmap: https://www.ubuntu.com/info... - so if you regularly update installed packages to the latest versions - I think you're safe with it.
So, you can use whatever image you want or whatever you know best.
Cheers!
After setting "mootube.l mypublic_ip_addr" under etc/hosts , i tried to acess to mootube.l via my brwoser but i get error "DNS not found" ?
any explination !?
Hey Ahmed,
Did you set "mootube.l your_public_ip_addr" in the "/etc/host" (notice the "/" in the beginning). Because "etc/hosts" will edit the etc/hosts file relative to the current directory you are in now. Please, double check that you write the hosts file on your *local machine* (not in the AWS EC2 instance). Also please, ensure this line is really present, you can check it with the next command: "$ cat /etc/hosts" - did you see the "mootube.l your_public_ip_addr" in the output? Are you sure you don't make a type in the domain address? Are you trying to open exactly the http://mootube.l/ domain?
Btw, what OS are you on? Is it Windows? Because for Windows local machine the hosts file is located in a different folder.
Cheers!
Oh thank you for replay problém solved :)
Hey Ahmed,
Glad you got it solved! If it was not something I mentioned before - it would be nice of you to share this information with others users who has similar problem. But it's up to you ;)
Cheers!
I was facing two problems, the first that the Apache service was not running so just I typed: httpd service start
the second problem like you already mentioned : I need to write the hosts file on your *local machine* (not in the AWS EC2 instance
Hey Ahmed,
Ah, Apache service was not running, makes sense! What about writing hosts, ideally, you need to write both files on local and remove machines. But in practice, you need to write hosts file on your remove machine only when you want to get access to that host from inside of the remove machine, for example with Curl.
Thanks for sharing it!
Cheers!
Hi Guys
Is there a way to put aws IP address info to vars.yml and save it to vault. Exposing the IP and commit to github feel like security risk for me
Hey Jian,
Hm, good question! Actually, probably you want to secure your repository where the IP is shown, i.e. make your GitHub repo private or use other services like Bitbucket or GitLab which allow you to create private repositories for free. But I'd say no, it's not possible. The only workaround I see is use DNS name instead of public IP in ansible/hosts.ini file. Then the IP will be resolved automatically at runtime, but for programmers is not a difficult task to discover your public IP if they know DNS name. Or, you can invent any fake DNS name which you commit to the repo and in your local /etc/hosts point this fake DNS name to the real public IP address, so only you will know this IP even if someone else has access to your private repo.
Also, I think you can specify a real IP address in command line, see -l option for ansible-playbook. So we use "-l aws", but you can use "-l 12.123.12.123", i.e. your real public IP, but this case you probably will need to tweak "hosts" value of your playbook to allow all hosts.
Cheers!
Hey, I just finished the course and my application run so fast, this amazing it's 5 time more fast than local.
I don't know why my app seems so slow on the local.
By the way, I have three questions wish you help me to get some answers :
1) What is Docker and why Docker is so famous ? Does deploying with docker made my app fire so fast ? Or it's just it's a new virtualization tech for deployment.
2) orm:
auto_generate_proxy_classes: false
+ Does this configuration under orm désactive cache, by setting "auto_generate_proxy_classes" to "false", any explination about this config ?
+ Does caching made the app behaving more faster ?
3)Same question about this configuration (any explanation !)
doctrine:
orm:
metadata_cache_driver: apc
Hey Ahmed,
Well done! You're a hero, my congratulations ;)
Well, what about speed - it depends on your local machine: what kind of OS you use, what PHP version you have, what PHP extensions you have installed (btw, XDebug "eats" some time as well), your local php.ini configuration, etc. But yea, production websites always run faster in practice.
1) Docker is just another way for virtualization, but it could be used in both development and production. But of course, like any virtualization tool, Docker will slows your performance. But how much slow exactly it will be is depend on the OS. Also Docker is a tool which allow you to scale ecosystem around your website, but of course it requires some good configuration and architectural design of your app. So it's more complex, need some solid understanding of how it works but have huge opportunities.
2) Unfortunately, can't help you with this one, I have never use it before :/
3) That's a good question! Doctrine allows you to cache its annotations in a separate cache system to increase reading speed. By defaults, Doctrine cache it in files, which is very slow in comparison with using cache engines. On KnpU we use APCu for storing Doctrine metadata cache.
Cheers!
Oh Thnak you victor for replying to me.
I really appreciate your help, you made my day!
Btw, if you're wondering about performance of your Symfony app - take a look at:
http://symfony.com/doc/curr...
Cheers!
"Houston: no signs of life"
Start the conversation!