Install Wordpress on Ubuntu 22.04, add LNMP configuration (non-pagoda installation)

Briefly introduce relevant information

  • Ubuntu22.04 and above
  • Nginx1.18
  • Mysql8.0
  • PHP8.2.1
  • wordpress6.1.1
  • Redis7.0.7 (lazy cancer committed~~do it in the next issue)
  • pagoda
  • Common to machines at home and abroad

**Let’s start without further ado** (* The demonstration here uses the root user by default )

1. Update the software source package list and install the necessary components

apt update && apt install wget curl nano libgd3 -y
#这两个都行
apt-get update && apt-get install wget curl nano libgd3 -y

Two, install nginx

apt install nginx -y
#ubuntu22.04默认版本就是1.18

#检查nginx服务
systemctl status nginx

3. Install PHP

The php version of the apt package in Ubuntu22.04 does not have 8.2, we install php8.2 by adding source

add-apt-repository ppa:ondrej/php
#输入之后会出现Press [ENTER] to continue or Ctrl-c to cancel.按回车就好

apt install php8.2 && php8.2-fpm -y

#这里我们用nginx,删掉apache2
apt autoremove apache2 --purge -y

#检查php版本
php -v
#出现如下结果
#PHP 8.2.1 (cli) (built: Jan  6 2023 15:18:43) (NTS)

4. Install MySQL

apt install nginx mysql-server-8.0 php8.2-mysql -y
  • configure mysql

  • #注意:将'passwd'更改为你自己想要的密码
    mysql -u root -ppasswd
    
    #这条是8.0标准改root用户的密码
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'passwd';
    
    #这条是将root用户的访问权限变成任意位置
    UPDATE mysql.user SET user.Host='%' where user.User='root';
    
    #创建wordpress的数据库
    create database wordpress;
    
    #创建woredpress数据库的用户,并赋权
    create user 'wordpress'@'localhost' identified by 'passwd';
    
    GRANT ALL PRIVILEGES ON `wordpress`.* TO `wordpress`@`localhost`;
    
    flush privileges;
    
    #然后退出mysql
    exit
    

5. Install Redis

#此处位官方推荐安装方式
apt install lsb-release

curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

apt-get update && apt-get install redis -y
#检查版本
redis-cli -v
#redis-cli 7.0.7

6. Download wordpress

#你们也可用xftp或者finalshell直接从本地上传
wget https://cn.wordpress.org/latest-zh_CN.tar.gz

#解压
tar -zxvf latest-zh_CN.tar.gz 

#挪到web专用目录去
mv wordpress/ /var/www/html/

#调整权限
chmod -R 755 /var/www/html/
chown -R www-data:www-data /var/www/html/


Seven, configure nginx

rm -rf /etc/nginx/sites-enabled/default

nano /etc/nginx/sites-enabled/wp
#会用vim也可,此处用nano演示
#将下面的代码复制粘贴进去

server {
    
    
        listen 80 ;
        listen [::]:80 ;

        # listen 443 ssl http2;
        # listen [::]:443 ssl http2;
        root /var/www/html/wordpress;

        index index.php index.html index.htm index.nginx-debian.html;

        server_name localhost;

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

        location ~ \.php$ {
    
    
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php-fpm.sock;
        }

        location ~ /\.ht {
    
    
                deny all;
        }
}

#如上就是nginx最简配置代码

After the code is pasted in, press it Ctrl+x, and the following will appear

Save modified buffer?                                                                
 Y Yes
 N No           ^C Cancel

At this time, we press Y, and then enter

8. Configure wordpress

1. At this point we open the browser and enter http:// in the address bar此处写你云服务器的公网ip或者你局域网的服务器ip

2. After opening, it looks like this

start configuration

3. Click to start now, and then fill in the database information

Fill in the database information.webp

4. The submission is completed as follows, and then click to run the installer

Submit completed.webp

end of issue

  • The source of this article: When I first came into contact with the server, I liked tossing like many people. At that time, I simply wanted to create my own blog on the server. After reading a circle of wordpress, the most recommended people, I began to look for related installation and configuration tutorials. , but I started from ubuntu18.04 when I got started with linux. Many tutorials go to the pagoda installation for teaching. I used the pagoda once. I personally don’t like it. I think the pagoda is too troublesome and there are certain security issues. It is not particularly friendly, and the performance is not sufficient, so after I am proficient, I want to write a tutorial to update the latest version of this construction method as much as possible, so as to avoid too many pitfalls for the novice who loves to toss
  • If you like this article or related content, you can post related videos and post-optimization later
  • This article was created on 2023-01-10
  • Reprint please indicate the source.

Notice:

  1. The download speed of some software packages for domestic machines may not be very fast, you can change the source

  2. Most of the steps of the debian system machine are the same, only the installation of mysql8.0 is different. The mysql in the default source of debian11 is version 5.7. You can check the information and install mysql8.0 by yourself, or directly use mysql5.7.

  3. The full text of ufw is disabled by default. If you cannot access your website, you can try to disable ufw

    ufw disable
    

. The download speed of some software packages for domestic machines may not be very fast, you can change the source

  1. Most of the steps of the debian system machine are the same, only the installation of mysql8.0 is different. The mysql in the default source of debian11 is version 5.7. You can check the information and install mysql8.0 by yourself, or directly use mysql5.7.

  2. The full text of ufw is disabled by default. If you cannot access your website, you can try to disable ufw

    ufw disable
    

Guess you like

Origin blog.csdn.net/calm_programmer/article/details/128633128