CentOS下Nginx安装配置使用说明
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CentOS下Nginx安装配置使用说明,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2051字,纯文字阅读大概需要3分钟。
内容图文
![CentOS下Nginx安装配置使用说明](/upload/InfoBanner/zyjiaocheng/933/83d725b4394e458e8fb3087b6a5c9580.jpg)
Nginx安装
1 安装依赖包
//一键安装四个依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2 下载并解压安装包
//创建一个文件夹
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
3 安装nginx
//进入nginx目录
cd /usr/local/nginx
//进入目录
cd nginx-1.13.7
//执行命令
./configure
//执行make命令
make
//执行make install命令
make install
4 配置nginx.conf
// 打开配置文件
vim /usr/local/nginx/conf/nginx.conf
配置server
server {
listen 3001;
server_name localhost;
root /srv/realbim/client/dist;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
#root html;
try_files $uri $uri/ @router;
index index.html index.htm;
}
location @router {
rewrite ^.*$/index.html last;
}
location /api {
proxy_pass http://192.168.1.224:81;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
5 启动nginx
/usr/local/nginx/sbin/nginx -s reload
如果报错:nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed
则运行:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
再次启动即可!
6 查看nginx进程是否启动
ps -ef | grep nginx
7 常用命令
安装完成一般常用命令
进入安装目录中,
cd /usr/local/nginx/sbin
启动,关闭,重启,命令:
./nginx 启动
./nginx -s stop 关闭
./nginx -s reload 重启
8 访问
ping 确认ip是否通
telnet 确认端口是否通
systemctl stop firewalld 停止防火墙
user root; nginx.conf用户改为root
内容总结
以上是互联网集市为您收集整理的CentOS下Nginx安装配置使用说明全部内容,希望文章能够帮你解决CentOS下Nginx安装配置使用说明所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。