時間: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ì)完整云端建站教程: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安裝MariaDBsudo apt-get updatesudo apt-get install mariadb-server
mysql_secure_installation
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;
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>
安裝Nginxsudo apt updatesudo apt install nginx
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運(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ù)制啊。在這里插入代碼片
wget https://wordpress.org/latest.tar.gz
解壓安裝后修改:cp wp-config-sample.php wp-config.php
然后編輯wp-config.php文件/** 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ì)
客戶&案例
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。