ubuntu安装wordpress Ubuntu安装ssh

   2023-02-10 学习力0
核心提示:查看系统版本lsb_release -aDistributor ID: UbuntuDescription: Ubuntu 18.04.2 LTSRelease: 18.04Codename: bionic下载并解压https://wordpress.org/download/releases/wget https://wordpress.org/wordpress-5.2.2.zip #下载源码sudo apt install unzip #

查看系统版本

lsb_release -a

Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic

下载并解压

https://wordpress.org/download/releases/

wget https://wordpress.org/wordpress-5.2.2.zip #下载源码
sudo apt install unzip #安装 unzip
unzip wordpress-5.2.2.zip # 解压

PHP

sudo apt install -y php php-fpm php-mysql

php -v
# PHP 7.2.19-0ubuntu0.18.04.1 (cli)

MariaDB

sudo apt install -y mariadb-server mariadb-client
mysql -V

# mysql  Ver 15.1 Distrib 10.1.40-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Nginx

sudo apt install -y nginx

nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)
server {
    listen 80;
    server_name codingday.network;
    root <目录>;
    index index.php index.html index.htm index.nginx-debian.html;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

# /etc/nginx/sites-enabled

数据库

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

GRANT ALL ON wordpress.* TO ' wordpress '@'localhost' IDENTIFIED BY 'wordpress';

FLUSH PRIVILEGES;

cp wp-config-sample.php wp-config.php

/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'wordpress' );

/** MySQL database password */
define( 'DB_PASSWORD', 'wordpress' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

sudo chown -R www-data:www-data wordpress


sudo lsof -Pn -iTCP:3306

 

WordPress 安装插件时无法创建目录解决方案


sudo chown -R www-data:www-data wordpress



参考:

1、安装 nginx
sudo apt install nginx

确认:查看端口
netstat -anp |grep 80
或者
sudo lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1750 root 6u IPv4 22825 0t0 TCP *:http (LISTEN)
nginx 1750 root 7u IPv6 22826 0t0 TCP *:http (LISTEN)
nginx 1752 www-data 6u IPv4 22825 0t0 TCP *:http (LISTEN)
nginx 1752 www-data 7u IPv6 22826 0t0 TCP *:http (LISTEN)

确认:cha查看 nginx 服务
sudo systemctl status nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2 、安装 php
sudo apt install php php-fpm
sudo apt-get install php7.2 php7.2-fpm
确认:查看版本
php -v
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

确认:查看进程
ps -ef |grep php
root 10848 1 0 12:41 ? 00:00:00 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
www-data 10862 10848 0 12:41 ? 00:00:00 php-fpm: pool www
www-data 10863 10848 0 12:41 ? 00:00:00 php-fpm: pool www
dhbm 10983 1232 0 12:48 pts/0 00:00:00 grep --color=auto php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
3 、修改站点配置,测试 php 文件解析
1)、新建一个 php 文件
cd /var/www/html
sudo vim info.php
加入以下 3 行
<?php
phpinfo();
?>
2)、修改站点配置
cd /etc/nginx/sites-available/
** a. 去掉 location ~ \.php$ { 这行的注释,同时去掉配对的 } 这行的注释
** b. 去掉 fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; 这行的注释
** c. 同时,修改成对应的 php-fpm 版本号的文件名(我安装的是 php7.2)
3)、测试 nginx,重启 nginx 服务
nginx -t
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
...

需要 sudo

sudo nginx -t
nginx: [emerg] "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:62
nginx: configuration file /etc/nginx/nginx.conf test failed
按照错误提示的行号(我的错误在 62 行),检查以上 a,b,c 处修改正确否!

4)、纪录一下修改的结果
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}

5)、正确测试结果
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
6)、正确之后再重启 nginx 服务
sudo systemctl restart nginx

** 不确认的话,可以查看 nginx 服务状态!
sudo systemctl status nginx
**中途总是折腾不对时,多次 reboot ,实践证明:必须 nginx 测试正确后,重启服务才会正常!
7)、测试结果
本地测试:
curl 127.0.0.1
curl 127.0.0.1/info.php
浏览器测试:
http://192.168.1.191/
http://192.168.1.191/info.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
4、错误处理:nginx打开php文件总是显示下载,并开始下载我的 info.php 文件
这是之前学习时遇到的问题(另一个虚拟机)
原因同上!
1
2
5、错误处理:nginx打开php文件,显示 502 Bad Gateway
回头处理之前学习时遇到的问题(另一个虚拟机)
不出现下载了,但是,出来 502 Bad Gateway 错误

检查 /etc/nginx/sites-available/default 配置中 php部分
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

cd /var/run/php/
ls
php7.2-fpm.pid

只有一个 pid 文件!没有发现存在这个文件 php7.2-fpm.sock ?
怎么安装的 php-fpm?

sudo vim /etc/nginx/sites-available/default
先改用 php-cgi 方式
fastcgi_pass 127.0.0.1:9000;

重启 php7.2-fpm 服务
sudo systemctl restart php7.2-fpm.service
重启 nginx
sudo systemctl restart nginx

