您的位置:首页 > 运维架构 > Nginx

centos7源码安装nginx

2018-09-14 09:03 549 查看
下载:
a. nginx官网及安装包:
https://nginx.org/en/download.html
或 https://github.com/dollarphper/soft/blob/master/nginx/nginx-1.15.3.tar.gz[/code] 
安装:
a. 安装依赖:
yum  -y  install  pcre-devel
yum  -y  install  zlib-devel

b. 安装nginx:

cd  nginx的下载目录
tar  -xzf  nginx-1.15.3.tar.gz
cd  nginx-1.15.3
./configure  &&  make  &&  make  install


配置:
a. 创建nginx用户:
useradd  -s  /sbin/nologin  -M  nginx

b. 修改配置文件:
vim /usr/local/nginx/conf/nginx.conf

user nginx;
worker_processes  1;
events {
worker_connections  1024;
}
http {
include       mime.types;
default_type  application/octet-stream;
sendfile        on;
keepalive_timeout  65;
server {
listen       80;
server_name  localhost;
location / {
root   html;
index  index.html index.htm;
}
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;
}
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   html;
}
}
}

c. 创建测试文件:

echo  "hello world"  >  /usr/local/nginx/html/index.html


启动命令:
a. 启动:
/usr/local/nginx/sbin/nginx

b. 停止:

/usr/local/nginx/sbin/nginx  -s  stop

c. 重启:

/usr/local/nginx/sbin/nginx  -s  reload


测试:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos7 源码安装 nginx