LNMP项目部署(3)-编译安装NGINX/测试访问php

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;
	}
}

测试访问:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值