为了方便,我是用CetnOS7.5中的yum安装
一、配置epel源并更新系统
Yum install -y epel-release
Yum clean all && yum makecache && yum update
二、安装LNMP
Yum源中的Nginx果然还是太旧了,在这里还是使用官方提供的安装方式
1、Nginx
Yum install -y yum-utils
在/etc/yum.repos.d/Nginx.repo中写入
[Nginx-stable]
name=Nginx stable repo
baseurl=http://Nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://Nginx.org/keys/Nginx_signing.key
[Nginx-mainline]
name=Nginx mainline repo
baseurl=http://Nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://Nginx.org/keys/Nginx_signing.key
在这里,我使用开发版,所以输入以下命令切换到Nginx-mainline
yum-config-manager --enable Nginx-mainline
~~如用于生产环境,请勿使用以上命令。~~由于稳定版更新频率并不高,而开发版稳定性也有保障且更新(修复BUG)很快,因此建议使用开发版。随后安装Nginx
Yum install -y Nginx
curl 127.0.0.1以查看Nginx是否成功安装,若成功安装则会返回类似以下文字
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Nginx!</title>
</head>
<body>
<h1>Welcome to Nginx!</h1>
If you see this page, the Nginx web server is successfully installed and
working. Further configuration is required.</p>
``
For online documentation and support please refer to
<a href="http://Nginx.org/">Nginx.org</a>.<br/>
Commercial support is available at
<a href="http://Nginx.com/">Nginx.com</a>.</p>
``
Thank you for using Nginx.
</body>
</html>
``
2、MysqL
Rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
之后安装MysqL,在这里我安装的版本是MysqL-80-community
yum -y install MysqL-community-server
如果想切换版本,可以修改/etc/yum.repos.d/MysqL-community.repo
将相应版本下对应的enable值改为1并将其他版本值改为0即可
修改完成以后查看是否启用相应版本
Yum repolist enable | grep MysqL
安装完成以后就可以启用并启动MysqL服务了
Systemctl start MysqLd && systemctl enable MysqLd
安装完成后,MysqL会在LOG文件(/var/log/MysqLd.log)中生成初始密码,查看初始密码并登陆
grep 'temporary password' /var/log/MysqLd.log
MysqL -u root -p
Alter user 'root'@'localhost' identified with MysqL_native_password by '新密码’;
由于MysqL默认的密码规则太烦人,我在此处稍作修改,降低了密码要求
set global validate_password_policy=0;
show variables like 'validate_password%';
*注意,MysqL5.7和80的Variable_name不同,和我版本不同的同学请自行查看并修改命令
随后开启MysqL远程访问权限
3、PHP
rpm -Uvh <https://mirror.webtatic.com/yum/el7/webtatic-release.rpm>
安装PHP7
yum install 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-MysqL.x86_64 PHP70w-pdo.x86_64
安装并启用PHP-fpm
yum install PHP70w-fpm PHP70w-opcache
systemctl start PHP-fpm && systemctl enable PHP-fpm
修改/etc/Nginx/conf.d/default.conf,将PHP部分注释去掉并修改
重启Nginx生效
下载相应源码包
wget http://am1.php.net/distributions/php-7.3.2.tar.gz
解压并进入目录后编译
./configure --prefix=/usr/local/PHP --with-fpm-user=Nginx --with-fpm-group=Nginx --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-MysqLi --with-openssl --with-pcre-regex --with-pdo-MysqL --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
Make && make install
//也可以用官方给的方式安装最新版PHP
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
yum install yum-utils
yum-config-manager --enable remi-PHP73
yum install PHP PHP-common PHP-opcache PHP-mcrypt PHP-cli PHP-gd PHP-curl PHP-MysqLnd
index index.PHP index.html index.htm;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
三、安装word press
从官网下载压缩包并解压到网站根目录并跟着教程走即可。但是有几个需要注意的地方:
1、 MysqL8.0的密码验证方式从MysqL_native_password改为了caching_sha2_password,所以要在MysqL配置文件my.cnf中设置:
default_authentication_plugin=MysqL_native_password
并修改密码:
use MysqL;
ALTER USER 'root'@'localhost' IDENTIFIED WITH MysqL_native_password BY '密码';
FLUSH PRIVILEGES;
2、 在Nginx和PHP中可能存在上传大小限制,请自行百度解决。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。