Ubuntu使用Nginx搭建WordPress

来源:互联网 发布:怎么管理淘宝店铺 编辑:程序博客网 时间:2024/05/15 23:49

Ubuntu搭建WordPress

参考https://www.codecasts.com/blog/post/lnmp-wordpress-deploy-environment-setup

安装服务器Nginx

  • sudo apt-get update
  • sudo apt-get install nginx

安装PHP7.1

  • 首先添加 PPA

    sudo apt-get updatesudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -ysudo apt-get update
  • 然后,安装 PHP7.1

    sudo apt-get -y install php7.1sudo apt-get -y install php7.1-mysql php7.1-fpm
  • 安装完毕之后配置,php-fpm :

    vim /etc/php/7.1/fpm/php.ini//;cgi.fix_pathinfo=1 改为cgi.fix_pathinfo=0

安装 Mysql 和 配置

  • sudo apt-get -y install mysql-server-5.7
  • mysql -u root -p 输入密码
  • 在 mysql 执行:

    CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;CREATE USER 'jellybool' IDENTIFIED BY 'laravist';GRANT ALL PRIVILEGES ON wordpress.* TO 'jellybool';quit

拉取 WordPress 的源码

  • git clone https://github.com/JellyBool/wordpress.git /var/www/wordpress

配置Nginx

  • vim /etc/nginx/sites-available/default

    root /var/www/wordpress;index index.php index.html index.htm index.nginx-debian.html;# 注意我们添加了 index.phplocation / {        try_files $uri $uri/ /index.php?$query_string;    }location ~ \.php$ {        try_files $uri /index.php =404;        fastcgi_split_path_info ^(.+\.php)(/.+)$;        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;        include fastcgi_params; }

配置 WordPress 文件上传

  • 打开 wp-config.php 文件(加上以下语句):

    define('FS_METHOD', 'direct');define('FS_CHMOD_DIR', 0777);define('FS_CHMOD_FILE', 0777);

安装其他的 php 扩展

  • sudo apt install -y php7.1-gd php7.1-mbstring php7.1-xmlrpc
原创粉丝点击