Linux/Mac OS X安装Nginx替代Apache
- 下载:请到官方网站http://nginx.org/或者直接点击链接http://nginx.org/download/nginx-0.8.43.tar.gz
- 解压:tar jxvf nginx-*
-
进入文件目录,运行以下命令:
1)./configure
2)make
3)sudo make install
命令1为安装程序自动配置环境,命令2为编译源程序,命令3为安装 -
完成后 Nginx基本就安装好了,默认安装在/usr/local/nginx,可以在.configure --prefix=设置安装目录中。
注(mac):这个是隐藏目录,Finder中是直接看不到的,要在Finder中点击前往-前往文件夹,然后输入/usr才能进入。 -
输入以下命令启动Nginx,然后浏览器输入地址http://localhost进行测试,看到很大的字体的Welcome to nginx!就代表安装成功了
/usr/local/nginx/sbin/nginx
注:默认./configure后的配置结果为:
Configuration summary + using system PCRE library + OpenSSL library is not used + md5: using system crypto library + sha1 library is not used + 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"
-
./configure: error: the HTTP rewrite module requires the PCRE library.
解释:http rewrite模块需要PCRE资源库支持
解决:安装pcre-devel
yum install pcre-devel -
./configure: error: the HTTP cache module requires md5 functions from OpenSSL library.
解释:http缓存模块需要OpenSSL资源库内的md5方法支持
解决:安装openssl openssl-devel
yum install openssl openssl-devel
作者: Sand@Desert专注于程序开发、系统架构、性能优化
版权所有。转载时必须以链接形式注明作者和原始出处及本声明。

相关评论 | Comments (1)