时间:2023-07-11 06:30:01 | 来源:网站运营
时间:2023-07-11 06:30:01 来源:网站运营
Debian+Nginx+MariaDB+PHP+WordPress详细完整云端建站教程: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
创建一个数据库用户:CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'password';
创建一个数据库create database wordpress default charset utf8 collate utf8_general_ci;
授予权限grant all privileges on wordpress.* to 'wordpress'@'localhost' identified by 'password';
刷新权限flush privileges;
sudo apt install curl gnupg2 ca-certificates lsb-release
设置存储库echo "deb http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" / | sudo tee /etc/apt/sources.list.d/nginx.list
导入签名密钥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
安装完后会显示运行 Apache 服务失败,这是正常情况,因为我们先安装并运行了Nginx,Nginx占用了80端口,导致 Apache 服务运行失败。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运行的用户名user nginx;# nginx启动进程,通常设置成和cpu的数量相等,这里为自动worker_processes auto;# errorlog文件位置error_log /var/log/nginx/error.log;# pid文件地址,记录了nginx的pid,方便进程管理pid /run/nginx.pid;# Load dynamic modules. See /usr/share/nginx/README.dynamic.# 用来加载其他动态模块的配置include /usr/share/nginx/modules/*.conf;# 工作模式和连接数上限events { # 每个worker_processes的最大并发链接数 # 并发总数:worker_processes*worker_connections worker_connections 1024;}# 与提供http服务相关的一些配置参数类似的还有mailhttp { # 设置日志的格式 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; # 这部分下面会单独解释 # 设置nginx是否使用sendfile函数输出文件 sendfile on; # 数据包最大时发包(使用Nagle算法) tcp_nopush on; # 立刻发送数据包(禁用Nagle算法) tcp_nodelay on; # 链接超时时间 keepalive_timeout 65; # 这个我也不清楚... types_hash_max_size 2048; # 引入文件扩展名与文件类型映射表 include /etc/nginx/mime.types; # 默认文件类型 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服务上支持若干虚拟主机。 # 每个虚拟主机一个对应的server配置项 # 配置项里面包含该虚拟主机相关的配置。 server { # 端口 listen 80 default_server; listen [::]:80 default_server; # 访问的域名 server_name _; # 默认网站根目录(www目录) root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; # 默认请求 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
设置:cgi.fix_pathinfo=1
/etc/php/7.4/fpm/php.ini
设置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; }}
别说我的博文是文字不够代码来凑,那还不是怕有的同学看不过来,直接贴代码好复制啊。在这里插入代码片
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,设置好用户名密码邮箱,接下来就可以愉快地造作了。 关键词:云端,教程,完整,详细