centos7.2 NGINX 源码安装编译
条件介绍
百度云
- 密集计算型ic3 CPU:2核
- 内存:2GB 磁盘:40G
- CentOS / 7.2 x86_64 (64bit)
1、安装相关的依赖包
[root@centos7_4 ~]# yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre*
2、 创建nginx运行用户
[root@centos7_4 ~]# useradd -M -s /sbin/nologin nginx
下载pcre包
[root@centos7_4 ~]# wget https://jaist.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.zip
[root@centos7_4 ~]# unzip pcre-8.42.zip -d /usr/local/src/
3、 下载nginx源码包并解压
[root@centos7_4 ~]# wget http://nginx.org/download/nginx-1.14.0.tar.gz
[root@centos7_4 ~]# tar zxf nginx-1.14.0.tar.gz -C /usr/local/src/
[root@centos7_4 ~]# cd /usr/local/src/nginx-1.14.0/
./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_ssl_module --user=nginx --group=nginx --with-pcre=/usr/local/src/pcre-8.42
#这个是可选项,如果yum安装了依赖包这里也可以不用
make && make install
4、 修改配置文件
[root@centos7_4 nginx-1.14.0]# vim /usr/local/nginx/conf/nginx.conf
user nginx nginx; #修改用户和组
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; #修改路径
include fastcgi_params;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现