CenterOS6.5(Minimal) 搭建nginx
来源:互联网 发布:具体营销数据分析 编辑:程序博客网 时间:2024/06/08 15:44
服务端开发环境搭建(默认以root帐户登录)
安装基础库
yum -y install lrzsz make cmake gcc gcc-c++ autoconf automake nc \
curl-devel libpng-devel libjpeg-devel libuuid libuuid-devel zlib*\
flex* libxml* ncurses-devel bison libtool-ltdl-devel* pcre-devel \
openssl openssl-devel gperf libevent libevent-devel bzip2 \
bzip2-devel bzip2-libs python-devel python-setuptools wget
软件安装
创建软件源码目录 mkdir -p /usr/local/app/sources
nginx(1.6.0)
编译安装
- 下载nginx-1.6.0.gz源码
wget http://nginx.org/download/nginx-1.6.0.tar.gz -P /usr/local/app/sources/
cd /usr/local/app/sources
tar -xf nginx-1.6.0.tar.gz
cd /usr/local/app/sources/nginx
./configure --prefix=/usr/local/app/nginx
make
make install clean
增加www用户和组
groupadd www
useradd -g www www
创建应用所在目录, 并增加执行权限
- 切换用户
su www
- 回到www的home目录
cd
- 创建应用目录
mkdir app
- 给www用户增加对应用目录的执行权限
chmod +x app
- 推出www帐户, 回到root身份
exit
修改nginx配置文件
vi /usr/local/app/nginx/conf/nginx.conf
修改启动帐户
#user nobody;
改为user www www;
打开log_format main的注释
在http块下增加一行
include /usr/local/app/nginx/conf/vhosts/*.conf;`保存退出
:wq
复制index.html
cp /usr/local/app/nginx/html/index.html /home/www/app/
创建nginx配置目录
mkdir /usr/local/app/nginx/conf/vhosts
增加一个app.conf的配置文件
内容如下
server { listen 80; server_name 192.168.2.240; # 以实际ip为准 index index.html index.htm index.php; root /home/www/app; client_header_buffer_size 128k; large_client_header_buffers 4 128k; proxy_buffer_size 64k; proxy_buffers 8 64k; fastcgi_buffer_size 128k; fastcgi_buffers 4 128k; access_log logs/app.access.log main; location ~ .*\.zip?$ { access_log off; } location ~ .*\.txt?$ { access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css|zip)?$ { expires 12h; } if (!-e $request_filename) { rewrite ^/(.+)$ /index.php?url=$1 last; break; } location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; add_header Content-Type text/html; }}
- 以www用户在/home/www/app/目录下创建index.php文件内容如下
<?php phpinfo();?>
关闭防火墙(CenterOS6)
chkconfig iptables off
service iptables stop
关闭selinux
- vi /etc/sysconfig/selinux
SELINUX=enforcing
改为SELINUX=disabled
- 保存退出
:wq
启动nginx
- /usr/local/app/nginx/sbin/nginx -c /usr/local/app/nginx/conf/nginx.conf
- 使用
ifconfig
查看本机ip地址, 在浏览器中查看nginx是否正常运行
- CenterOS6.5(Minimal) 搭建nginx
- CenterOS6.5(Minimal) 搭建php
- CenterOS6.5(Minimal) 搭建Redis
- CenterOS6.5(Minimal) 搭建MongoDB
- CenterOS6.5(Minimal) 搭建MySQL
- centeros6.4搭建hadoop2.6
- CenterOS6.5安装Xwindow
- CenterOS6.5 配置sendmail
- centeros6.5安装 rrdtool
- CenterOS6.5下安装oracle11g经验谈
- nginx centos6 minimal 下安装
- Windows7下使用VMWare12 安装CenterOS6.5虚拟机
- Centos 6 x86 minimal搭建SS服务
- Virtual Box + CentOS7 Minimal基础环境搭建
- Vmware 搭建Centos7 Minimal支持共享
- Nginx搭建
- nginx搭建
- [nginx]搭建
- 页面控制利器——JSTL标签库
- Handler的两种用法
- HTML的dl、dt、dd标记制作表格对决Table制作表
- Linux 系统结构详解
- [安卓开发] 自定义View之一: 组合View
- CenterOS6.5(Minimal) 搭建nginx
- Codeforces Round #311 (Div. 2) C 贪心
- linux下管道的容量以及实现机制
- Jdbc
- cookie
- 实时调度类
- Linux 多线程编程(不限Linux)
- 字符串查找(2)KMP算法
- localStorage