lnmp ubuntu 20.04

原文链接:https://www.tl8517.com/lnmp-ubuntu-20-04/

lnmp ubuntu 20.04 在Ubuntu安装nginx服务器,phpwordpressmysqlphpmyadmin

更新系统

sudo apt update
sudo apt upgrade

安装nginx

sudo apt install nginx

安装mysql,设置root及秘密。

sudo apt install mysql-server-8.0 mysql-client-8.0 

sudo mysql -uroot

mysql> use mysql;

mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';

mysql> FLUSH PRIVILEGES;

mysql> exit;

csjtl@ubuntu:~$ sudo service mysql restart

csjtl@ubuntu:~$ mysql -uroot -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

mysql> exit

csjtl@ubuntu:~$ mysql -uroot -p

mysql> CREATE DATABASE wordpress;

mysql> FLUSH PRIVILEGES;

mysql> exit

安装php

csjtl@ubuntu:~$ sudo apt install php7.4-fpm php7.4-mysql php7.4 php7.4-gd php7.4-cgi php7.4-curl php7.4-mbstring php7.4-zip
csjtl@ubuntu:~$ ps -ef |grep php

安装phpmyadmin

csjtl@ubuntu:~$ wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.tar.gz
tar -xvf phpMyAdmin-5.0.2-all-languages.tar.gz 
mv phpMyAdmin-5.0.2-all-languages phpmyadmin
csjtl@ubuntu:~$ sudo cp -r phpmyadmin /var/www/html/

配置nginx站点默认端口和网站路径

csjtl@ubuntu:~$ sudo vi /etc/nginx/sites-available/default 

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

        listen 443 default_server;
        listen [::]:443 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

csjtl@ubuntu:~$ sudo service nginx restart

安装wordpress:默认安装目录为/usr/share/wordpress

csjtl@ubuntu:~$ wget https://cn.wordpress.org/latest-zh_CN.tar.gz
csjtl@ubuntu:~$ tar -xvf latest-zh_CN.tar.gz
csjtl@ubuntu:~$ cd wordpress
csjtl@ubuntu:~$ sudo mv * /var/www/html
csjtl@ubuntu:~$ cd /var/www/html

csjtl@ubuntu:~$ sudo cp wp-config-sample.php wp-config.php                    //重命名为wp-config.php文件

sudo vim wp-config.php                                   //(11)编辑wp-config.php文件

默认内容如下:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');
/** MySQL database username */
define('DB_USER', 'username_here');
/** MySQL database password */
define('DB_PASSWORD', 'password_here');
/** MySQL hostname */
define('DB_HOST', 'localhost');
将其修改为:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** MySQL hostname */
define('DB_HOST', 'localhost');

服务器IP/wp-admin/install.php                               //(12)安装

服务器ip/wp-login.php                                       //(13)登陆

UBUNTUSERVER更多内容:

https://www.tl8517.com/category/personal-website-building/ubuntuserver/

ubuntu lamp 搭建(Apache+PHP+Mysql环境):

https://tl8517.com/ubuntu-lamp/

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值