文章目录
一、Yum安装PHP5.6
1.1、安装Yum源
-
CentOS 6.x
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
-
CentOS 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
1.2、安装PHP及必要扩展
yum install -y php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64
1.3、安装PHP FPM
yum install -y php56w-fpm
1.4、启动PHP FPM
cd /etc/systemd/system/
ln -s /lib/systemd/system/php-fpm.service php-fpm.service
systemctl start php-fpm.service # 启动
systemctl enable php-fpm.service # 加入开机自启动
二、Yum安装MariaDB
2.1、配置Yum源文件
vim /etc/yum.repos.d/MariaDB.repo
-
CentOS6.X
[mariadb] name = MariaDB baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos6-amd64 gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
-
CentOS7.X
[mariadb] name = MariaDB baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.1/centos7-amd64/ gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
2.2、导入GPG key
rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
2.3、安装MariaDB
yum -y install MariaDB-server MariaDB-client
2.4、启动并设置开机自启动
-
CentOS6.X
/etc/init.d/mysql start chkconfig mysql on
-
CentOS7.X
systemctl start mariadb #启动服务 systemctl enable mariadb #设置开机启动
2.5、登录配置
-
执行命令进行配置
mysql_secure_installation
-
开始配置
-
首先是设置密码,会提示先输入密码
Enter current password for root (enter for none): <–初次运行直接回车
-
设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码 -
其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车(后面授权配置)
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
-
三、Yum安装NGINX
3.1、CentOS6.X
直接安装yum安装即可
sudo yum install -y nginx
3.2、Centos7.X
默认情况Centos7中无Nginx的源,Nginx官网提供了Centos的源地址
-
添加源
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
-
安装Nginx
sudo yum install -y nginx
-
启动Nginx并设置开机自动运行
sudo systemctl start nginx.service sudo systemctl enable nginx.service
四、安装WordProse
4.1、下载安装包
4.2、解压安装
将WordPress安装包解压后放到/opt目录下
4.3、配置NGINX
cat /etc/nginx/conf.d/mc_wordpress.conf
server {
listen 80;
server_name mc.9zmai.com;
root /opt/wordpress;
index index.php index.html index.htm;
client_max_body_size 10m;
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;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 1h;
}
}
4.4、配置PHP
[www]
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache
4.5、配置项目
将wp-config-sample.php文件,重命名为wp-config.php。配置数据库相关信息。在此之前,请为该项目创建数据库,并为其创建用户并授权。
4.6、进入页面配置
下面就可以在页面上进行配置,和相关操作
五、WordPress常用插件
插件 | 软件名称 |
---|---|
邮件系统 | WP Mail Bank |
页面编辑 | Elementor |
权限管理 | Ultimate Member |
网络推广 | Yoast SEO |