Sunday, June 1, 2014

amazon linux ami ec2 install nginx + php5.5 +mysql

what

when i used other credit card to register one new account,i want to retest it.

i request one amazon linux ami ec2 t1.micro 64bit + one windows server 2012 64bit instance in west-1c zone.

how

after your get virtual machine,do follow me:

2.1 linux

2.1.1 setup nginx and mysql  and php
# sudo -I
# yum update

# yum install nginx mysql php55 php55-cli php55-common php55-xml php55-bcmath php55-embedded php55-fpm php55-imap php55-intl php55-mbstring php55-mcrypt php55-mysqlnd php55-opcache php55-pdo php55-pecl-apcu

# chkconfig nginx on
# chkconfig php-fpm-5.5 on

# vi /etc/php-fpm.d/www.conf
listen = 127.0.0.1:9000
listen.owner = nginx
listen.group = nginx
listen.mode = 0664

user = nginx
group = nginx

/>vi /etc/nginx/nginx.conf

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

resolver_timeout 3s;

#Directive sets timeout period for connection with FastCGI-server. It should be noted that this value can't exceed 75 seconds.
fastcgi_connect_timeout 5s;

#Directive sets the amount of time for upstream to wait for a fastcgi process to send data. Change this directive if you have long running fastcgi processes that do not produce output until they have finished processing. If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate.
fastcgi_read_timeout 40s;

#Directive specifies request timeout to the server. The timeout is calculated between two write operations, not for the whole request. If no data have been written during this period then serve closes the connection.
fastcgi_send_timeout 15s;


fastcgi_buffers 8 32k;
fastcgi_buffer_size 32k;
#fastcgi_busy_buffers_size 256k;
#fastcgi_temp_file_write_size 256k;

#gzip on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

index index.php index.html index.htm;

server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;

#charset koi8-r;
charset utf-8;

#access_log /var/log/nginx/host.access.log main;

include /usr/share/nginx/html/nginx.htaccess;

location / {
}

# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

location ~ /\.ht {
deny all;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;

# location / {
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# root html;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# }
#}

}

# service php-fpm-5.5 restart
# service nginx restart


2.1.2 file sync with two machine

linux server:
# vi /etc/rsyncd.conf
pid file = /var/run/rsyncd.pid
uid = nobody
gid = nobody
max connections = 3
transfer logging = no

[test]
path = /usr/share/nginx/html
comment = html
list = no
read only = true
use chroot = no
hosts allow = *
hosts deny = *

# rsync --daemon --config /etc/rsyncd.conf


2.1.3 add task
# crontab -e
0 * * * * /usr/bin/php -f /usr/share/nginx/html/s/local/cron.php >> /var/log/pkcron.log



2.2 setup nginx + mysql + php5.5 on windows server 2012

1.download and install wt-nmp with nginx php5.5 mysql
2.edit nginx config:



worker_processes 1;




events {
worker_connections 1024;
}


http {

server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
ssi off;

#Timeouts
client_body_timeout 5;
client_header_timeout 5;
keepalive_timeout 25 25;
send_timeout 15s;
resolver_timeout 3s;

#Directive sets timeout period for connection with FastCGI-server. It should be noted that this value can't exceed 75 seconds.
fastcgi_connect_timeout 5s;

#Directive sets the amount of time for upstream to wait for a fastcgi process to send data. Change this directive if you have long running fastcgi processes that do not produce output until they have finished processing. If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate.
fastcgi_read_timeout 40s;

#Directive specifies request timeout to the server. The timeout is calculated between two write operations, not for the whole request. If no data have been written during this period then serve closes the connection.
fastcgi_send_timeout 15s;


fastcgi_buffers 8 32k;
fastcgi_buffer_size 32k;
#fastcgi_busy_buffers_size 256k;
#fastcgi_temp_file_write_size 256k;

open_file_cache off;


#php max upload limit cannot be larger than this
client_max_body_size 8m;
####client_body_buffer_size 1K;
client_header_buffer_size 1k;
large_client_header_buffers 2 1k;
types_hash_max_size 2048;




include nginx.mimetypes.conf;
default_type text/html;

##
# Logging Settings
##
access_log "c:/wt-nmp/log/nginx_access.log";
error_log "c:/wt-nmp/log/nginx_error.log" warn; #debug or warn
log_not_found on; #enables or disables messages in error_log about files not found on disk.
rewrite_log on;

#Leave this off
fastcgi_intercept_errors off;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

index index.php index.htm index.html;

server {
listen 0.0.0.0:80 default_server;
#listen [::1]:80 ipv6only=on;
server_name news.pkrss.com;

root "c:/wt-nmp/www/";
autoindex on;

allow all;
#allow ::1;
#deny all;

# deny access to .htaccess files, if Apache'
s document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php_farm;
include nginx.fastcgi.conf;
}



include c:/wt-nmp/www/nginx.htaccess;

}



include nginx.phpfarm.conf;



}


3.firewall add nginx.exe and php-fastcgi.exe pass.

4.rsync client
windows client:
download and setup https://www.itefix.no/download/cwRsync_5.3.0_Free.zip
extract to C:\Users\Administrator\Downloads\cwRsync_5.3.0_Free

add system variable path: C:\Users\Administrator\Downloads\cwRsync_5.3.0_Free

ec2 secure group add inbound rule:
All traffic All All sg-6b9bxxxx (default)

edit cwrsync.cmd:
rsync -vzrtopg --progress --delete root@yourserverip::test /cygdrive/c/wt-nmp/www/



3last


thanks reading!

No comments: