|
1.CentOS5.8 x86_64位 采用最小化安装,系统经过了基本优化篇
2.nginx版本:nginx-1.4.7
3.源码包存放位置:/home/oldboy/tools
4.源码包编译安装位置:/application/
一.下载安装prce
二.安装nginx
1.下载
2.安装
1
2
3
4
5
6
7
8
9
10
11
12
13
| tar zxf nginx-1.4.7.tar.gz
cd nginx-1.4.7
useradd -s /sbin/nologin -M nginx
./configure \
--user=nginx \
--group=nginx \
--prefix=/application/nginx-1.4.7 \
--with-http_stub_status_module \
--with-http_ssl_module
make && make install
ln -s /application/nginx-1.4.7/ /application/nginx
ll -d /application/nginx
cd /application/nginx
|
报错:
[iyunv@ser200 nginx]# sbin/nginx
sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or director
[iyunv@ser200 nginx]# find / -name libpcre*
/usr/local/lib/libpcre.so.1
[iyunv@ser200 nginx]#vi /etc/ld.so.conf #这个文件记录了编译时使用的动态链接库的路径
include ld.so.conf.d/*.conf
/usr/local/lib
[iyunv@ser200 nginx]# ldconfig #它的作用就是将/etc/ld.so.conf列出的路径下的库文件 缓存到/etc/ld.so.cache 以供使用
/etc/ld.so.conf 此文件记录了编译时使用的动态库的路径,也就是加载so库的路径。
默认情况下,编译器只会使用/lib和/usr/lib这两个目录下的库文件,而通常通过源码包进行安装时,如果不指定--prefix会将库安装在/usr/local目录下,而又没有在文件/etc/ld.so.conf中添加/usr/local/lib这个目录。这样虽然安装了源码包,但是使用时仍然找不到相关的.so库,就会报错。也就是说系统不知道安装了源码包。
对于此种情况有2种解决办法:
(1)在用源码安装时,用--prefix指定安装路径为/usr/lib。这样的话也就不用配置PKG_CONFIG_PATH
(2) 直接将路径/usr/local/lib路径加入到文件/etc/ld.so.conf文件的中。在文件/etc/ld.so.conf中末尾直接添加:/usr/local/lib(这个方法给力!)
ldconfig
再来看看ldconfig这个程序,位于/sbin下,它的作用是将文件/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用,因此当安装完一些库文件,或者修改/etc/ld.so.conf增加了库的新的搜索路径,需要运行一下ldconfig,使所有的库文件都被缓存到文件/etc/ld.so.cache中,如果没做,可能会找不到刚安装的库
三.nginx基于域名的虚拟主机配置
1.添加运行nginx服务的用户,可以优化
1
2
3
| [iyunv@ser200 nginx]# useradd -s /sbin/nologin -M nginx
[iyunv@ser200 nginx]# vi conf/nginx.conf
user nginx nginx;
|
2.增运nginx运行的方式
events {
use epoll;
worker_connections 1024;
}
3.设置启动时开启的进程数,依据CPU的个数进行调节
worker_processes 4;
4.增加虚拟主机
server {
listen 80;
server_name blog.test.com; #兼听的域名
location / {
root /data/www/blog; #主机目录
index index.html index.htm; #索引页面
access_log /app/logs/blog_access.log main; #访问日志名字上文对应
}
}
http段有main的日志格式设置
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
5.可以用include的方式来加载虚拟主机的配置文件
include conf/extra/nginx_vhost.conf
6.检查语法和平滑启动
1
2
3
| [iyunv@ser200 conf]# ../sbin/nginx -t
[iyunv@ser200 conf]# ../sbin/nginx -s reload
[iyunv@ser200 conf]# lsof -i :80
|
|
|
所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298
本贴地址:https://www.yunweiku.com/thread-26551-1-1.html
上篇帖子:
nginx mac 10.10 编译报错
下篇帖子:
nginx,apache,php,mysql编译参数查看
虚拟主机
|
|
|
|
|