Linux中必备常用支持库的安装(CentOS-6.5)
yum install -y gcc gdb strace gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs patch e2fsprogs-devel krb5-devel libidn libidn-devel openldap-devel nss_ldap openldap-clients openldap-servers libevent-devel libevent uuid-devel uuid mysql-devel
3.3 Nginx安装
0)创建用户nginx使用的www用户。
# groupadd www #添加www组
# useradd -g www www -s /bin/false #创建nginx运行账户www并加入到www组,不允许www用户直接登录系统
创建安装目录与日志目录
a) 安装目录
# mkdir /usr/local/nginx
b) 日志目录
# mkdir /data0/logs/nginx
# chown www:www /data0/logs/nginx -R
1) 判断系统是否安装了zlib-devel。如果没有安装。使用
# yum install -y zlib-devel
Linux中Nginx安装与配置详解
2) 解压
# cd /usr/local/src/nginx
# tar zxvf nginx-1.5.0.tar.gz
3) 进入目录
# cd nginx-1.5.0
4) 配置。通常将软件安装在/usr/local/目录下。
# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
5)编译
# make
6) 安装
# make install
7) 检查是否安装成功
# cd /usr/local/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
3.4 配置防火墙80端口
#修改防火墙配置:
# vi + /etc/sysconfig/iptables
#添加配置项
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙
# service iptables restart
3.5 上传配置文件
1)上传nginx.conf (文件下载地址见上面的Linux公社资源站)
# cd /usr/local/nginx/conf
# rz nginxrz fastcgi_params.phis
3.6 启动停止重启与测试
1)启动
#方法1
# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#方法2
# cd /usr/local/nginx/sbin
# ./nginx
# cd /usr/local/nginx/sbin
# ./nginx
2) 停止
#查询nginx主进程号
ps -ef | grep nginx
#停止进程
kill -QUIT 主进程号
#快速停止
kill -TERM 主进程号
#强制停止
pkill -9 nginx
3) 重启
(首次启动需:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf)
/usr/local/nginx/sbin/nginx -s reload
4)测试
#测试端口
netstat -na | grep 80
#浏览器中测试
http://ip:80