centos7怎么安装配置nginx

lnmp环境安装配置

centos7怎么配置nginx?接下来网络自学网教你如何安装和配置nginx
yum list nginx* 查看nginx的安装包
yum install nginx 安装nginx
service nginx restart 重启nginx
yum install php-fpm安装对应版本的php-fpm
cd /etc/nginx/conf.d 到nginx的配置文件

server {
listen 8080;
#listen [::]:8080 default_server;
server_name www.networkidc.com;#配置域名
#root /usr/share/nginx/html;

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

location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
root /var/www; #指定php的根目录
fastcgi_pass 127.0.0.1:9000;#php-fpm的默认端口是9000
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

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

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

}

然后重启nginx访问网址就可以看到信息了 ,到此,centos7的nginx安装和配置就ok了。

Be the first to comment

Leave a Reply

Your email address will not be published.


*