Setting up development environment with nginx on Amazon EC2

优质
小牛编辑
124浏览
2023-12-01

As an ISV participating in AWS Solution Providers Program, nginx is offering an automated install script for use with AWS EC2 instances. This helper script is targeted at the developers who have just started using nginx and EC2, and who would like to get things up quickly and efficiently. Please check the action list below in order to prepare your virtual machine and nginx configuration.

To set up a development environment:

  • Follow the Get Started with EC2 guide to sign up to AWS and launch your EC2 instance. Only Amazon Linux is supported, so please choose either “Basic 32-bit Amazon Linux AMI” or “Basic 64-bit Amazon Linux AMI” for an AMI. When configuring the firewall rules, it is necessary to add a rule to accept web traffic on port 80.
  • As soon as the new instance is launched, log in to it and download aws_nginx_setup.sh script with the following command:
    wget http://nginx.org/download/aws_nginx_setup.sh
    
    then run the script with root privileges:
    sudo sh https://www.xnip.cn/doc/BZ7EWB2Eaws_nginx_setup.sh
    
  • You will be asked to select what components to install. Currently it is possible to choose Django, Pyramid, Ruby on Rails or PHP development environment. After you have selected the necessary component, the script will automatically prepare its configuration for use with nginx. There will be a separate user created too, and then a sample web application is started to ensure everything is working correctly.
  • After the installation completes and the web application is installed in a subdirectory inside /var/www, the script will print how to start/stop sample application. For example, the Rails application will reside in /var/www/rails, and Rails specific part of nginx configuration will be in /etc/nginx/conf.d/rails.conf. Installed application and configuration files can be used as a basis for further development.