目的:此篇文章为体验源码包编译安装软件的过程,为初学者提供思路。
软件安装过程:
1.从nginx官网下载原码包,并传到linux /tmp目录下。
2.解压
[root@iscisi tmp]# cd /tmp
[root@iscisi tmp]# tar xf nginx-1.4.7.tar.gz
[root@iscisi tmp]# ll -d nginx*
drwxr-xr-x 9 1001 1001 4096 1月 30 18:39 nginx-1.4.7
-rw-r--r-- 1 root root 769153 1月 30 18:31 nginx-1.4.7.tar.gz
[root@iscisi tmp]#cd nginx-1.4.7 进入解压的目录内,准备安装。
3.安装
首先查看编译环境是否安装
yum grouplist |grep "Server Platform Development" && yum group list "Development tools".
可以使用 yum groupinstall "Server Platform Development" "Development tools" 进行安装
root@iscisi nginx-1.4.7]# ./configure --help 查看安装帮助
--help print this message
--prefix=PATH set installation prefix 自定义软件安装目录
--sbin-path=PATH set nginx binary pathname
--conf-path=PATH set nginx.conf pathname 自定义配置文件路径
--error-log-path=PATH set error log pathname
--pid-path=PATH set nginx.pid pathname
--lock-path=PATH set nginx.lock pathname
[root@iscisi nginx-1.4.7]# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf
[root@iscisi nginx-1.4.7]#make
[root@iscisi nginx-1.4.7]#make install
#如果make编译过程中提示error,并且错误原因是依赖的包PCRE没有安装。这是因为默认安装的CentOS6,只安装了 PCRE主程序,没有安装pcre-devel开发程序。所以,这时只要安装pcre-devel之后就可以再次执行make编译
4.添加环境变量用于执行nginx安装目录内bin下年所有命令
[root@iscisi sbin]# vim /etc/profile.d/nginx.sh
#添加如下行
PATH=/usr/local/nginx/sbin:$PATH
export PATH
[root@iscisi sbin]# ./etc/profile.d/nginx.sh #使环境变量生效
[root@iscisi nginx-1.4.7]#nginx #启动nginx服务
[root@iscisi nginx-1.4.7]#netstat -tln #查看80端口是否启动
5.访问nginx服务 http://服务器ip地址