CentOS_7.2安装Nginx_1.9
一、安装依赖包和开发工具:
yum install vim vim-enhanced wget zip unzip telnet ntsysv compat* apr* nasm* gcc gcc* gcc-c++ ntp make imake cmake automake autoconf python-devel zlib zlib-devel glibc glibc-devel glib2 libxml glib2-devel libxml2 libxml2-devel bzip2 bzip2-devel libXpm libXpm-devel libidn libidn-devel libtool libtool-ltdl-devel* libmcrypt libmcrypt-devel libevent-devel libmcrypt* libicu-devel libxslt-devel postgresql-devel curl curl-devel perl perl-Net-SSLeay pcre pcre-devel ncurses ncurses-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers krb5 krb5-devel e2fsprogs e2fsprogs-devel libjpeg libpng libjpeg-devel libjpeg-6b libjpeg-devel-6b libpng-devel libtiff-devel freetype freetype-devel fontconfig-devel gd gd-devel kernel screen sysstat flex bison nss_ldap pam-devel compat-libstdc++-
二、清除系统中的httpd痕迹
yum remove httpd rm -rvf /etc/httpd rm /usr/bin/pod2man
三、创建www用户和用户组:
groupadd www useradd -s /sbin/nologin -g www www
四、解压nginx模块包:
tar zxvf zlib-.tar.gz -C /usr/src tar zxvf pcre-8.12.tar.gz -C /usr/src tar zxvf openssl-.tar.gz -C /usr/src
五、解压、配置、编译、安装nginx_1.9:
tar zxvf nginx-.tar.gz -C /usr/src/ cd /usr/src/nginx-/ ./configure --prefix=/usr/local/nginx \ --user=www \ --group=www \ --sbin-path=/usr/local/nginx/sbin/nginx \ --conf-path=/usr/local/nginx/conf/nginx.conf \ --error-log-path=/home/www/log/error.log \ --http-log-path=/home/www/log/access.log \ --pid-path=/home/www/pid/nginx.pid \ --lock-path=/home/www/pid/nginx.lock \ --with-mail \ --with-file-aio \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_dav_module \ --with-http_sub_module \ --with-http_spdy_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-zlib=/usr/src/zlib- \ --with-pcre=/usr/src/pcre-8.12 \ --with-openssl=/usr/src/openssl- \ --without-select_module \ --without-poll_module \ --http-client-body-temp-path=/tmp/clientbody \ --http-proxy-temp-path=/tmp/proxy \ --http-fastcgi-temp-path=/tmp/fastcgi \ --http-uwsgi-temp-path=/tmp/uwsgi \ --http-scgi-temp-path=/tmp/scgi make make install
六、编辑nginx.conf配置文件:
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak ln -s /usr/local/nginx/conf/nginx.conf /etc/nginx.conf vim /etc/nginx.conf
user www www;
worker_processes auto;
pid /home/www/pid/nginx.pid;
worker_rlimit_nofile ;
events
{
use epoll;
worker_connections ;
multi_accept on;
}
http
{
include mime.types;
default_type application/octet-stream;
charset UTF-;
server_names_hash_bucket_size ;
client_header_buffer_size 32k;
large_client_header_buffers 32k;
client_max_body_size 50m;
client_body_buffer_size 128k;
sendfile on;
tcp_nopush on;
keepalive_timeout ;
server_tokens off;
tcp_nodelay on;
# Proxy
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Fastcgi
fastcgi_connect_timeout ;
fastcgi_send_timeout ;
fastcgi_read_timeout ;
fastcgi_buffer_size 64k;
fastcgi_buffers 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
# Gzip Compression
gzip on;
gzip_buffers 8k;
gzip_comp_level ;
gzip_http_version 1.1;
gzip_min_length ;
gzip_proxied any;
gzip_vary on;
gzip_types
# MIME Type
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;
gzip_disable "msie6";
# Cache
open_file_cache max= inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses ;
open_file_cache_errors on;
# Log Format
log_format access '[$time_iso8601] "$remote_addr" "$http_x_forwarded_for"'
'"$request" "$request_body" "$http_cookie"'
'"$upstream_addr" "$upstream_status"'
'"$http_referer" "$status"'
'"$body_bytes_sent" "$http_user_agent"';
################################################## default ##################################################
server
{
listen default;
server_name 127.0.0.1;
access_log /home/www/log/access.log access;
error_log /home/www/log/error.log error;
root /home/www/html/;
index index.html index.htm index.php;
location ~ [^/]\.php(/|$)
{
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location /nginx_status
{
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$
{
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$
{
expires 7d;
access_log off;
}
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php?s=$ last;
break;
}
}
################################################## vhost ##################################################
include vhost/*.conf;
}
七、创建nginx相关目录,并修改权限:
mkdir -p /home/www/html chown -R www:www /home/www/
八、测试启动nginx服务:
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx nginx -t nginx -c /usr/local/nginx/conf/nginx.conf ps -aux | grep nginx netstat -anptu | grep
九、编写nginx启动脚本:
vim /etc/init.d/nginx
#!/bin/sh
# chkconfig:
# Description: Start and Stop Nginx
# Provides: nginx
# Default-Start:
# Default-Stop:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
NGINX_BIN=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/home/www/pid/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
case "$1" in
start)
echo -n "Starting $NAME... "
if netstat -tnpl | grep -q nginx;then
echo "$NAME (pid `pidof $NAME`) already running."
exit
fi
$NGINX_BIN -c $CONFIGFILE
] ; then
echo " failed"
exit
else
echo " done"
fi
;;
stop)
echo -n "Stoping $NAME... "
if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit
fi
$NGINX_BIN -s stop
] ; then
echo " failed. Use force-quit"
exit
else
echo " done"
fi
;;
status)
if netstat -tnpl | grep -q nginx; then
PID=`pidof nginx`
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
exit
fi
;;
force-quit)
echo -n "Terminating $NAME... "
if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit
fi
kill `pidof $NAME`
] ; then
echo " failed"
exit
else
echo " done"
fi
;;
restart)
$SCRIPTNAME stop
sleep
$SCRIPTNAME start
;;
reload)
echo -n "Reload service $NAME... "
if netstat -tnpl | grep -q nginx; then
$NGINX_BIN -s reload
echo " done"
else
echo "$NAME is not running, can't reload."
exit
fi
;;
configtest)
echo -n "Test $NAME configure files... "
$NGINX_BIN -t
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|force-quit|restart|reload|status|configtest}"
exit
;;
esac
十、添加nginx系统服务:
chmod a+x /etc/init.d/nginx chkconfig --add nginx chkconfig --level nginx on chkconfig --list | grep nginx
十一、重新启动nginx服务:
service nginx restart ps -aux | grep nginx netstat -anptu | grep
十二、测试:
vim /home/www/html/index.html
This is test nginx!!! nginx server test is ok!!!
chown www:www /home/www/html/index.html
十三、防火墙开启80端口:
iptables -A INPUT -p tcp --dport -j ACCEPT
CentOS_7.2安装Nginx_1.9的更多相关文章
- Linux(CentOS_7.6)安装Nginx
1.安装依赖 12 yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel 2.下载Nginx并解压 1234567 c ...
- CentOS_7.2安装Redis_3.0
一.安装依赖包和开发工具: yum install vim vim-enhanced wget zip unzip telnet ntsysv compat* apr* nasm* gcc gcc* ...
- CentOS_7.2安装PHP_5.6
一.安装依赖包和开发工具: yum install vim vim-enhanced wget zip unzip telnet ntsysv compat* apr* nasm* gcc gcc* ...
- CentOS_7.2安装MySQL_5.7
一.安装依赖包和开发工具: yum install vim vim-enhanced wget zip unzip telnet ntsysv compat* apr* nasm* gcc gcc* ...
- CentOS_7下安装PHP7.3
安装mysql:https://www.cnblogs.com/jiangml/p/10402390.html 下载PHP安装包: 官网:http://www.php.net/downloads.ph ...
- CentOS_7下安装MySQL
卸载旧版本MySQl: 下载MySQ: MySQl官网:https://dev.mysql.com/downloads/mysql/ 版本自选,操作系统选Linux-Generic,64位系统或者32 ...
- CentOS_7下安装Nginx服务
安装make: yum -y install gcc automake autoconf libtool make make是一个命令工具,是一个解释makefile中指令的命令工具.它可以简化编译过 ...
- 【CentOS_7】安装nginx
1,下载 [root@VM_0_7_centos local]# wget http://nginx.org/download/nginx-1.14.2.tar.gz ---- ::-- http:/ ...
- [CentOS_7.4]Linux编译安装ffmpeg
[CentOS_7.4]Linux编译安装ffmpeg 安装过程: 下载安装源,配置,编译,安装,设置环境变量. # wget http://www.ffmpeg.org/releases/ffm ...
随机推荐
- 我的Android第二章
前言 之前有很多人遇到了关于内部类的问题[主要在android的学习之中会大量的使用到],内部类是什么,内部类怎么定义,内部类的分类,内部类的好处,内部类如何访问,这里我们来结合代码简单的理解一下 1 ...
- 2017年1月3日 星期二 --出埃及记 Exodus 21:29
2017年1月3日 星期二 --出埃及记 Exodus 21:29 If, however, the bull has had the habit of goring and the owner ha ...
- 学习git与github的二三事 (一)
前一段时间看到了一个参加机器人比赛的同学写的经验之谈,他提到了在比赛时,希望同学们学习一下git来管理代码,于是我就某度了一下,发现了廖雪峰老师的网站,受益匪浅,持续学习中,拜谢大神,顺便记录一下自己 ...
- Css绘制圆形,环形,椭圆等图形
转载自http://blog.csdn.net/gongstrong123/article/details/50888758 绘制圆形,环形,椭圆 <!DOCTYPE html> < ...
- Android runtime Exception 整理
一般面试中java Exception(runtimeException )是必会被问到的问题 常见的异常列出四五种,是基本要求.更多的....需要注意积累了 常见的几种如下: NullPoi ...
- iOS10通知框架UserNotification理解与应用
iOS10通知框架UserNotification理解与应用 一.引言 关于通知,无论与远程Push还是本地通知,以往的iOS系统暴漏给开发者的接口都是十分有限的,开发者只能对标题和内容进行简单的定义 ...
- 获取div或者元素相对于屏幕坐上角的绝对位置
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- [转](六)unity4.6Ugui中文教程文档-------概要-UGUI Animation Integration
5.Animation Integration(动画集成) 动画允许控件的所有状态之间相互转换,充分使用unity的动画系统.这是最强大的的转换模式的在处理很多属性的同时可以进行动画. 要使用动画转换 ...
- Spring事务属性的介绍
Spring声明式事务让我们从复杂的事务处理中得到解脱.使得我们再也无需要去处理获得连接.关闭连接.事务提交和回滚等这些操作.再也无需要我们在与事务相关的方法中处理大量的try-catch-final ...
- IO流-字节输出流OutputStream异常处理
package it.cast_01; import java.io.FileNotFoundException; import java.io.FileOutputStream; import ja ...