centos7.5 安装nginx

本文详细介绍了在CentOS7.5系统中安装和配置Nginx的过程,包括HTTPS组件的添加,以及如何设置主配置文件和子配置文件。此外,还提供了启动、重启和关闭Nginx的命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

centos7.5 安装nginx

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

###############################

nginx:

[root@localhost nginx-1.12.2]#yum -y install zlib zlib-devel openssl openssl–devel pcre pcre-devel
[root@localhost nginx-1.12.2]#yum -y install GeoIP gd libXpm libxslt

[root@localhost nginx-1.12.2]#tar -zxvf nginx-1.11.3.tar.gz

[root@localhost nginx-1.12.2]#./configure

增加Https组件

[root@localhost nginx-1.12.2]# ./configure –with-http_ssl_module

[root@localhost nginx-1.12.2]# make
[root@localhost nginx-1.12.2]# make install

config:

##主配置文件
/usr/local/nginx/config/nginx.config

#user nobody;
worker_processes 2;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

include /usr/local/nginx/conf/vshot/web.conf;

}

子配置文件

/usr/local/nginx/config/vshot/web.config

upstream web01{
server 127.0.0.1:888;
}

server {
listen 80;
listen 443 ssl;
ssl_certificate /usr/local/nginx/cert/243349_aa.cn.pem;
ssl_certificate_key /usr/local/nginx/cert/243349_aa.cn.key;
#ssl_session_timeout 5m;
client_max_body_size 2M;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

fastcgi_buffers 8 128k;
send_timeout 60;

server_name linpxing.cn www.linpxing.cn;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
#proxy_pass http://web01/; tomcat8-dir
root html;
index index.html index.htm index.php;
}

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

location /wordpress/wp-content/uploads/dlm_uploads {
deny all;
return 403;
}

}

7,启动

[root@localhost nginx-1.12.2]#/usr/local/nginx/sbin/nginx

[root@localhost nginx-1.12.2]#/usr/local/nginx/sbin/nginx -s reload

检查nginx配置语法
[root@localhost nginx-1.12.2]#/usr/local/nginx/sbin/nginx -t
重启命令:/usr/local/nginx/sbin/nginx -s reload
查看命令:ps -ef | grep nginx
关闭命令:kill -9 进程号

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值