原文连接: https://www.cnblogs.com/jimisun/p/8057156.html
linux安装nginx
安装依赖
yum install gcc
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel
一键安装上面四个依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
下载nginx的tar包
创建一个文件夹
cd /usr/local
mkdir nginx
cd nginx
下载tar包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.gz
安装nginx
进入nginx目录
cd /usr/local/nginx/nginx-1.13.7
执行命令
./configure
执行make命令
make
执行make install命令
make install
启动nginx
cd /usr/local/nginx/sbin
./nginx
防火墙:
查询端口是否开放:
firewall-cmd --query-port=8080/tcp
开放80端口:
firewall-cmd --permanent --add-port=80/tcp
移除端口:
firewall-cmd --permanent --remove-port=8080/tcp
查看开放了那些端口:
firewall-cmd --list-ports
重启防火墙(修改配置后要重启防火墙):
firewall-cmd --reload
修改配置文件
cd /usr/local/nginx/conf
vi conf.nginx
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/web/dist;
index index.html index.htm;
}
#error_page 404 /404.html;