Ubuntu配置negix并开机自启动
2017-06-03 17:14
246 查看
1. nginx安装环境
gcc
pcre库
zlib库
openssl库
安装方式网上有
2.编译安装
网上下载nginx-1.8.0.tar.gz,并拷贝到Ubuntu
2.1 解压:tar -zxvf nginx-1.8.0.tar.gz
2.2 进入文件夹:cd nginx-1.8.0
2.3 配置
命令行输入:
./configure \
然后将如下命令拷入命令行
2.4 部分文件夹建立
因为以上临时文件指定目录在var/temp/nginx
所以要在var文件夹建立/temp/nginx文件夹。使用mkdir xx
2.5 编译安装
make
make install
无错才可以进行下一步
2.6 检查是否安装好
cd /usr/local/nginx/sbin/
./nginx
使用ps指令看是否启动成功
ps aux|grep nginx
在Ubuntu浏览器下输入localhost/ ,有如下表示安装配置成功
3 开机自启动
为了方便使用Nginx服务器,可以进行Ubuntu开机自启动。
3.1 编写处理脚本、
vim /etc/init.d/nginx
复制如下内容
3.2 设置文件的访问权限
chmod a+x /etc/init.d/nginx
这样在控制台就好操作Nginx了如下:
3.3 开机自启动
vi /etc/rc.local
加入一行 /etc/init.d/nginx start 保存并退出,下次重启会生效。
gcc
pcre库
zlib库
openssl库
安装方式网上有
2.编译安装
网上下载nginx-1.8.0.tar.gz,并拷贝到Ubuntu
2.1 解压:tar -zxvf nginx-1.8.0.tar.gz
2.2 进入文件夹:cd nginx-1.8.0
2.3 配置
命令行输入:
./configure \
然后将如下命令拷入命令行
--prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi
2.4 部分文件夹建立
因为以上临时文件指定目录在var/temp/nginx
所以要在var文件夹建立/temp/nginx文件夹。使用mkdir xx
2.5 编译安装
make
make install
无错才可以进行下一步
2.6 检查是否安装好
cd /usr/local/nginx/sbin/
./nginx
使用ps指令看是否启动成功
ps aux|grep nginx
在Ubuntu浏览器下输入localhost/ ,有如下表示安装配置成功
3 开机自启动
为了方便使用Nginx服务器,可以进行Ubuntu开机自启动。
3.1 编写处理脚本、
vim /etc/init.d/nginx
复制如下内容
#nx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf #注意:这里的三个变量需要根据具体的环境而做修改。 nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/var/run/nginx.pid RETVAL=0 prog="nginx" #Check that networking is up [ -x $nginxd ] || exit 0 ## Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " $nginxd -s stop RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx $nginx_pid } # reload nginx service functions. reload() { echo -n $"Reloading $prog: " kill -HUP `cat ${nginx_pid}` RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL
3.2 设置文件的访问权限
chmod a+x /etc/init.d/nginx
这样在控制台就好操作Nginx了如下:
3.3 开机自启动
vi /etc/rc.local
加入一行 /etc/init.d/nginx start 保存并退出,下次重启会生效。
相关文章推荐
- Ubuntu14.04配置nginx开机自启动项
- [bigdata-047] 禅道 ubuntu 配置开机自启动服务 开机启动
- Ubuntu图形界面配置开机自启动
- **在Ubuntu系统下Copley CAN-PCI驱动的安转和开机自启动配置**
- Ubuntu14.04配置nginx开机自启动项
- 在3版中实现并动态配置开机自启动
- ubuntu下设置开机自启动项
- ubuntu开机启动svn(添加自启动)
- ubuntu 实现开机自动执行,类似于Windows开机自启动
- Ubuntu 取消 Apache及Nginx等开机自启动
- ubuntu 配置免安装版tomcat实战,并配置其自启动
- ubuntu配置开机启动服务
- ubuntu修改grub,修改开机顺序,配置grub启动顺序
- Ubuntu 创建开机自启动脚本
- Tomcat服务器在Linux开机下自启动配置
- Oracle 10g配置dbstart实现开机自启动
- Ubuntu开机配置静态ip
- Linux下配置jboss开机自启动
- Ubuntu Nginx 开机自启动