玩客云搭建WordPress环境(lnmp)教程
1.1 準備環境
環境:Linux aml-s812 5.9.0-rc7-aml-s812 #20.10 SMP Sun Nov 22 13:29:35 CST 2020 armv7l armv7l armv7l GNU/Linux
1.2 其他
其他:一個不需要太聰明的大腦以及一點點時間和一點點耐心
1.3目錄
2.安裝軟件
2.1.1登錄玩客云
2.1.2更新
2.2安裝nginx
?2.3安裝php7.4
2.4安裝Mariadb
3.配置環境
3.1配置nginx
3.2配置Mariadb
3.2.1安全設置
3.2.2 賬戶設置?
3.2.2 遠程連接MySQL
?4.1新增wordpress賬戶
5.Wordpres使用
5.1下載Wordpres
??5.1wordpres
2.安裝軟件
2.1.1登錄玩客云
2.1.2更新
更新軟件信息和更新軟件
apt update apt upgrade -y2.2安裝nginx
輸入apt-get -y install nginx回車
apt-get -y install nginx然后就安裝成功了
輸入玩客云ip地址我這里是:10.0.0.109
?2.3安裝php7.4
復制回車遠行,然后等
apt install -y php7.4 php7.4-fpm php7.4-mysql php7.4-gd php7.4-curl php7.4-mbstring php7.4-xml php7.4-xmlrpc php7.4-json php7.4-zip php7.4-intl php7.4-xsl?php -v查詢版本號
2.4安裝Mariadb
apt install -y mariadb-server? mysql?-v查詢版本號
3.配置環境
3.1配置nginx
首先輸入vim /etc/nginx/sites-enabled/default,打開nginx配置文件
vim /etc/nginx/sites-enabled/default?在44行前面添加index.php,56行和60行以及63行去除行頭#號
?如圖所示
?輸入nginx -t
root@aml-s812:~# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful表示沒有問題
?重新啟動nginx
service nginx restart新建測試頁面文件(后面記得刪除)?
echo "<?php phpinfo(); ?>">/var/www/html/info.php瀏覽器打開ip/info.php
?就可以看到php的相關信息了
3.2配置Mariadb
3.2.1安全設置
輸入mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here.Enter current password for root (enter for none): 注意:建議所有人都運行此腳本的所有部分服務器在生產中使用!請仔細閱讀每一步!為了登錄MariaDB以確保其安全,我們需要當前根用戶的密碼。如果你剛剛安裝了MariaDB您尚未設置根密碼,密碼將為空,所以你應該在這里按回車鍵。輸入root用戶的當前密碼(輸入無):我們剛剛安裝,沒有密碼直接回車?
Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.You already have a root password set, so you can safely answer 'n'.Change the root password? [Y/n] 設置root密碼可以確保任何人都無法登錄MariaDB未經適當授權的root用戶。您已經設置了根密碼,因此可以安全地回答“n”。更改根密碼?[是/否]輸入y設置一個簡單而且你記得住密碼? 我這里是P@ssW0
By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.Remove anonymous users? [Y/n] 默認情況下,MariaDB安裝有匿名用戶,允許任何人登錄MariaDB而無需為其創建用戶帳戶他們這僅用于測試和安裝再平穩一點。你應該在搬進公寓前把它們取下來生產環境。刪除匿名用戶?[是/否]y? 刪除就完了
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] 通常,root用戶只能從“localhost”連接。這確保有人無法從網絡中猜到根密碼。不允許根用戶遠程登錄?[是/否]n方便修改
By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.Remove test database and access to it? [Y/n] 默認情況下,MariaDB附帶一個名為“test”的數據庫,任何人都可以使用通道這也僅用于測試,應移除在進入生產環境之前。刪除測試數據庫并訪問它?[是/否]n沒有用直接刪除
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.Reload privilege tables now? [Y/n] 重新加載特權表將確保迄今為止所做的所有更改將立即生效。現在重新加載特權表嗎?[是/否]y
3.2.2 賬戶設置?
?直接輸入mysql直接登錄
mysql查詢用戶表
select User,host from mysql.user;使用mysql數據庫
use mysql; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '6166b2002fdcb5df' WITH GRANT OPTION; ALTER USER 'root'@'%' IDENTIFIED BY '6166b2002fdcb5df'; ALTER USER 'root'@'localhost' IDENTIFIED BY 'P@ssW0rd'; update user set plugin = 'mysql_native_password' where user = 'root';添加一個可以從任何地址登錄的root賬戶密碼建議復雜一點
flush privileges;刷新
exit退出
vim /etc/mysql/mariadb.conf.d/50-server.cnf把29行bind-address = 127.0.0.1 改為 bind-address = 0.0.0.0
systemctl restart mysql?重啟Mariadb
3.2.2 遠程連接MySQL
mysql -u root -p -h 10.0.0.109拿cmd連接看看?
?4.1新增wordpress賬戶
create user wordpress@'10.0.0.%' identified by '02fdcb5df'; create database www_wordpress default charset utf8; grant all on www_wordpress.* to wordpress@'10.0.0.%' identified by '02fdcb5df';新建賬戶,新建數據庫,給權限
5.Wordpres使用
5.1下載Wordpres
wget https://cn.wordpress.org/latest-zh_CN.tar.gz tar xvzf latest-zh_CN.tar.gz rm -rf html mv wordpress html給www的讀寫權限
chown -R www-data /var/www/html chmod -R 755 /var/www/html??5.1wordpres
瀏覽器輸入ip
?按自己的輸入信息
安裝完成
總結
以上是生活随笔為你收集整理的玩客云搭建WordPress环境(lnmp)教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么用好系统重装助手装机?
- 下一篇: Qt实现一个简单的应用程序——桌面助手