CentOS 7 安装Nginx-1.9.2
来源:互联网 发布:ubuntu 改变源 编辑:程序博客网 时间:2024/05/17 08:04
CentOS 7 安装Nginx-1.9.2
1、安装必备工具:
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
说明:
pcre: 用来作地址重写的功能。
zlib:nginx 的gzip模块,传输数据打包,省流量(但消耗资源)。
openssl:提供ssl加密协议。
2、新建一个系统级用户组和匿名用户,以及下面编译时使用
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -r nginx
3、下载nginx
wget http://nginx.org/download/nginx-1.9.7.tar.gz
tar -zxvf nginx-1.9.7.tar.gz
cd nginx-1.9.7/
4、编译nginx
[root@localhost nginx-1.9.7]#
点击(此处)折叠或打开
- ./configure \
- --prefix=/etc/nginx \
- --sbin-path=/usr/sbin/nginx \
- --conf-path=/etc/nginx/nginx.conf \
- --error-log-path=/var/log/nginx/error.log \
- --http-log-path=/var/log/nginx/access.log \
- --pid-path=/var/run/nginx.pid \
- --lock-path=/var/run/nginx.lock \
- --http-client-body-temp-path=/var/cache/nginx/client_temp \
- --http-proxy-temp-path=/var/cache/nginx/proxy_temp \
- --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
- --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
- --http-scgi-temp-path=/var/cache/nginx/scgi_temp \
- --user=nginx \
- --group=nginx \
- --with-http_ssl_module \
- --with-http_realip_module \
- --with-http_addition_module \
- --with-http_sub_module \
- --with-http_dav_module \
- --with-http_flv_module \
- --with-http_mp4_module \
- --with-http_gunzip_module \
- --with-http_gzip_static_module \
- --with-http_random_index_module \
- --with-http_secure_link_module \
- --with-http_stub_status_module \
- --with-http_auth_request_module \
- --with-mail \
- --with-mail_ssl_module \
- --with-file-aio \
- --with-ipv6 \
- --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
[root@localhost nginx-1.9.7]# make -j4 && make install
[root@localhost nginx-1.9.7]# mkdir -p /var/cache/nginx/client_temp
[root@localhost nginx-1.9.7]# systemctl stop httpd.service
[root@localhost nginx-1.9.7]# nginx -c /etc/nginx/nginx.conf
5、Nginx 控制脚本
[root@localhost nginx-1.9.7]# gedit /usr/lib/systemd/system/nginx.service
点击(此处)折叠或打开
- [Unit]
- Description=nginx - high performance web server
- Documentation=http://nginx.org/en/docs/
- After=network.target remote-fs.target nss-lookup.target
-
- [Service]
- Type=forking
- PIDFile=/run/nginx.pid
- ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
- ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
- ExecReload=/bin/kill -s HUP ${MAINPID}
- ExecStop=/bin/kill -WINCH ${MAINPID}
- PrivateTmp=true
-
- [Install]
- WantedBy=multi-user.target
6、修改权限
[root@localhost nginx-1.9.7]# chmod +x /usr/lib/systemd/system/nginx.service
[root@localhost nginx-1.9.7]# systemctl enable nginx.service
ln -s '/usr/lib/systemd/system/nginx.service' '/etc/systemd/system/multi-user.target.wants/nginx.service'
# 会在/etc/systemd/system/multi-user.target.wants/目录下新建一个/usr/lib/systemd/system/nginx.service 文件的链接。
7、使用下面的指令来控制nginx
systemctl start nginx.service
systemctl reload nginx.service
systemctl restart nginx.service
systemctl stop nginx.service
8、查看日志
journalctl -f -u nginx.service
++++++++++++++++++++++++++++++++++
[root@localhost nginx]# gedit /etc/nginx/nginx.conf
点击(此处)折叠或打开
- #user nobody;
- worker_processes 1;
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- #pid logs/nginx.pid;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
- #access_log logs/access.log main;
- sendfile on;
- #tcp_nopush on;
- #keepalive_timeout 0;
- keepalive_timeout 65;
- #gzip on;
- server {
- listen 80;
- server_name localhost;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- root html;
- index index.html index.htm;
- }
- location ~ \.cgi$ {
- fastcgi_pass 127.0.0.1:8088;
- fastcgi_index index.cgi;
- fastcgi_param SCRIPT_FILENAME fcgi$fastcgi_script_name;
- include fastcgi_params;
- }
- #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;
- #}
- }
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- # HTTPS server
- #
- #server {
- # listen 443 ssl;
- # server_name localhost;
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
- # ssl_session_cache shared:SSL:1m;
- # ssl_session_timeout 5m;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- }
0
上一篇:(Not OK) 在CentOS7—编译nginx—for—Android
下一篇:(Not OK) 在CentOS7—编译nginx—for—Android—Makefile
相关热门文章
- Android之开发环境搭建
- Android自定义View的实现...
- AndroidManifest.xml配置文件...
- Android相对布局+圆角按钮+Sha...
- 查看Android应用包名package和...
- linux dhcp peizhi roc
- 关于Unix文件的软链接
- 求教这个命令什么意思,我是新...
- sed -e "/grep/d" 是什么意思...
- 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
评论热议
0 0
- CentOS 7 安装Nginx-1.9.2
- CentOS 7 安装Nginx-1.9.2
- CentOS 7 安装 nginx
- [CentOS 7] 安装nginx
- CentOS 7安装Nginx
- CentOS 7 安装 nginx
- Centos 7 安装Nginx
- centos 7 安装nginx
- Centos 7 安装nginx
- CentOS 7 安装Nginx
- CentOS 7 安装nginx
- CentOS 7安装nginx
- CentOS 7 安装Nginx
- centOs 7 安装 Nginx
- centOs 7 安装 Nginx
- CentOS 7 安装Nginx
- CentOS 7 安装 Nginx
- CentOS 7安装Nginx
- JAVA Excel数据批量导入到SQL数据库
- glob.h and glob.c for the Android NDK
- 腾讯TencentOS正式开放测试:支持“傻瓜式刷机”-android
- Android RecyclerView 使用完全解析 体验艺术般的控件
- (Not OK) 在CentOS7—编译nginx—for—Android
- CentOS 7 安装Nginx-1.9.2
- C++之“友元类”学习笔记
- (Not OK) 在CentOS7—编译nginx—for—Android—Makefile
- CentOS 7 systemd添加自定义系统服务
- 应用自动布局让UITableviewCell自适应高度出现下面问题
- CentOS7—Nginx—FastCGI 程序(C/C++)
- MFC——8.文件读写操作
- MYSQL用法(十八) MySQL中查询时带有保留字报错的解决方案
- 值得推荐的C/C++框架和库—造轮子前先看看现有的轮子
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
橄榄绿酒店
我的橄榄绿
橄榄绿发型
军绿 橄榄绿
橄榄绿太阳膜
橄榄绿眼影
橄榄绿英语
青春飘过橄榄绿
橄榄绿配什么颜色
歌曲橄榄绿
橄榄绿 搭配
橄榄绿调色
一身橄榄绿歌词
橄榄绿怎么调出来
橄榄绿的体验
橄榄绿的梦
橄榄绿 怎么调
橄榄绿代表什么
橄榄绿外套怎么搭配
橄榄绿搭配颜色
橄榄绿 英语
国际蓝和橄榄绿
橄榄胡手串图片欣赏
橄榄胡怎么玩
橄榄色
贝蒂斯橄榄油价格
安安金纯橄榄油
欧丽薇兰特级初榨橄榄油
金龙鱼橄榄油
阿格利司橄榄油怎么样
孕妇 橄榄油
伯爵特级初榨橄榄油
品利特级初榨橄榄油
护发橄榄油
特级初榨橄榄油护肤
橄榄油怎么护发
橄榄油 炒菜
贝蒂斯特级初榨橄榄油
橄榄油什么牌子的好
特级初榨橄榄油怎么吃
特级初榨橄榄油哪个牌子好