AWS amazon linux 配置lnmp,redis,magento环境

B901FB5A-878E-439E-A289-B92133D1B940

登陆服务器:

1
2
chmod 400 test.pem
ssh -i "test.pem" ec2-user@ec2-xx-xx-xxx-xx.us-west-2.compute.amazonaws.com

配置lnmp环境

php7.0, mysql5.7, nginx1.8,redis 2.4.10

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
sudo yum update
sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
sudo yum autoremove php*
sudo yum install php70w-devel php70w-fpm php70w-mbstring php70w-pdo php70w-mysql php70w-intl php70w-gd php70w-opcache php70w-xml php70w-mbstring php70w-mcrypt
php -m

sudo yum install nginx
sudo mkdir -p /mnt/www
sudo vim /etc/nginx/nginx.conf
sudo chkconfig nginx on
sudo chkconfig php-fpm on
sudo service nginx start
sudo service php-fpm start

sudo rpm -ihv http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
sudo yum install -y mysql-server
sudo service mysqld start
sudo grep 'temporary password' /var/log/mysqld.log
sudo chkconfig mysqld on
sudo mysql_secure_installation

sudo yum --enablerepo=epel install redis
sudo yum --enablerepo=remi install redis
sudo service redis start
sudo chkconfig --level 35 redis on
sudo chkconfig --list | grep redis

 

nginx.conf配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
user nginx;
#user www;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;
events {
#worker_connections 1024;
use epoll;
worker_connections 51200;
multi_accept on;
}

http {
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;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

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

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/png image/gif image/jpeg;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";

# 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.html index.htm;

server {
listen 80 default_server;
#listen [::]:80 default_server;
server_name localhost;
#root /usr/share/nginx/html;
root /mnt/www;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
try_files $uri $uri/ /index.php?$args;
index index.php index.html index.htm;
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_param SERVER_PORT 80;
fastcgi_param PHP_VALUE "
memory_limit=512M;
max_execution_time=90;";
fastcgi_param MAGE_IS_DEVELOPER_MODE "yes";
fastcgi_param MAGE_RUN_CODE "fashion_main_eng";
fastcgi_param MAGE_RUN_TYPE "store";
}
if (-f $request_filename) {
break;
}
location ~ /(app|var|downloader|includes|pkginfo)/ {
deny all;
}

# 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 {
}

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

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

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

# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl;
# listen [::]:443 ssl;
# server_name localhost;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# # It is *strongly* recommended to generate unique DH parameters
# # Generate them with: openssl dhparam -out /etc/pki/nginx/dhparams.pem 2048
# #ssl_dhparam "/etc/pki/nginx/dhparams.pem";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }

}

备注:

如果域名打不开的话,查看下是不是安全组设置的问题,要添加规则

9E5A87EF-6831-4DA0-BC0E-9EE4827EB8A7

坚持原创技术分享,您的支持将鼓励我继续创作!