Java必备技能之环境搭建篇 (安装nginx)

环境:

linux版本:CentOS7 64位

【yum 安装最新版nginx:https://www.cnblogs.com/xxoome/p/7256214.html

在安装nginx前首先要确认系统中安装了gcc、pcre-devel、zlib-devel、openssl-devel

安装命令:

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

nginx下载地址:https://nginx.org/download/

创建一个文件夹方便管理

mkdir software

下载“ nginx-1.12.2.tar.gz”,移动到/root/software下。

安装:

解压
tar -zxvf  nginx-1.12.2.tar.gz


进入nginx目录
重命名
mv nginx-1.12.2 nginx
切换到
cd nginx
 配置 
./configure --prefix=/usr/local/nginx

安装
# make

make
make install

OK,现在可以执行make 了。 

   

执行make、make install命令

测试是否安装成功

# cd到刚才配置的安装目录/usr/loca/nginx/
./sbin/nginx -t

正常情况的信息输出:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

启动nginx 

cd /usr/local/nginx/sbin
./nginx //启动nginx

Nginx默认访问端口80,启动后需要确定一下是否可以用。 

因为我使用的linux系统版本是CentOS7,所以可以在服务器中执行如下命令来验证80端口情况

firewall-cmd --query-port=80/tcp

    

显然80端口没有开启。

下面我们开启80端口:

firewall-cmd --add-port=80/tcp --permanent
#重启防火墙
systemctl restart firewalld

 --permanent   #永久生效,没有此参数重启后失效

   

个人学习使用,为了方便可关闭防火墙。

永久关闭防火墙

systemctl disable firewalld

chkconfig iptables off

刷新浏览器

    


配置完毕!

配置nginx开机自启动

vim /etc/rc.d/rc.local

猜你喜欢

转载自blog.csdn.net/Coder_Boy_/article/details/110393134
今日推荐