Centos 7 安装Wordpress详细过程
Centos 7 安装Wordpress
安装Centos 7
-
在VMWARE安装Centos 7(步骤略)
-
备份原有的yum源文件,更新yum源为阿里云
[root@localhost yum.repos.d]# ls | xargs -t -i mv {} {}.bak
[root@localhost yum.repos.d]# ls -alh
total 48K
drwxr-xr-x. 2 root root 252 Apr 2 08:12 .
drwxr-xr-x. 139 root root 8.0K Apr 2 08:09 ..
-rw-r--r--. 1 root root 1.7K Apr 7 2020 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1.3K Apr 7 2020 CentOS-CR.repo.bak
-rw-r--r--. 1 root root 649 Apr 7 2020 CentOS-Debuginfo.repo.bak
-rw-r--r--. 1 root root 314 Apr 7 2020 CentOS-fasttrack.repo.bak
-rw-r--r--. 1 root root 630 Apr 7 2020 CentOS-Media.repo.bak
-rw-r--r--. 1 root root 1.3K Apr 7 2020 CentOS-Sources.repo.bak
-rw-r--r--. 1 root root 7.4K Apr 7 2020 CentOS-Vault.repo.bak
-rw-r--r--. 1 root root 616 Apr 7 2020 CentOS-x86_64-kernel.repo.bak
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost yum.repos.d]# yum clean cache
[root@localhost yum.repos.d]# yum makecache
-
更新一下系统,然后最好做一下快照
[root@localhost yum.repos.d]# yum update
安装LNMP环境
-
关闭防火墙
a. 确认防火墙当前状态
[root@localhost ~]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2023-04-02 08:22:54 EDT; 1min 43s ago Docs: man:firewalld(1) Main PID: 837 (firewalld) Tasks: 2 CGroup: /system.slice/firewalld.service └─837 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid Apr 02 08:22:53 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon... Apr 02 08:22:54 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon. Apr 02 08:22:54 localhost.localdomain firewalld[837]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Ple...bling it now. Hint: Some lines were ellipsized, use -l to show in full.
b. 关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
-
关闭Selinux,修改为SELINUX=disabled
[root@localhost ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
-
安装nginx,由于nginx位于第三方的yum源里面,而不在centos官方yum源里面
[root@localhost ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost opt]# rpm -ivh epel-release-latest-7.noarch.rpm
warning: epel-release-latest-7.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:epel-release-7-14 ################################# [100%]
[root@localhost opt]# yum install -y nginx
验证一下nginx是否安装成功:
[root@localhost opt]# nginx -v
nginx version: nginx/1.20.1
说明安装成功!
-
安装mysql
[root@localhost opt]# sudo rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
[root@localhost opt]# sudo yum -y install mysql-community-server --nogpgcheck
运行以下命令验证是否安装成功:
[root@localhost opt]# mysql -V
mysql Ver 14.14 Distrib 5.7.41, for Linux (x86_64) using EditLine wrapper
运行以下命令启动和开机启动Myssql:
[root@localhost opt]# systemctl start mysqld
[root@localhost opt]# systemctl enable mysqld
-
安装PHP
a. 更新yum源
sudo yum install \ https://repo.ius.io/ius-release-el7.rpm \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
b. 运行以下命令添加Webtatic源
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
c. 安装PHP
sudo yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb
d.验证PHP是否安装成功
[root@localhost opt]# php -v
PHP 7.0.33 (cli) (built: Dec 6 2018 22:30:44) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies
-
配置NGINX
-
添加或修改
location /
配置信息。location / { index index.php index.html index.htm; }
-
添加或修改
location ~ .php$
配置信息。#添加下列信息,配置Nginx通过fastcgi方式处理您的PHP请求。 location ~ .php$ { root /usr/share/nginx/html; #将/usr/share/nginx/html替换为您的网站根目录,本文使用/usr/share/nginx/html作为网站根目录。 fastcgi_pass 127.0.0.1:9000; #Nginx通过本机的9000端口将PHP请求转发给PHP-FPM进行处理。 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; #Nginx调用fastcgi接口处理PHP请求。 }
-
启动Nginx
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
-
配置mysql
a. 运行以下命令,查看/var/log/mysqld.log文件,获取并记录root用户的初始密码。
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log 2023-04-02T12:43:47.099622Z 1 [Note] A temporary password is generated for root@localhost: ecz+LMihI1g=
[root@localhost ~]# mysql_secure_installation
-
配置PHP
在网站根目录创建phpinfo.php文件
[root@localhost ~]# echo '<?php echo phpinfo(); ?>' > /usr/share/nginx/html/phpinfo.php
运行以下命令,启动PHP-FPM。
[root@localhost ~]# systemctl start php-fpm
设置开机启动php-fpm
[root@localhost ~]# systemctl enable php-fpm
访问phpinfo.php页面
至此已经成功的将php,mysql以及nginx安装配置完成。
安装Wordpress
- 创建数据库huawen_db
mysql> create database huawen_db;
Query OK, 1 row affected (0.00 sec)
- 创建数据库用户和密码
mysql> CREATE USER AAAAAAAAAAAAAA@localhost IDENTIFIED BY 'xxxxxxx';
Query OK, 0 rows affected (0.00 sec)
设置wordpressuser访问wordpress数据库权限
mysql> GRANT ALL PRIVILEGES ON huawen_db.* TO AAAAAAAAAAAAAr@localhost IDENTIFIED BY 'xxxxxxx';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
- 下载最新版本的wordpress包
[root@localhost opt]# wget http://wordpress.org/latest.tar.gz
[root@localhost opt]# tar -zxvf latest.tar.gz
并拷贝到nginxu网站根目录
[root@localhost opt]# rsync -avP ./wordpress/ /usr/share/nginx/html/
-
编辑wp-config.php文件,配置数据库名、用户名和密码
-
此时访问ip,即可完成wordpress的安装
STRIVE FOR PROGRESS,NOT FOR PERFECTION
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2022-04-02 快速搭建HTTP服务器的几种方法(单条命令)