在这里
不仅有你,还有我

Ubuntu使用nginx搭建wordpress5.5

原来网站使用Apache2作为web服务器。最近想改为Nginx。

使用Nginx需要首先安装php-fpm。

所以查询自己的php版本安装对应版本的php-fpm.

php -v
sudo apt install php7.4-fpm;

安装Nginx

sudo apt install nginx

进入/etc/nginx/sites-available

cd /etc/nginx/sites-available

进入修改default的配置

upstream php {
        server unix:/var/run/php/php7.4-fpm.sock;
        server 127.0.0.1:9000;				#检查一下php路径,根据实际情况更改
    }
	server {
        ## Your website name goes here.
        server_name www.returncome.cn;			#修改为自己的域名或者ip
        ## Your only path reference.
        root /var/home/wordpress;			#wordpress文件夹的路径
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi_params;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
                #The following parameter can be also included in fastcgi_params file
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
    }
赞(0) 打赏
版权声明:本站部分文章转载自互联网,如有侵权或出处有误请联系网站管理员平缓的老猎人 » Ubuntu使用nginx搭建wordpress5.5

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址