安装Nginx

安装Nginx
1、安装编译环境
yum -y install gcc gcc-c++ make lrzsz

上传 rz

2、安装pcre、zlib

tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure && make && make install
cd ..

tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure && make && make install
cd ..

3、安装Nginx

tar -zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure && make && make install
cd ..

4、启动

检查80端口是否被占用
lsof -i:80 (如果被占用,停掉占用的进程)

/usr/local/nginx/sbin/nginx #启动nginx服务

ln -s /usr/local/nginx/sbin/nginx /usr/sbin #创建Nginx 启动链接
nginx #启动nginx服务
pkill nginx #停止nginx服务

报错:nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决: ln -s /usr/local/lib/libpcre.so.1 /lib64


##############虚拟主机#################
1、基于端口
vim /usr/local/nginx/conf/nginx.conf
————————————————————————————————————————————————————
server {
listen 90;
root /www/web1;
}
————————————————————————————————————————————————————————

2、基于ip
vim /usr/local/nginx/conf/nginx.conf
————————————————————————————————————————————————————
server {
listen 192.168.**.**;
root /www/web1;
}
————————————————————————————————————————————————————————

3、基于域名
vim /usr/local/nginx/conf/nginx.conf
————————————————————————————————————————————————————
server {
listen 80;
server_name www.123.com;
root /www/web1;
}
————————————————————————————————————————————————————————


##############配置nginx支持PHP
1、安装PHP php-fpm
yum -y install php*
rpm -ivh php-fpm-5.3.3-1.i_want_root.el6.x86_64.rpm

2、修改nginx配置文件
vim /usr/local/nginx/conf/nginx.conf
————————————————————————————————————————————————————————————

location / {
root html;
index index.php index.html index.htm;
}


location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

——————————————————————————————————————————————————————
重新加载nginx配置文件

nginx -s reload

启动php-fpm

service php-fpm start

编辑php测试页

vim /usr/local/nginx/html/index.php
____________________________

<?php phpinfo(); ?>
_________________________________

测试


世界本来就很邋遢,还有什么可以害怕。加油。

posted @ 2019-09-11 10:13  Fy丶Jianc  阅读(111)  评论(0编辑  收藏  举报