CentOS 6.5 Nginx 配置
2014-06-17 23:04
471 查看
1.安装所有 http功能:
./configure --user=www-data --group=www-data --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module
错误:
./configure: error: the HTTP image filter module requires the GD library.
./configure: error: the GeoIP module requires the GeoIP library
1.1 安装 GeoIP (区分大小写)
yum install GeoI GeoIP-data GeoIP-devel
完毕以后,还需要到MaxMind去下一个GeoCityLite,待会php程序要用到。
下载地址是:http://geolite.maxmind.com/downl ... /GeoLiteCity.dat.gz
下载完毕以后,将压缩包解压出数据库的.dat文件,并把文件重命名为GeoIPCity.dat,然后移动到GeoIP的数据文件夹下。
使用 whereis GeoIP查看位置在 /usr/share
gzip -d GeoLiteCity.dat.gz
mv GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
参考:
http://blog.163.com/leijie131421@126/blog/static/4241114520112176194123/
http://sjolzy.cn/GeoIP-PHP-version-use.html
1.2 安装gd
yum install gd-devel
参考:/article/5579351.html
1.3帐号用户配置
--user=www-data --group=www-data 表示帐号和用户, 这两个应该都是已经存在的, 若不存在则在配置晚Nginx后需要添加这两个帐号或者修改 nginx.conf配置为user nobody, 详细见 4.1
至此,configure 成功
2. make
没有出现错误提示;成功。
出现 make[1]: Leaving directory `/home/gxw/Downloads/nginx-1.6.0'
3. make install
没出先错误提示, 成功。
安装路径为:/usr/local/nginx/
出现
[root@localhost nginx-1.6.0]# make install
make[1]: Leaving directory `/home/gxw/Downloads/nginx-1.6.0'
4 安装后运行出现的错误:
4.1 [root@localhost sbin]# ./nginx
nginx: [emerg] getpwnam("www-data") failed
原因: 没有创建www这个用户
解决:
4.1.1 添加www用户组和用户www,如下命令:
添加; 后,测试成功。显示为:
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
4.3 普通用户 gxw无法启动nginx
4.3.1 出现错误:
[gxw@localhost sbin]$ ./nginx
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
2014/07/01 21:12:13 [warn] 4882#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/nginx/conf/nginx.conf:2
2014/07/01 21:12:13 [emerg] 4882#0: open() "/usr/local/nginx/logs/access.log" failed (13: Permission denied)
原因是:默认情况下linux的1024以下端口是只有root用户才有权限占用
而gxw:gxw属于gxw组布局被root权限。
并且Log文件也是root权限。gxw也不具备。
4.3.2解决:
方法一:采用了该方法
所有用户都可以运行(因为是755权限,文件所有者:root,组所有者:root)
chown root:root nginx
chmod 755 nginx
chmod u+s nginx
方法二:
仅 root 用户和 reistlin 用户可以运行(因为是750权限,文件所有者:root,组所有者:www)
chown root:www nginx
chmod 750 nginx
chmod u+s nginx
5. 成功运行
进入:/usr/local/nginx/sbin/
[root@localhost sbin]# ./nginx 开启Nginx
打开浏览器输入:127.0.0.1
显示页面:
6. 使用命令
/usr/local/nginx/nginx -V 查看版本 和 配置信息(编译前的 --with-** 配置)
./configure --user=www-data --group=www-data --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module
错误:
./configure: error: the HTTP image filter module requires the GD library.
./configure: error: the GeoIP module requires the GeoIP library
1.1 安装 GeoIP (区分大小写)
yum install GeoI GeoIP-data GeoIP-devel
完毕以后,还需要到MaxMind去下一个GeoCityLite,待会php程序要用到。
下载地址是:http://geolite.maxmind.com/downl ... /GeoLiteCity.dat.gz
下载完毕以后,将压缩包解压出数据库的.dat文件,并把文件重命名为GeoIPCity.dat,然后移动到GeoIP的数据文件夹下。
使用 whereis GeoIP查看位置在 /usr/share
gzip -d GeoLiteCity.dat.gz
mv GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
参考:
http://blog.163.com/leijie131421@126/blog/static/4241114520112176194123/
http://sjolzy.cn/GeoIP-PHP-version-use.html
1.2 安装gd
yum install gd-devel
参考:/article/5579351.html
1.3帐号用户配置
--user=www-data --group=www-data 表示帐号和用户, 这两个应该都是已经存在的, 若不存在则在配置晚Nginx后需要添加这两个帐号或者修改 nginx.conf配置为user nobody, 详细见 4.1
至此,configure 成功
2. make
没有出现错误提示;成功。
出现 make[1]: Leaving directory `/home/gxw/Downloads/nginx-1.6.0'
3. make install
没出先错误提示, 成功。
安装路径为:/usr/local/nginx/
出现
[root@localhost nginx-1.6.0]# make install
make[1]: Leaving directory `/home/gxw/Downloads/nginx-1.6.0'
4 安装后运行出现的错误:
4.1 [root@localhost sbin]# ./nginx
nginx: [emerg] getpwnam("www-data") failed
原因: 没有创建www这个用户
解决:
4.1.1 添加www用户组和用户www,如下命令:
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
4.3 普通用户 gxw无法启动nginx
4.3.1 出现错误:
[gxw@localhost sbin]$ ./nginx
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
2014/07/01 21:12:13 [warn] 4882#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/nginx/conf/nginx.conf:2
2014/07/01 21:12:13 [emerg] 4882#0: open() "/usr/local/nginx/logs/access.log" failed (13: Permission denied)
原因是:默认情况下linux的1024以下端口是只有root用户才有权限占用
而gxw:gxw属于gxw组布局被root权限。
并且Log文件也是root权限。gxw也不具备。
4.3.2解决:
方法一:采用了该方法
所有用户都可以运行(因为是755权限,文件所有者:root,组所有者:root)
chown root:root nginx
chmod 755 nginx
chmod u+s nginx
方法二:
仅 root 用户和 reistlin 用户可以运行(因为是750权限,文件所有者:root,组所有者:www)
chown root:www nginx
chmod 750 nginx
chmod u+s nginx
5. 成功运行
进入:/usr/local/nginx/sbin/
[root@localhost sbin]# ./nginx 开启Nginx
打开浏览器输入:127.0.0.1
显示页面:
6. 使用命令
/usr/local/nginx/nginx -V 查看版本 和 配置信息(编译前的 --with-** 配置)
相关文章推荐
- CentOS 6.5安装配置Nginx
- 5、CentOS 6.5系统安装配置Nginx-1.2.7+PHP-5.3.22环境
- 运维小知识之nginx---CentOS6.5安装nginx配置nginx sticky
- CentOS6.5环境使用keepalived实现nginx服务的高可用性及配置详解
- Linux CentOS 6.5 中安装与配置JDK-7-tomcat-nginx-rabbitmq
- CentOS6.5 Nginx优化编译配置
- centos6.5直接yum安装nginx,并且支持php访问的配置
- CentOS6.5安装nginx及负载均衡配置
- CENTOS 6.5 配置YUM安装NGINX
- CentOS 6.5系统中安装配置Nginx服务器的方法
- CENTOS 6.5 配置YUM安装NGINX
- centos6.5编译安装(配置shopex4.8.5) nginx1.6.2+mysql5.5.35+php5.2.17+Zendoptimizer+eaccelerator
- CentOS-6.5安装配置Nginx
- nginx1.6 centos6.5 安装配置
- centos6.5安装配置nginx+php+mysql+httpsqs+ttserver+redis
- CentOS 6.5 配置yum安装Nginx
- Linux中Nginx安装与配置(CentOS-6.5:nginx-1.5.0)
- CENTOS 6.5 配置YUM安装NGINX
- CentOS6.5 yum安装配置nginx 以及相关配置
- Linux CentOS 6.5 中安装与配置JDK-7-tomcat-nginx-rabbitmq