在服务器上搭建wordpress个人博客 php7.2+nginx+mysql+wordperss

买了台VPS,准备搭建一个博客。用过几个博客框架还是觉得Wordpress好用。主题多,插件也非常的便利,而且大多还免费开源。搭建也很简单,其实安装好php+mysql+nginx+wordpress就差不多了。其他的需要一些简单的配置就可以挂上去了。

输入以下命令安装MySQL+nginx+php:

sudo apt-get update
apt-get install mysql server mysql-client
apt-get install nginx
apt-get install php7.2 php-mysql php7.2-fpm php-pear php7.2-curl php7.2-json php7.2-cgi php7.2-mysql

查看安装版本 nginx -v / mysql -v / php7.2 -v

 
使用FTP上传SSL证书
如果没有安装可以查看我 安装vsftpd文
没有SSL证书可以去freessl.cn免费获取一个证书
 
 
这里我使用MacOS自带的 scp命令
 
工作目录移动到你SSL证书文件路径下然后执行以下命令:
Filepath 是你的文件名 root你服务器用户名 serverhost服务器地址 :~ (上传到~路径)
sudo scp filepath root@serverhost:~ 
解压证书放到/etc/ssl/wordpress/下(按照你的需求选择,这里的演示将使用该路径)
解压命令
zip文件解压
sudo unzip youfile.zip -d /etc/ssl/wordpress/
tar文件解压
tar -zxvf youfile.tar -c /etc/ssl/wordpress

 

 
 
修改nginx配置文件
路径一般在:vi /etc/nginx/sites-available/default 
修改内容如下:
 
server {
        #监听80http端口
        #listen 80 default_server;
        #listen [::]:80 default_server;

        # SSL configuration
        #SSL配置 监听443SSL端口 https
         listen 443 ssl;
         listen [::]:443 ssl;
        #
        # 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/wordpress;
       #SSL证书配置 注意 这里要填写你证书的路径里的两个文件,这里是我的pem和key文件
        ssl_certificate /etc/ssl/wordpress/fechain.pem;
        ssl_certificate_key /etc/ssl/wordpress/private.key;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        # Add index.php to the list if you are using PHP
        #网站主页配置 php主页记得加index.php
        index index.html index.htm index.php;
        #填写你的服务器
        server_name hhxblog.ml;

        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
        #启用php,fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;对应你的php-fpm版本
        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;
        }

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

 

 
重启nginx
service nginx start (这里报错可能是上面的配置错误了)
 

使用wget获取并解压wordpress

cd /var/www
sudo wget https://wordpress.org/latest.zip
unzip latest.zip
 

MySQL数据库配置 

参考官网 https://codex.wordpress.org/zh-cn:安装WordPress#.E6.AD.A5.E9.AA.A43:.E8.AE.BE.E7.BD.AEwp-config.php
参考代码搬运:
$ mysql -u adminusername -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname"
    -> IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
  
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> EXIT
Bye
$ 
 

修改wordpress配置文件

cd 你的wordpress路径/
sudo mv wp-config-sample.php wp-config.php
vi wp-config.php(根据提示填写数据库信息)
 
填写你数据库信息 参考官网 :https://codex.wordpress.org/zh-cn:编辑_wp-config.php
注意:配置里的 Authentication Unique Keys and Salts 需要填写
官网生成AUKS地址: https://api.wordpress.org/secret-key/1.1/salt/
 
然后打开你的网站按照提示配置即可完成安装!
https://youhost/
 
辛苦码字,转载请著名出处! https://www.hhxblog.ml

转载于:https://www.cnblogs.com/galoliy/p/install-wordpress.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值