LNMP项目实战:
L:Linux(centos 7.6) http://mirrors.cqu.edu.cn/CentOS/7.6.1810/isos/x86_64/
N:Nginx(1.12.2) https://nginx.org/en/download.html
M:MySQL(5.6.43) https://dev.mysql.com/downloads/mysql/5.6.html#downloads
P:PHP(7.2.15) http://php.net/downloads.php
Worldpress(5.0.3):https://cn.wordpress.org/download/
部署规划:
192.168.39.7:Nginx php-fpm 运行web服务
192.168.39.10:NFS存储服务器,存储上传的图片
192.168.39.101:运行MySQL数据库
一、安装依赖包:
[root@Centos7 src]#yum install -y vim lrzsz tree screen psmisc lsof tcpdump wget ntpdate gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel net-tools iotop bc zip unzip zlib-devel bash-completion nfs-utils automake libxml2 libxml2-devel libxslt libxslt-devel perl perl-ExtUtils-Embed
二、编译安装:
[root@Centos7 ]# cd /usr/local/src/
[root@Centos7 src]# tar xf nginx-1.12.2.tar.gz
[root@Centos7 src]# cd nginx-1.12.2
[root@Centos7 nginx-1.16.1]#./configure --prefix=/apps/nginx \
> --user=www \
> --group=www \
> --with-http_ssl_module \
> --with-http_v2_module \
> --with-http_realip_module \
> --with-http_stub_status_module \
> --with-http_gzip_static_module \
> --with-pcre \
> --with-stream \
> --with-stream_ssl_module \
> --with-stream_realip_module
[root@Centos7 nginx-1.16.1]# make
[root@Centos7 nginx-1.16.1]# make install
三、准备php测试页:
[root@s1 ~]# mkdir /data/nginx/wordpress -p
[root@s1 ~]# vim /data/nginx/wordpress/index.php
<?php
phpinfo();
?>
四、配置Nginx:
[root@s1 ~]# grep -v "#" /apps/nginx/conf/nginx.conf | grep -v "^$"
server {
listen 80;
server_name www.linux39.com;
location / {
root /data/nginx/wordpress;
index index.php index.html index.htm;
if ($http_user_agent ~ "ApacheBench|WebBench|TurnitinBot|Sogou web spider|Grid
Service") {
#proxy_pass http://www.linux39.com;
return 403;
}
}
location ~ \.php$ {
root /data/nginx/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#如果SCRIPT_FILENAME是绝对路径则可以省略root /data/nginx/wordpress;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
测试访问: