创建www用户
# groupadd www
# useradd -g www www
依赖
# yum -y install gcc gcc-c++ autoconf automake
# yum -y install zlib zlib-devel pcre pcre-devel
# yum -y install openssl openssl-devel
配置
./configure 请看Tengine安装
nginx安装完成,设置成服务并开机自动启动
在/etc/init.d下创建文件nginx
# vim /etc/init.d/nginx
其内容参考nginx官方文档
!/bin/bash Startup script for the nginx Web Server chkconfig: 2345 85 15 nginx=/usr/local/nginx/sbin/nginx conf=/usr/local/nginx/conf/nginx.conf case $1 in start) echo -n "Starting Nginx" $nginx -c $conf echo " done." ;; stop) echo -n "Stopping Nginx" killall -9 nginx echo " done." ;; test) $nginx -t -c $conf echo "Success." ;; reload) echo -n "Reloading Nginx" ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP echo " done." ;; restart) $nginx -s reload echo "reload done." ;; *) echo "Usage: $0 {start|restart|reload|stop|test|show}" ;; esac
保存后设置文件的执行权限
# chmod a+x /etc/init.d/nginx
将nginx服务加入chkconfig管理列表
# chkconfig --add /etc/init.d/nginx
就可以使用service对nginx进行启动,重启等操作了。
# service nginx start
# service nginx stop
# service nginx restart
设置开机自动启动
# chkconfig nginx on