5-LNMP简单实现配置

安装Nginx

1
yum install nginx -y

安装Mysql

1
yum install mairadb -y

安装PHP,php-mysql,php-fpm

1
yum install php php-mysql php-fpm -y

简单配置一下PHP,php-fpm

编辑/etc/php-fpm.d/www.conf设置用户,用户组

1
2
user = nginx
group = nginx

编辑/etc/php.ini开启PHP短标签

1
short_open_tag = On

启动php-fpm

1
systemctl start php-fpm

配置nginx

编辑/etc/nginx/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
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
}

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;

include /etc/nginx/conf.d/*.conf;

server {
listen 80;
server_name 域名或ip地址;
root /wordpress;

include /etc/nginx/default.d/*.conf;

location / {
index index.php index.html;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}

启动Nginx

1
systemctl start Nginx

注意权限问题

1.iptables是否允许80端口访问
2.selinux是否关闭