上大學(xué)前一直籌劃自己建站當(dāng)站長,然而在早就買好的云服務(wù)器,一直只掛了一個靜態(tài)網(wǎng)站,也沒多少激情去維護(hù),自己開發(fā)的動態(tài)網(wǎng)站,emmm,我自己都看不下去的,有點先去,那" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運(yùn)營 > Debian+Nginx+MariaDB+PHP+WordPress詳細(xì)完整云端建站教程

Debian+Nginx+MariaDB+PHP+WordPress詳細(xì)完整云端建站教程

時間:2023-07-11 06:30:01 | 來源:網(wǎng)站運(yùn)營

時間:2023-07-11 06:30:01 來源:網(wǎng)站運(yùn)營

Debian+Nginx+MariaDB+PHP+WordPress詳細(xì)完整云端建站教程:

上大學(xué)前一直籌劃自己建站當(dāng)站長,然而在早就買好的云服務(wù)器,一直只掛了一個靜態(tài)網(wǎng)站,也沒多少激情去維護(hù),自己開發(fā)的動態(tài)網(wǎng)站,emmm,我自己都看不下去的,有點先去,那么我就搬輪子吧。就選擇WordPress,有強(qiáng)大的社區(qū)支持。 開始吧

準(zhǔn)備工作

服務(wù)器

無論是企業(yè)還是個人開發(fā)者,我都建議先使用云服務(wù)器,國內(nèi)建議阿里云和騰訊云,國外使用AWS是首選。政府網(wǎng)站建議使用物理服務(wù)器。

LNMP系統(tǒng) 我使用的是阿里云的云服務(wù)器, 1C2G物理配置,1Mbps的網(wǎng)絡(luò)和40G的高效硬盤。 系統(tǒng)采用Debian9.9 數(shù)據(jù)庫使用MariaDB10.4.12 webserver使用Nginx1.17.10 編程語言使用PHP7.4.5

阿里云服務(wù)器購買鏈接:https://www.aliyun.com/product/ecs?source=5176.11533457&userCode=kuoc2mgi&type=copy

下面是優(yōu)惠,需要的可以領(lǐng)取。 新用戶優(yōu)惠每年102元/年起:點擊我 新用戶2000元優(yōu)惠券:點擊我

域名

域名就是去各大域名廠家購買域名就行了,如果只是為了玩玩,建議購買.top域名,后期續(xù)費比較便宜,性價比比較高,其他的看個人愛好、網(wǎng)站用途、經(jīng)濟(jì)承受能力。

我的域名是在阿里云的域名市場購買的,國內(nèi)的網(wǎng)站要使用是需要備案的,個人備案的話準(zhǔn)備材料也也比較簡單,安裝官網(wǎng)操作就行,基本就是填寫資料,幕布拍照,然后就是等待管局審核,我首次申請就12天就完成了,阿里云為了補(bǔ)償我,給了我12天的云服務(wù)器使用,然后第二個域名申請就只是花了5天就弄好了。

一切準(zhǔn)備好后,申請一個免費的SSL,這個是很有必要的,申請過程大概一個小時左右就可以下發(fā)證書,然后下載證書就可以部署了。

Nginx部署SSL的教程官網(wǎng)也有,我是照官網(wǎng)的教程然后稍微修改修改就可以了。

阿里云域名官網(wǎng):https://wanwang.aliyun.com/domain/searchresult/?source=5176.11533457&userCode=kuoc2mgi&type=copy

若是不懂的可以在下發(fā)評論或者直接郵件我




MariaDB

安裝MariaDB

將MariaDB添加到系統(tǒng)源

sudo apt-get install software-properties-common dirmngrsudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.coreix.net/mariadb/repo/10.4/debian stretch main'使用apt安裝MariaDB

sudo apt-get updatesudo apt-get install mariadb-server

配置MariaDB

安裝頁面:https://downloads.mariadb.org/mariadb/repositories/#distro=Debian&distro_release=stretch--stretch&mirror=coreix&version=10.4

輸入如下命令配置root密碼:

mysql_secure_installation

配置WordPress數(shù)據(jù)庫

mysql -uroot -hlocalhost -ppassword創(chuàng)建一個數(shù)據(jù)庫用戶:

CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'password';創(chuàng)建一個數(shù)據(jù)庫

create database wordpress default charset utf8 collate utf8_general_ci;授予權(quán)限

grant all privileges on wordpress.* to 'wordpress'@'localhost' identified by 'password';刷新權(quán)限

flush privileges;

Nginx

安裝頁 http://nginx.org/en/linux_packages.html#Debian

安裝組件

sudo apt install curl gnupg2 ca-certificates lsb-release設(shè)置存儲庫

echo "deb http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" / | sudo tee /etc/apt/sources.list.d/nginx.list導(dǎo)入簽名密鑰

curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -驗證密鑰

sudo apt-key fingerprint ABF5BD827BD9BF62輸出:

pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14] 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62uid [ unknown] nginx signing key <signing-key@nginx.com>安裝Nginx

