centos7.5 安装nginx

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 进程号

你可能感兴趣的:(centos7)