First you need to install essential modules on AMI. If you like to use Nginx, please take a look at tutorial here. If you like Apache more, please see here.
I myself likes to use Nginx. However, by default AWS Nginx config does not contain sites-avaliable and sites-enabled folder. I recommend using sites-enable and available structure to keep things organized.
Configure Nginx
First we make two directories within nginx config.cd /etc/nginx/ sudo mkdir sites-available sudo mkdir sites-enabledthen we need to config nginx.conf, we construct a new config file.
sudo vim nginx.tempPaste the following code into the file without modification.Refer to Yii official website.
worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; ## # nginx-naxsi config ## # Uncomment it if you installed nginx-naxsi ## #include /etc/nginx/naxsi_core.rules; ## # nginx-passenger config ## # Uncomment it if you installed nginx-passenger ## #passenger_root /usr; #passenger_ruby /usr/bin/ruby; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } #mail { # # See sample authentication script at: # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # # auth_http localhost/auth.php; # # pop3_capabilities "TOP" "USER"; # # imap_capabilities "IMAP4rev1" "UIDPLUS"; # # server { # listen localhost:110; # protocol pop3; # proxy on; # } # # server { # listen localhost:143; # protocol imap; # proxy on; # } #}then we replace the config file
sudo mv nginx.temp nginx.confafter that we edit a nginx server file, replace the
sudo vim sites-avaliable/copy and edit the server info to the file, replace the domain with your own domain info and the host_path and document to be the root of your hosted files.
server { set $host_path "/var/www/html/"; set $document "/var/www/html/"; server_name "domain"; #access_log /var/log/nginx/access.log main; root $host_path; set $yii_bootstrap "index.php"; charset utf-8; location / { index index.html $yii_bootstrap; try_files $uri $uri/ /$yii_bootstrap?$args; } location ~ ^/(protected|framework|themes/\w+/views) { deny all; } #avoid processing of calls to unexisting static files by yii location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { try_files $uri =404; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php { fastcgi_split_path_info ^(.+\.php)(.*)$; #let yii catch the calls to unexising PHP files set $fsn /$yii_bootstrap; if (-f $document$fastcgi_script_name){ set $fsn $fastcgi_script_name; } fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document$fsn; #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document$fsn; } location ~ /\.ht { deny all; } }make a symbolic link from sites-enabled to sites-available, so even the file is deleted in sites-enabled, the file in sites-available is still there.
sudo ln -s sites-available/domain sites-enabled/domainMake sure that you session was started automatically in /etc/php.ini config "session.auto_start = 1" or it was started manually by session_start() or Yii similar function
$session=new CHttpSession; $session->open();And check your session status by session_status() function. restart nginx and the server, everything will be fine.
I would recommend you to use Cloudways Yii hosting platform for deploying your yii app on Aws cloud server. It is easy and quick.
ReplyDeleteVery helpful blog it was a pleasure reading your blog would love to read it more AWS Training in India | AWS Training in Bangalore
ReplyDeleteVery Useful
ReplyDeleteAWS Training in Chennai
AWS Training in Bangalore
Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
ReplyDeleteGerman Classes in Chennai
Java Training in Chennai
German Training Centers in Chennai
German Training Institute in Chennai
Best Java Training in Chennai
Best Java Training Institute in Chennai with placement
nice blog.
ReplyDeleteaws training in bangalore
artificial intelligence training in bangalore
machine learning training in bangalore
blockchain training in bangalore
iot training in bangalore
artificial intelligence certification
artificial intelligence certification
Thanks for sharing this worthy article with us. Its very useful to learn and understand easily with the help of your guidelines. The data you have provided in this blog is very effective for AWS Learner to improve their productivity.
ReplyDeleteAWS Training In Marathahalli
Very nice information, it is valuable and useful to so many people. It gives the beautiful knowledge especially to the technical people.
ReplyDeleteamazon web services training institutes in bangalore
amazon web services training in bangalore
best amazon web services training institutes in bangalore
amazon web services training course content
amazon web services training interview questions
amazon web services training & placement in bangalore
amazon web services training center in bangalore
A big thank you for sharing such a valuable blog, I found this blog really useful. As a contribution to your blog postThis was a wondereful post being shared. Your story always bring hope and new energy.I gained many unknown information, the way you have clearly explained is really fantastic.
ReplyDeleteJava training in Chennai
Java Online training in Chennai
Java Course in Chennai
Best JAVA Training Institutes in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
Such an excellent and interesting blog, do post like this more with more information, this was very useful, Thank you.
ReplyDeleteAWS Course in Bangalore
AWS Course in Hyderabad
AWS Course in Coimbatore
AWS Course
AWS Certification Course
AWS Certification Training
AWS Online Training
AWS Training
Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful .
ReplyDeleteacte reviews
acte velachery reviews
acte tambaram reviews
acte anna nagar reviews
acte porur reviews
acte omr reviews
acte chennai reviews
acte student reviews
Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
spoken english classes in chennai | Communication training