-
手动搭建LNMP环境
-
Linux ,Nginx,MariaDB,PHP 1)安装Nginx vi /etc/yum.repos.d/nginx.repo #创建nginx.repo文件 2)编辑写入如下内容 [nginx] name = nginx repo baseurl = https://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck = 0 enabled = 1 3)安装nginx yum install -y nginx 5)编辑nignx.conf文件 vim /etc/nginx/nginx.conf 6)在gzip on后加入如下内容 server { listen 80; root /usr/share/nginx/html; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; # 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 /usr/share/nginx/html; } #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 $document_root$fastcgi_script_name; include fastcgi_params; } } 7)执行命令 systemctl start nginx 8)执行以下命令,设置 Nginx 为开机自启动 systemctl enable nginx 1)安装数据库MariaDB。 2)查看系统中是否已安装 MariaDB rpm -qa | grep -i mariadb 3)卸载已安装的MariaDB yum -y remove 包名 4)在 /etc/yum.repos.d/ 下创建 MariaDB.repo 文件 vi /etc/yum.repos.d/MariaDB.repo 5)写入以下内容 # MariaDB 10.4 CentOS repository list - created 2019-11-05 11:56 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.4/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 6)安装 MariaDB yum -y install MariaDB-client MariaDB-server 7)启动 MariaDB 服务 systemctl start mariadb 8)设置 MariaDB 为开机自启动 systemctl enable mariadb 9)验证 MariaDB 是否安装成功 mysql 1)配置PHP 2)更新 yum 中 PHP 的软件源 rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 3)安装 PHP 7.2 所需要的包 yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64 4)启动 PHP-FPM 服务 systemctl start php-fpm 5)设置 PHP-FPM 服务为开机自启动 systemctl enable php-fpm 1)验证环境配置 echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php 2)重启 Nginx 服务 systemctl restart nginx 3)查看环境配置是否成功 http://云服务器实例的公网 IP
-
配置 WordPress 数据库
1)进入 MariaDB mysql 2)创建 MariaDB 数据库。例如 “wordpress” CREATE DATABASE wordpress; 3)创建一个新用户。例如 “user”,登录密码为 123456。 CREATE USER 'user'@'localhost' IDENTIFIED BY '*'; 4)赋予用户对 “wordpress” 数据库的全部权限 GRANT ALL PRIVILEGES ON wordpress.* TO 'user'@'localhost' IDENTIFIED BY '*'; 5)使所有配置生效 FLUSH PRIVILEGES;
-
配置 root 帐户
1)mysqpl 2)设置 root 帐户密码 ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD('输入您的密码');
-
安装和配置 WordPress
1)下载 WordPress
手动搭建LNMP环境
最新推荐文章于 2023-03-08 19:14:09 发布