怎样用阿里云搭建个人博客
1 工具 :阿里云服務器,WordPress,
2 部署好阿里云服務器創建好實例以后,用本地的XShell 連接遠程服務器,一般的話我喜歡用CentOS系統。連上以后
1 安裝一個擴展源
yum install epel-release
2 下載nginx
安裝完成以后查看nginx版本
3 啟動nginx
4設置開機自啟動
(2)下載PHP
進入這個網站下載你需要下載的版本
https://www.php.net/downloads.php
然后復制對應的tar.gz 鏈接到XShell里邊
(3)
wget 鏈接地址
4 解壓
5 安裝PHP所需的依賴
這個鏈接里匯總了安裝PHP里邊可能出現的一些問題集錦
yum install gcc gcc-c++ libxm12-devel openssl-dev libcurl-devel freetype-devel libjpeg-devel libpng-devel libxslt-devel systemd-devel libicu-devel libedit-devel
6 創建user
7 編譯配置參數
報找不到libzip的錯誤
報這個錯誤 Cannot find OpenSSL’s evp.h
解決方法
報這個錯誤 error:Please reinstall the BZip2 distribution
解決方案
每次執行完命令以后都要重新運行上邊那一大堆代碼進行檢查
然后由于中間還有部分報錯,這里就沒有摘錄了,最后安裝成功是這樣的。
中間安裝那塊可以看PHP安裝的這一節
https://www.bilibili.com/video/BV1JJ411W72p?p=4&spm_id_from=pageDriver
配置成功以后輸入 make 進行編譯
過程比較長,請耐心等待
啟動后還有錯誤,還是一步一步跟著視頻做比較好
php部署成功后登錄可以看到PHP的界面
安裝mysql
我的centos版本是7 所以需要到這個頁面里下載 Linux7版本的mysql
https://dev.mysql.com/downloads/file/?id=508902
mysql版本是5.7的
安裝成功
到這個頁面下載WordPress
https://wordpress.org/download/
下載以后解壓,并移動到這個目錄
給用戶 賦予 www權限
布置完上面的操作之后,輸入你的ip到瀏覽器就可以看到如下頁面
最后附上上述操作的全部代碼
ps -ef|grep nginx 查看nginx的進程 systemctl enable nginx 設置為開機自啟動wget https://www.php.net/distributions/php-7.3.13.tar.gz 下載php tar xf php-7.3.13.tar.gz 解壓在php 目錄下安裝 依賴的環境 yum install gcc gcc-c++ libxm12-devel openssl-dev libcurl-devel freetype-devel libjpeg-devel libpng-devel libxslt-devel systemd-devel libicu-devel libedit-devel在php下創建用戶 useradd -M -s /sbin/nologin wwwid www安裝 一些需要用到的庫 yum install libzip -y yum install libzip-devel -y yum install openssl openssl-devel yum install bzip2 bzip2-devel yum install gmp-devel -y yum -y install readline-devel編譯的配置參數: ./configure \--prefix=/usr/local/php\--enable-fpm\--with-fpm-user=www\--with-fpm-group=www\--with-config-file-path=/usr/local/php/conf\--disable-rpath\--enable-soap\--with-libxml-dir\--with-xmlrpc\--with-openssl\--with-mhash\--with-pcre-regex\--with-zlib\--enable-bcmath\--with-bz2\--enable-calendar\--with-curl\--enable-exif\--with-pcre-dir\--enable-ftp\--with-gd\--with-openssl-dir\--with-jpeg-dir\--with-png-dir\--with-zlib-dir\--with-freetype-dir\--enable-gd-jis-conv\--with-gettext\--with-gmp\--with-mhash\--enable-mbstring\--with-onig\--with-mysqli=mysqlnd\--with-pdo-mysql=mysqlnd\--with-zlib-dir\--with-readline\--enable-shmop\--enable-sockets\--enable-sysvmsg\--enable-sysvsem \--enable-sysvshm \--enable-wddx\--with-libxml-dir\--with-xsl\--enable-zip\--with-pear如果報錯 checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11 那么卸載重新安裝libzip yum remove libzip libzip-devel -ywget https://libzip.org/download/libzip-1.8.0.tar.gz 下載好以后解壓 tar xf libzip-1.8.0.tar.gz 進入目錄 創建 mkdir build cd build yum install cmake3 -y cmake3 ..cp /usr/bin/cmake3 /usr/bin/cmake 然后再執行make 命令 (在build目錄下) 然后 make install 然后輸入 echo $? 如果返回0 說明正常再 到php目錄執行很長的一段配置 報錯check your library configuration 進入 vim /etc/ld.so.conf 添加 /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 然后輸入 ldconfig再次進行編譯 ,直到這個界面出現 creating main/internal_functions_cli.c +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+Thank you for using PHP.然后 make 命令編譯然后 make install 完成以后到php 文件夾下 執行 [root@iz8vbetpyzn77hkpieizu5z php-7.3.13]# cp php.ini-development /usr/local/php/etc/php.ini [root@iz8vbetpyzn77hkpieizu5z php-7.3.13]# cd /usr/local/php/etc/ [root@iz8vbetpyzn77hkpieizu5z etc]# cp php-fpm.conf.default php-fpm.conf[root@iz8vbetpyzn77hkpieizu5z etc]# cd [root@iz8vbetpyzn77hkpieizu5z ~]# cd php-7.3.13 [root@iz8vbetpyzn77hkpieizu5z php-7.3.13]# cd sapi/fpm [root@iz8vbetpyzn77hkpieizu5z fpm]# cp php-fpm.service /usr/lib/systemd/system/ [root@iz8vbetpyzn77hkpieizu5z fpm]# systemctl start php-fpm查看啟動狀態 [root@iz8vbetpyzn77hkpieizu5z fpm]# systemctl status php-fpm 沒有啟動成功 [root@iz8vbetpyzn77hkpieizu5z fpm]# cd /usr/local/php/etc/php-fpm.d/ [root@iz8vbetpyzn77hkpieizu5z php-fpm.d]# ls www.conf.default [root@iz8vbetpyzn77hkpieizu5z php-fpm.d]# cp www.conf.default www.conf [root@iz8vbetpyzn77hkpieizu5z php-fpm.d]# ls www.conf www.conf.default [root@iz8vbetpyzn77hkpieizu5z php-fpm.d]# 再次啟動 就啟動成功了 [root@iz8vbetpyzn77hkpieizu5z php-fpm.d]# systemctl start php-fpm [root@iz8vbetpyzn77hkpieizu5z php-fpm.d]# systemctl status php-fpm ● php-fpm.service - The PHP FastCGI Process ManagerLoaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)Active: active (running) since Fri 2021-12-10 12:10:17 CST; 3s agoMain PID: 15989 (php-fpm)CGroup: /system.slice/php-fpm.service├─15989 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)├─15990 php-fpm: pool www└─15991 php-fpm: pool wwwDec 10 12:10:17 iz8vbetpyzn77hkpieizu5z systemd[1]: Started The PHP FastCGI Process Manager. 回到nginx 配置[root@iz8vbetpyzn77hkpieizu5z php-fpm.d]# cd /etc/nginx [root@iz8vbetpyzn77hkpieizu5z nginx]# mv nginx.conf nginx.conf.bak [root@iz8vbetpyzn77hkpieizu5z nginx]# cp nginx.conf.default nginx.confvim nginx.conf下面是nginx.conf配置的內容 #user nobody; worker_processes 1;#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024; }http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;root /www/wordpress;location / {index index.php index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;include fastcgi.conf;}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}[root@iz8vbetpyzn77hkpieizu5z wordpress]# echo "<?php phpinfo();?>" >index.php [root@iz8vbetpyzn77hkpieizu5z wordpress]# vim index.php [root@iz8vbetpyzn77hkpieizu5z wordpress]# nginx -s reload 然后看頁面能否查看到index.php能查看到就說明配置成功安裝mysql [root@iz8vbetpyzn77hkpieizu5z ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-4.noarch.rpm [root@iz8vbetpyzn77hkpieizu5z ~]# yum install mysql80-community-release-el7-4.noarch.rpm [root@iz8vbetpyzn77hkpieizu5z ~]# yum list all|grep mysql [root@iz8vbetpyzn77hkpieizu5z ~]# yum install yum-utils -y [root@iz8vbetpyzn77hkpieizu5z ~]# yum-config-manager --disable mysql80-community[root@iz8vbetpyzn77hkpieizu5z ~]# yum-config-manager --enable mysql57-community[root@iz8vbetpyzn77hkpieizu5z ~]# yum install mysql-community-server -y[root@iz8vbetpyzn77hkpieizu5z ~]# systemctl start mysqld [root@iz8vbetpyzn77hkpieizu5z ~]# systemctl status mysqld ● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since Fri 2021-12-10 12:52:47 CST; 17s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 29601 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)Process: 29552 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)Main PID: 29605 (mysqld)CGroup: /system.slice/mysqld.service└─29605 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pidDec 10 12:52:41 iz8vbetpyzn77hkpieizu5z systemd[1]: Starting MySQL Server... Dec 10 12:52:47 iz8vbetpyzn77hkpieizu5z systemd[1]: Started MySQL Server.[root@iz8vbetpyzn77hkpieizu5z ~]# cat /var/log/mysqld.log 找到這一句,后邊有臨時密碼就是登錄數據庫的密碼[Note] A temporary password is generated for root@localhost: P=Jr,OC+t7B/ 2021-12-10T04:52:47.209086Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_def登錄以后修改數據庫密碼 mysql> alter user 'root'@'localhost' identified by '你的數據庫密碼'; 創建用戶create user 'user'@'%' identified by '000000'; 授權 mysql> grant all privileges on wordpress.* to 'user'@'%';下載wordpress程序 [root@iz8vbetpyzn77hkpieizu5z ~]# wget https://wordpress.org/latest.tar.gz使用tar xf 解壓[root@iz8vbetpyzn77hkpieizu5z ~]# mv wordpress/* /www/wordpress/[root@iz8vbetpyzn77hkpieizu5z ~]# chown -R www.www /www此時訪問瀏覽器就可以訪問到你的wordpress了總結
以上是生活随笔為你收集整理的怎样用阿里云搭建个人博客的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 站外营销经典方式之论坛发帖技巧
- 下一篇: mxf修复案例