nginx服务器部署步骤

Nginx 安装

操作系统: CentOS 7.7 64位

安装编译工具及库文件

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

首先要安装 PCRE

下载 PCRE 安装包:

cd /usr/local/src/
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

解压安装包:

tar zxvf pcre-8.35.tar.gz

进入安装包目录:

cd pcre-8.35

编译安装:

./configure
make && make install

查看pcre版本:

pcre-config --version
>>>8.35

安装 Nginx

下载 Nginx:

cd /usr/local/src/
wget http://nginx.org/download/nginx-1.6.2.tar.gz

解压安装包:

tar zxvf nginx-1.6.2.tar.gz

进入安装包目录:

cd nginx-1.6.2

编译安装:

./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
make && make install

查看nginx版本:

/usr/local/webserver/nginx/sbin/nginx -v
>>>nginx version: nginx/1.6.2

测试nginx是否配置成功

浏览器输入服务器域名(例如:http://39.97.118.212)
显示Welcome to nginx页面,表示成功

查看配置文件:

cat /usr/local/webserver/nginx/conf/nginx.conf

生成备份文件:

cp /usr/local/webserver/nginx/conf/nginx.conf /usr/local/webserver/nginx/conf/nginx.backup.conf

修改配置文件:

vi /usr/local/webserver/nginx/conf/nginx.conf

-------------------------------------------------------------------------->
location / {
root html;
index index.html index.htm;
}
-------------------------------------------------------------------------->
||
||
||
/
<--------------------------------------------------------------------------
location / {
root /opt/projects/dist/article/;
index index.html index.htm;
}
<--------------------------------------------------------------------------

重启nginx:
/usr/local/webserver/nginx/sbin/nginx -s reload

nginx常见命令

启动:/usr/local/webserver/nginx/sbin/nginx
重启:/usr/local/webserver/nginx/sbin/nginx -s reload
停止:/usr/local/webserver/nginx/sbin/nginx -s stop
查看:ps -ef | grep nginx

你可能感兴趣的:(程序员笔记)