nginx站点发布
源码编译安装
[root@kylin-server01 ~]# wget http://nginx.org/download/nginx-1.16.0.tar.gz #下载安装包
[root@kylin-server01 ~]# yum -y install gcc gcc-c++ pcre pcre-devel gd-devel #安装依赖包 [root@kylin-server01 ~]# yum -y install openssl openssl-devel zlib zlib-devel #安装依赖包
[root@kylin-server01 ~]# mkdir /usr/local/nginx #创建安装目录
[root@kylin-server01 ~]# tar xzf nginx-1.16.0.tar.gz -C /usr/local/src/ #解压到指定目录 [root@kylin-server01 ~]# cd /usr/local/src/nginx-1.16.0/ #切换到安装包目录
[root@kylin-server01 nginx-1.16.0]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module #编译环境
[root@kylin-server01 nginx-1.16.0]# make #编译
[root@kylin-server01 nginx-1.16.0]# make install #安装
[root@kylin-server01 nginx-1.16.0]# /usr/local/nginx/sbin/nginx -V
[root@kylin-server01 nginx-1.16.0]# /usr/local/nginx/sbin/nginx #启动服务
编写systemd启动文件
[root@kylin-server01 nginx-1.16.0]# /usr/local/nginx/sbin/nginx -s stop #停止服务
[root@kylin-server01 nginx-1.16.0]# vim /usr/lib/systemd/system/nginx.service #编写启动文件
[Unit]
Description=nginx - high performance web server
Documention=https://nginx.org/en/docs
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDfile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s 1 $MAINPID
ExecStop=/bin/kill -s 9 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
nginx发布站点
[root@kylin-server01 nginx-1.16.0]# cd /usr/local/nginx/conf
[root@kylin-server01 conf]# cp nginx.conf nginx.conf.bak
[root@kylin-server01 conf]# egrep -v '#|$' nginx.conf.bak
[root@kylin-server01 conf]# egrep -v '#|^$' nginx.conf.bak > nginx.conf
[root@kylin-server01 conf]# vi nginx.conf #编辑配置文件
worker_processes 1;
events {
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost; #域名配置
location / {
root /web; #定义主站路径
index index.html index.htm;
#auth_basic "secret-web"; #网站访问控制
#auth_basic_user_file /usr/local/nginx/conf/.passwd.db; #用户访问控制读取路径
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
创建网站目录
[root@kylin-server01 conf]# mkdir /web
[root@kylin-server01 conf]# vim /web/index.html
<html>
<head>
<title>kosse认证测试页</title>
</head>
<body text=#ff0000 bgcolor=#ccff99>
<p>恭喜你进入KOSSE认证nginx测试页面<p>
<p><marquee direction =right behavior=scroll>麒麟软件--国产操作系统</marquee > <p>
<p><marquee direction =right behavior=scroll>麒麟操作系统高级运维工程师</marquee > <p>
<p>恭喜您部署完成!<p>
<p> KOSSE认证之nginx编译安装 <p>
</body>
</html>
浙公网安备 33010602011771号