1、首先通过root权限进入到linux操作系统中,然后点击右键选择open in Terminal,打开进去。
安装之前要关闭linux的防火墙[email protected] ~]# service iptables stop
2、下载安装包
[email protected] ~]# cd /usr/local
[email protected] local]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
3、解压安装包
[email protected] local]#tar -zvxf nginx-1.12.2.tar.gz
[email protected] local]# cd nginx-1.12.2
4、安装先一下几个文件
[email protected] nginx-1.12.2]# yum install pcre-devel
[email protected] nginx-1.12.2]# yum -y install gcc
[email protected] nginx-1.12.2]# yum install zlib-devel
5、执行configure
[email protected] nginx-1.12.2]# ./configure
6、安装openssl功能,shal功能。
[email protected] nginx-1.12.2]# yum install openssl openssl-devel
[email protected] nginx-1.12.2]# install perl-Digest-SHA1.x86_64
[email protected] nginx-1.12.2]# ./configure --with-http_stub_status_module --with-http_ssl_module
7、执行make命令,执行make install命令
[email protected] nginx-1.12.2]# make
[email protected] nginx-1.12.2]# make install
8、配置环境变量
[email protected] nginx-1.12.2]# vi /etc/profile
#nginx configure
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin
9、使得配置生效
[email protected] nginx-1.12.2]# source /etc/profile
10、查看nginx版本
[email protected] nginx]# nginx -v
11、修改端口和ip地址(也可以不改,看个人情况)
1)、查看ip地址:[email protected] nginx]# ifconfig
2)、[email protected] nginx]# vi /usr/local/nginx/conf/nginx.conf
server {
listen 8089;
server_name nginx.test.com
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
3)在window系统中配置一下。
12、启动nginx服务器
1)[email protected] nginx]# nginx -c conf/nginx.conf
2)(重启命令,可参考)进入nginx可执行目录sbin下,输入命令./nginx -s reload 即可
[email protected] sbin]# ./nginx -s reload (重启nginx)
13、查看进程号和状态
[email protected] nginx]# ps -ef|grep nginx
13、在浏览器输入地址和端口号:
14、杀死进程,关闭服务器
[email protected] nginx]# kill -QUIT 2072