Centos 7.6 Install Nginx 1.15.12

Centos 7.6系统下载

http://mirrors.cqu.edu.cn/CentOS/7.6.1810/isos/x86_64/CentOS-7-x86_64-DVD-1810.iso

依赖安装

yum install pcre pcre-devel openssl openssl-devel zlib zlib-devel gcc gcc-c++ -y

下载nginx

wget http://nginx.org/download/nginx-1.15.12.tar.gz

解压nginx

tar -zxvf nginx-1.15.12.tar.gz

创建nginx用户

useradd -s /sbin/nologin -M www

cd nginx-1.15.12

编译nginx

./configure --user=www --group=www --prefix=/usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_realip_module --with-stream --with-stream_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_dav_module --with-http_sub_module  --with-http_gunzip_module --with-pcre  --with-debug

编译安装

make && make install

检查语法

 /usr/local/nginx/sbin/nginx -t

创建nginx启动脚本

vi /lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target 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
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

启动nginx设置开机启动

systemctl start nginx.service
systemctl enable nginx.service

创建nginx软连接

ln -s /usr/local/nginx/sbin/* /usr/local/sbin/

查看nginx版本

nginx -v

查看nginx进程和端口号

netstat -ntlp | grep nginx

下载nginx.vim(nginx高亮设置)

http://www.vim.org/scripts/script.php?script_id=1886

将下载下来的nginx.vim插件放置于~/.vim/syntax目录下

mkdir -pv  ~/.vim/syntax
cd ~/.vim/syntax
wget -O nginx.vim  http://www.vim.org/scripts/download_script.php?src_id=19394

配置nginx.vim(nginx高亮设置)

echo "au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif " >> ~/.vim/filetype.vim

Nginx配置实例

https://blog.csdn.net/hanzheng260561728/article/details/80583051

你可能感兴趣的:(Centos,Nginx)