安装配置nginx
2016-04-26 17:45
567 查看
yum -y install gcc automake autoconf libtool make
yum -y install gcc gcc-c++
先安装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。
1.选定源码目录
可以是任何目录,这里选定的是/usr/local/src
cd /usr/local/src
2.安装PCRE库 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下载最新的 PCRE 源码包
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make
make install
3.安装zlib库
wget http://zlib.net/zlib-1.2.8.tar.gz tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
4.安装ssl(如果默认没装ssl)
cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.2g.tar.gz
cd openssl-1.0.2g
./config
make
make install
5.安装nginx1.8.1
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel
groupadd nginx
useradd -g nginx -s /sbin/nologin nginx
tar zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_dav_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre=/usr/local/src/pcre-8.38
make
make install
编辑主配置文件nginx.conf
cd /usr/local/nginx/conf
vi nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 88;
server_name mcs.vcfilm.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /mcs/portal/web;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1; #}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 88;
#listen somename:8080;
server_name www.jiashenzhen.com;
location / {
root html;
index index.php index.html index.htm;
}
}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
主要修改端口 listen 88;
虚拟域名server_name mcs.vcfilm.cn;
网页路径root /mcs/portal/web;
头文件 index index.php index.html index.htm;
添加php端口
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
改完之后启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
看下进程 ps -ef | grep nginx
看下端口 netstat -nltp | grep nginx
yum -y install gcc gcc-c++
先安装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。
1.选定源码目录
可以是任何目录,这里选定的是/usr/local/src
cd /usr/local/src
2.安装PCRE库 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下载最新的 PCRE 源码包
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make
make install
3.安装zlib库
wget http://zlib.net/zlib-1.2.8.tar.gz tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
4.安装ssl(如果默认没装ssl)
cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.2g.tar.gz
cd openssl-1.0.2g
./config
make
make install
5.安装nginx1.8.1
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel
groupadd nginx
useradd -g nginx -s /sbin/nologin nginx
tar zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_dav_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre=/usr/local/src/pcre-8.38
make
make install
编辑主配置文件nginx.conf
cd /usr/local/nginx/conf
vi nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 88;
server_name mcs.vcfilm.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /mcs/portal/web;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1; #}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 88;
#listen somename:8080;
server_name www.jiashenzhen.com;
location / {
root html;
index index.php index.html index.htm;
}
}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
主要修改端口 listen 88;
虚拟域名server_name mcs.vcfilm.cn;
网页路径root /mcs/portal/web;
头文件 index index.php index.html index.htm;
添加php端口
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
改完之后启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
看下进程 ps -ef | grep nginx
看下端口 netstat -nltp | grep nginx
相关文章推荐
- MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket
- 将centos7打造成桌面系统
- Linux***与提权:技巧总结篇
- 配置lamp排错指南
- mongodb3.0的权限认证问题
- 多版本Python共存,以及pip对应
- adb remount bash: /usr/local/bin/adb: Permission denied
- 不想每次都到: /usr/local/mysql/bin
- 三思—mysql安装配置手册(一)
- 三思—mysql安装配置手册(二)——-my.cnf
- Linux bash Shell中的变量类型详解
- Diff
- sysbench-0.4.12安装注意事项
- 编译安装mysql5.5.22
- keepalived 安装配置
- centos下php redis扩展的安装配置3种方法
- apache 添加模块
- Nginx配置NameCheap免费SSL
- Linux下添加php的zip模块
- 全局组、Domail Local、通用组的区别和关联