Linux网站服务之部署Wordpress教程
一、环境准备1、云服务器(最好是国外的服务器或者是家用本地服务器,如果是在阿里云或者腾讯云里买服务器都需要给网站备案)。2、域名(推荐用免费的域名,或者是在阿里云或者腾讯云里买个域名,做云服务器绑定ip的)。3、源码包(需要准备lnmp脚本和wordpress包,都需要在官网下载)。下载链接:下载WordPress最新版(提取码:srri)二、环境搭建1、下载lnmp脚本并且执行。wget htt
一、环境准备
1、准备云服务器、公网ip、和域名,推荐用国外的,在国内使用服务器、公网ip和域名都需要备案的。
namecheap国外网站(最好用翻墙软件访问)
https://namecheap.com
3、源码包(需要准备lnmp脚本和wordpress包,都需要在官网下载)。
下载链接:
https://pan.baidu.com/share/init?surl=IO9YT6ChImSwQylR6CDqZw
提取码:srri
二、环境搭建
1、下载lnmp脚本并且执行。
wget http://soft.vpser.net/lnmp/lnmp1.8.tar.gz -cO lnmp1.8.tar.gz && tar zxf lnmp1.8.tar.gz && cd lnmp1.8 && ./install.sh lnmp
2、选择第7个。
+------------------------------------------------------------------------+
| LNMP V1.8 for CentOS Linux Server, Written by Licess |
+------------------------------------------------------------------------+
| A tool to auto-compile & install LNMP/LNMPA/LAMP on Linux |
+------------------------------------------------------------------------+
| For more information please visit https://lnmp.org |
+------------------------------------------------------------------------+
You have 11 options for your DataBase install.
1: Install MySQL 5.1.73
2: Install MySQL 5.5.62 (Default)
3: Install MySQL 5.6.51
4: Install MySQL 5.7.34
5: Install MySQL 8.0.25
6: Install MariaDB 5.5.68
7: Install MariaDB 10.1.48
8: Install MariaDB 10.2.38
9: Install MariaDB 10.3.29
10: Install MariaDB 10.4.19
0: DO NOT Install MySQL/MariaDB
Enter your choice (1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or 0): 7
You will install MariaDB 10.1.48
===========================
Please setup root password of MySQL.
Please enter: 123.com
MySQL root password: \\必须要填写密码
===========================
Do you want to enable or disable the InnoDB Storage Engine?
Default enable,Enter your choice [Y/n]: y
You will enable the InnoDB Storage Engine
3、安装PHP
You have 9 options for your PHP install.
1: Install PHP 5.2.17
2: Install PHP 5.3.29
3: Install PHP 5.4.45
4: Install PHP 5.5.38
5: Install PHP 5.6.40 (Default)
6: Install PHP 7.0.33
7: Install PHP 7.1.33
8: Install PHP 7.2.34
9: Install PHP 7.3.29
10: Install PHP 7.4.21
11: Install PHP 8.0.8
Enter your choice (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11): 6 \\填写第6个,因为WordPress支持php7的版本
You will install PHP 7.0.33
===========================
You have 3 options for your Memory Allocator install.
1: Don't install Memory Allocator. (Default)
2: Install Jemalloc
3: Install TCMalloc
Enter your choice (1, 2 or 3): \\直接回车
No input,You will not install Memory Allocator.
Press any key to install...or Press Ctrl+c to cancel \\直接回车,就执行安装了,然后打会儿游戏
6、将wordpress安装包上传到服务器里,然后创建/var/www/html目录,并且解压到/var/www/html目录下。
[root@rainlist ~]# mkdir -p /var/www/html
[root@rainlist ~]# tar xf wordpress-5.4.tar.gz -C /var/www/html/ \\解压到/var/www/html的目录下
[root@rainlist ~]# ls /var/www/html/wordpress
index.php readme.html wp-admin wp-comments-post.php wp-content wp-includes wp-load.php wp-mail.php wp-signup.php xmlrpc.php
license.txt wp-activate.php wp-blog-header.php wp-config-sample.php wp-cron.php wp-links-opml.php wp-login.php wp-settings.php wp-trackback.php
5、安装完成后提示这个界面,并且访问一下是否正常。
Checking ...
Nginx: OK
MariaDB: OK
PHP: OK
PHP-FPM: OK
Clean Web Server src directory...
+------------------------------------------------------------------------+
| LNMP V1.8 for CentOS Linux Server, Written by Licess |
+------------------------------------------------------------------------+
| For more information please visit https://lnmp.org |
+------------------------------------------------------------------------+
| lnmp status manage: lnmp {start|stop|reload|restart|kill|status} |
+------------------------------------------------------------------------+
| phpMyAdmin: http://IP/phpmyadmin/ |
| phpinfo: http://IP/phpinfo.php |
| Prober: http://IP/p.php |
+------------------------------------------------------------------------+
| Add VirtualHost: lnmp vhost add |
+------------------------------------------------------------------------+
| Default directory: /home/wwwroot/default |
+------------------------------------------------------------------------+
| MySQL/MariaDB root password: 123.com |
+------------------------------------------------------------------------+
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
nginx (pid 7532) is running...
php-fpm is runing!
SUCCESS! MariaDB running (7888)
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 :::3306 :::*
Install lnmp takes 45 minutes.
Install lnmp V1.8 completed! enjoy it.
6、用google浏览器访问测试,如果访问正常就没问题了。
7、修改nginx.conf文件的网站路径。
[root@localhost ~]# cd /usr/local/nginx/conf/
[root@localhost conf]# cp -a nginx.conf{,.bak} \\备份nginx.conf文件,方便以后使用
[root@localhost conf]# ls
enable-php.conf example fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.bak pathinfo.conf scgi_params uwsgi_params vhost
enable-php-pathinfo.conf fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf nginx.conf.default rewrite scgi_params.default uwsgi_params.default win-utf
[root@localhost conf]# vim nginx.conf \\修改以下内容
63 server
64 {
65 listen 80 default_server reuseport;
66 #listen [::]:80 default_server ipv6only=on;
67 server_name _;
68 index index.html index.htm index.php;
69 root /var/www/html/wordpress; \\默认路径是/home/wwwroot/default,给它改成/var/www/html/wordpress
70
71 #error_page 404 /404.html;
8、创建wordpress数据库,然后退出。
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.48-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| wordpress |
+--------------------+
4 rows in set (0.01 sec)
MariaDB [(none)]> quit;
9、修改wp-config.php文件。
[root@rainlist ~]# cd /var/www/html/wordpress/
[root@rainlist wordpress]# ls
index.php readme.html wp-admin wp-comments-post.php wp-content wp-includes wp-load.php wp-mail.php wp-signup.php xmlrpc.php
license.txt wp-activate.php wp-blog-header.php wp-config-sample.php wp-cron.php wp-links-opml.php wp-login.php wp-settings.php wp-trackback.php
[root@rainlist wordpress]# cp wp-config-sample.php wp-config.php \\把wp-config-sample.php复制成wp-config.php
[root@rainlist wordpress]# vim wp-config.php \\编辑wp-config.php文件
\\请修改以下内容
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', '数据库名称' );
/** MySQL database username */
define( 'DB_USER', '数据库用户' );
/** MySQL database password */
define( 'DB_PASSWORD', '数据库密码' ); \\修改完成后,然后保存退出
10、重启lnmp服务。
[root@localhost ~]# lnmp restart
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
Stoping LNMP...
Stoping nginx... done
Stopping mariadb (via systemctl): [ OK ]
Gracefully shutting down php-fpm . done
Starting LNMP...
Starting nginx... done
Starting mariadb (via systemctl): [ OK ]
Starting php-fpm done
三、配置wordpress
1、重启lnmp后,直接在浏览器里访问http://你的ip地址,修改以下内容。
注意:配置好后,会显示log in界面。直接登录即可。
2、登录wordpress并且修改成中文版。
注意:因为是英文版,需要在官网上下中文版,然后在中文版找到languages文件夹,上传到服务器里,复制到/var/www/html/wordpress/wp-content的文件下。
四、关于主题的设置。
-
登录WordPress控制面板
-
点击外观 – 主题
-
在右侧主题,点击添加
-
在添加主题页面,点击上传主题
-
在文件浏览窗口选择要上传的主题,注意一定要是zip格式的主题,如果不是,先自行压缩一下
-
上传完成后点击现在安装
-
安装完成后,就可以预览或者启用这个主题了
五、域名绑定
1、我目前用的是阿里云的服务器以及域名,因为做了网站后需要备案,就先省略那个操作,接下来看一下以下图形,看看我是怎么操作的。登录阿里云然后找到域名,点击解析设置。
2、点击添加记录。
3、直接添加两个A记录。
4、修改主机名和hosts文件,主机名和hosts文件里,必须是你的域名,否则访问不到。
[root@localhost ~]# hostnamectl set-hostname rainlist && bash
[root@rainlist ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
123.56.222.102 rainlist.top
更多推荐
所有评论(0)