CentOS 7 安装 WEB 环境之 安装 nginx

选择云服务器CentOS 7.6 做为系统,web环境。

选择安装nginx为http转发。

1.安装nginx YUM源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

 

2. yum安装
yum install -y nginx
3. 重启服务
systemctl start nginx.service
4. 设置开机启动
systemctl enable nginx.service
如果是云服务器,需要在安全策略里开启80端口。
配置:
cd /etc/nginx/conf.d
vim www.conf

server {
# listen 80 default_server;
# listen [::]:80 default_server;
# server_name _;
listen 80;
server_name www.qihangyun.net m.qihangyun.net;
root /data/wwwroot/dir;
index index.php index.html index.htm;
error_log “/home/web/logs/nginx_www_error.log”;

# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;

location / {
try_files $uri $uri/ /index.php?$args;
#rewrite ^/archives/(.*)$ /index.php/$1;
}
location ~ \.php(.*)$ {
#proxy_buffering off;
#fastcgi_buffers 256 128k;
#chunked_transfer_encoding off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

 

copy一个test.html 到  /data/wwwroot/dir/下

 

XXX.XXX.XXX.XXX/test.html

如果能访问则配置ok

发表评论

电子邮件地址不会被公开。 必填项已用*标注