再次测试
http://192.168.1.192/info.php
可以看到正确信息了
PHP Version 7.2.10-0ubuntu0.18.04.1
..
*** php-cgi 方式 和 php-fpm 方式差别在哪里来着?需要再次学习去!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28


***经过回忆:
之前的虚拟机上的 php 是直接按照ubuntu 18.04 官网介绍一次整体安装了 LAMP
之后是自己从头 LNMP 一个一个手工安装的!

 
 
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • Ubuntu使用——15(thinkphp路由报错Non-static method think\Route::get() should not be called statically)
    Ubuntu使用——15(thinkphp路由报错Non-static
    在route.php中添加代码:use think\Route;Route::get('/',function (){return 'hello world';});在浏览器中输入http://localhost/tp5-git/public/index.php,报错:[8192] ErrorException in route.php line 13Non-static method think\Route::get() should n
    03-08
  • Ubuntu与Window双系统安装的注意事项
    Ubuntu与Window双系统安装的注意事项
      UBUNTU与WINDOW双系统安装的注意事项 由 匿名 (未验证) 提交于 2019-05-18 10:07:41登录 发表评论29 次浏览假定电脑里面已经存在了Window系统,安装另外一个Linux系统:第一:首先确定电脑里面的window系统引导方式电脑系统的引导方式分为:(1)传统
    03-08
  • Ubuntu 图形界面损坏修复方法!!!亲测有用!!!
    Ubuntu 图形界面损坏修复方法!!!亲测有用!
    1.现象今天做实验的时候打开Ubuntu虚拟机,输入密码之后发现变成这样:然后重新开机,到了输入密码界面不输入,而是输入快捷键CTRL+alt+F1,输入用户名+密码进入之后输入ls,发现我的文件还在,心想这不是系统炸了啊上网搜说是图形界面损坏于是重新来:(参考
    03-08
  • Ubuntu终端输入异常、无法退格(删除文本)、使用方向键命令
    Ubuntu终端输入异常、无法退格(删除文本)、使
    1 起因为了学习嵌入式开发安装去安装的ncurses库,使用命令:sudo apt-get install libncurses5-dev导致系统自带的ncurses-base被自动删除。2 出现的问题误删ncurses-base后导致终端输入窗口出现了一系列的问题:Ubuntu终端输入无法退格(删除文本)、使用↑
    03-08
  • Raspberry Pi (Ubuntu) 上的 VNC 无监视器
    Raspberry Pi (Ubuntu) 上的 VNC 无监视器
    超级方便的无监视器VNC方便的树莓派远程桌面操作,无需显示器\(^^)/通过在页面末尾设置“无显示器设置”,可以在启动树莓派之前和之后连接和断开 HDMI 显示器电缆(这很重要)。来自主 PC 的远程桌面环境树莓派 4Ubuntu 20.04(64位)服务器+桌面设置VNC 设
    03-08
  • 免费供个人使用最多3个! !我尝试注册 ESM 将 Ubuntu LTS 版本的支持期延长 5 年
    免费供个人使用最多3个! !我尝试注册 ESM 将
    我个人使用 Ubuntu 作为我的 Linux 机器的操作系统。 Ubuntu 有正常版本和 LTS(长期支持)版本的操作系统。至此,版本号奇数为普通版,偶数为LTS版,LTS版长期支持5年,而普通版有支持期半年左右。。由于Linux机器用作GPU服务器,由于驱动程序和库的兼容性等
    03-08
  • [WSL2 Ubuntu22.04] 尝试使用 WSLg 运行 Elixir Desktop(未完成)
    [WSL2 Ubuntu22.04] 尝试使用 WSLg 运行 Elixir
    现状启用 WSLg 后,Elixir Desktop 会不会像在 Ubuntu 上一样工作?Elixir 桌面示例我试着跑步窗口显示并似乎在移动,但 Todo 应用程序未显示在窗口中。这是一个空白的显示。显示窗口和菜单。Extra 的内容也可以单独使用。如果您使用 Extra 的 Open Browser
    03-08
  • ubuntu中vi下删除键和上下左右键输入字符异常(
     刚安装的Ubuntu系统,使用vi编辑文本的时候,出现以下现象:点删除键输入了 D回车无效上下左右为字母光标乱跳 原因:自带的vi功能问题 解决:卸载原有vi,重新安装完整版本vim执行以下命令即可: sudo apt-get remove vim-common sudo apt-get install v
    02-10
  • ubuntu禁止ping操作(禁用ICMP协议访问) icmp
    ping命令是计算机之间进行相互检测线路完好的一个应用程序,计算机间交流数据的传输没有经过任何的加密处理,因此我们在用ping命令来检测某一个服务器时,可能在因特网上存在某个非法分子,为了安全我们把ping给禁止掉。通过专门的黑客程序把在网络线路上传输
    02-10
  • Ubuntu16配置静态IP ubuntu16.04配置静态ip
    一、静态IP地址配置sudo vi/etc/network/interfaces然后按照如下格式修改:注意这里的网卡名字是ens33auto loiface lo inet loopbackauto ens33iface ens33 inet staticaddress 192.168.1.106netmask 255.255.255.0gateway 192.168.1.1二、配置DNS#临时修改su
    02-10
点击排行