下面讲讲nginx在redhat6.5下的配置使用nginx-1.6.2源码包安装(该资源我已上传);
1.使用如下命令登陆虚拟机:
ssh root@192.168.3.223
由于我之前的博客已经讲过网络配置以及yum源的配置,所以这里就直接使用了。
2.使用如下命令解压源码包:
tar -xvf nginx-1.6.2.tar.gz
3.使用cd命令切换到nginx-1.6.2;
4.使用如下命令进行编译环境的安装:
yum install gcc* -y
因为源码安装需要有gcc的编译器进行编译。
5.使用如下命令进行编译:
./configure --with-http_ssl_module --with-http_stub_status_module
6.之后根据提示使用yum install命令安装对应缺失的模块(prec*和openssl*),之后再进行第5步命令的重复,直至出现以下提示:
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
7.使用如下命令,进行nginx的安装:
make && make install
8.使用cd命令切换至/usr/local/nginx/sbin,你会发现当前目录下有个nginx的文件,但是使用很不方便,每次都得加上该目录的绝对路径进行运行,所以可以生成一个usr/sbin的链接文件。
9.使用如下命令生成/usr/sbin下的链接文件:
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
10.使用如下命令测试是否安装成功:
nginx -t
11.使用命令nginx进行服务的开启,并在真机上打开火狐浏览器,输入虚拟机的IP地址进行测试。至此,nginx的初步配置已完成。