centos6 centos7 yum 安装 nginx 和一些配置

centos6 centos7 yum 安装 nginx 和一些配置

Posted by panmg on October 8, 2019

http://www.nginx.cn/doc/ (很多的教程) http://nginx.org/en/docs/

centos7

1
2
3
4
5
	rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
	yum install nginx
	systemctl start nginx.service
	systemctl stop nginx.service
	systemctl enable nginx.service

centos6

1
2
3
4
	rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
	yum info nginx
	yum install nginx
	service nginx start restart stop reload

查看版本

nginx -v

查看端口占用 80

netstat -nlpt

php /etc/php.ini 需要开启 ;cgi.fix_pathinfo=1 把; 去掉

typecho 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
	server {
		listen       80;
		#定义使用www.xx.com访问
		server_name 47.97.156.168;
		root /data/typecho/;
		index index.html index.htm index.php;
	        if (!-e $request_filename) {
	            rewrite ^(.*)$ /index.php$1 last;
	        }
	        location ~ .*\.php(\/.*)*$ {
	            include fastcgi.conf;
	            fastcgi_pass  127.0.0.1:9000;
	        }
		access_log off;
		expires 24h;
	}