sudo apt updatesudo apt install nginx

PHP

apt-get -y install apt-transport-https lsb-release ca-certificates curlwget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpgecho "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.listapt-get updatesudo apt install php7.4安裝完后會顯示運(yùn)行 Apache 服務(wù)失敗,這是正常情況,因為我們先安裝并運(yùn)行了Nginx,Nginx占用了80端口,導(dǎo)致 Apache 服務(wù)運(yùn)行失敗。

安裝必要包

apt install php7.4-fpm php7.4-cgi php7.4-curl php7.4-gd php7.4-xml php7.4-xmlrpc php7.4-mysql php7.4-bz2檢測

php -v

配置Nginx和PHP

nginx文件分析

# nginx運(yùn)行的用戶名user nginx;# nginx啟動進(jìn)程,通常設(shè)置成和cpu的數(shù)量相等,這里為自動worker_processes auto;# errorlog文件位置error_log /var/log/nginx/error.log;# pid文件地址,記錄了nginx的pid,方便進(jìn)程管理pid /run/nginx.pid;# Load dynamic modules. See /usr/share/nginx/README.dynamic.# 用來加載其他動態(tài)模塊的配置include /usr/share/nginx/modules/*.conf;# 工作模式和連接數(shù)上限events { # 每個worker_processes的最大并發(fā)鏈接數(shù) # 并發(fā)總數(shù):worker_processes*worker_connections worker_connections 1024;}# 與提供http服務(wù)相關(guān)的一些配置參數(shù)類似的還有mailhttp { # 設(shè)置日志的格式 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記錄訪問的用戶、頁面、瀏覽器、ip和其他的訪問信息 access_log /var/log/nginx/access.log main; # 這部分下面會單獨解釋 # 設(shè)置nginx是否使用sendfile函數(shù)輸出文件 sendfile on; # 數(shù)據(jù)包最大時發(fā)包(使用Nagle算法) tcp_nopush on; # 立刻發(fā)送數(shù)據(jù)包(禁用Nagle算法) tcp_nodelay on; # 鏈接超時時間 keepalive_timeout 65; # 這個我也不清楚... types_hash_max_size 2048; # 引入文件擴(kuò)展名與文件類型映射表 include /etc/nginx/mime.types; # 默認(rèn)文件類型 default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; # http服務(wù)上支持若干虛擬主機(jī)。 # 每個虛擬主機(jī)一個對應(yīng)的server配置項 # 配置項里面包含該虛擬主機(jī)相關(guān)的配置。 server { # 端口 listen 80 default_server; listen [::]:80 default_server; # 訪問的域名 server_name _; # 默認(rèn)網(wǎng)站根目錄(www目錄) root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; # 默認(rèn)請求 location / { } # 錯誤頁(404) error_page 404 /404.html; location = /40x.html { } # 錯誤頁(50X) error_page 500 502 503 504 /50x.html; location = /50x.html { } }}/etc/php/7.4/cgi/php.ini設(shè)置:

cgi.fix_pathinfo=1/etc/php/7.4/fpm/php.ini 設(shè)置

cgi.fix_pathinfo=0/etc/nginx/nginx.conf配置如下:

user www-data; # 到/etc/php/7.4/fpm/pool.d/www.conf文件可以找到worker_processes 1;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;events { worker_connections 1024;}http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; gzip on; include /etc/nginx/conf.d/*.conf;}cat /etc/nginx/conf.d/default.conf

server { listen 80; server_name localhost; root /var/www/wordpress; #charset koi8-r; access_log /var/log/nginx/host.access.log main; location / { #root /usr/share/nginx/html; index index.html index.htm index.php; } 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 /usr/share/nginx/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$ { #root html; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ //.ht { deny all; }}別說我的博文是文字不夠代碼來湊,那還不是怕有的同學(xué)看不過來,直接貼代碼好復(fù)制啊。在這里插入代碼片

# WordPress

下載WordPress

wget https://wordpress.org/latest.tar.gz解壓安裝后修改:

cp wp-config-sample.php wp-config.php然后編輯wp-config.php文件

在相應(yīng)地方寫入數(shù)據(jù)庫,數(shù)據(jù)庫用戶名以及密碼。

/** The name of the database for WordPress */define( 'DB_NAME', 'wordpress' );/** MySQL database username */define( 'DB_USER', 'wordpress' );/** MySQL database password */define( 'DB_PASSWORD', 'wp^2020.' );/** MySQL hostname */define( 'DB_HOST', 'localhost' );/** Database Charset to use in creating database tables. */define( 'DB_CHARSET', 'utf8' );/** The Database Collate type. Don't change this if in doubt. */define( 'DB_COLLATE', '' );然后到瀏覽器輸入IP,設(shè)置好用戶名密碼郵箱,接下來就可以愉快地造作了。




有不懂的地方歡迎留言。

關(guān)鍵詞:云端,教程,完整,詳細(xì)

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點擊下載Chrome瀏覽器
關(guān)閉