LNMP环境搭建
linux centos7.9 腾讯云
FTP配置
yum install vsftpd
useradd  -d /usr/share/nginx/html/wordpress   wordpress
vim /etc/vsftpd/vsftpd.conf
	chroot_local_user=YES #所有用户限制在自己home目录
	allow_writeable_chroot=YES
重启生效
systemctl restart vsftpd
SFTP服务配置
创建用户
useradd  -d /usr/share/nginx/html/wordpress  -s /bin/false wordpress
passwd wordpress
修改配置
vim /etc/ssh/sshd_config
#屏蔽下面这一行
#Subsystem sftp /usr/libexec/openssh/sftp-server
#添加如下
Subsystem sftp internal-sftp
Match User wordpress
        ChrootDirectory /usr/share/nginx/html/wordpress
        ForceCommand internal-sftp
        X11Forwarding no
目录权限
cd /usr/share/nginx/html
chown -R wordpress:wordpress wordpress
chown root:root wordpress
重启生效
systemctl restart sshd.service
Nginx 安装配置
安装
yum install nginx
如果是源代码安装注意要创建nginx用户和nginx用户组,以及nginx安装的位置可能是/usr/local/nginx
nginx:x:995:993:Nginx web server:/var/lib/nginx:/sbin/nologin
修改配置文件
/etc/nginx/nginx.conf
 找到 server{…},并将 server 大括号中相应的配置信息替换为如下内容。用于取消对 IPv6 地址的监听,同时配置 Nginx,实现与 PHP 的联动
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 / {
		  charset utf-8;
          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;
    }
修改页面
<a href="https://beian.miit.gov.cn/">湘ICP备xxxxxxxx号</a>
重启
systemctl restart nginx
测试
http://你的ip 访问测试
MariaDB安装配置
安装 启动 开机启动
yum install mariadb-server
systemctl start mariadb 
systemctl enable mariadb
查看启动结果
ps -aux | grep mysqld
首次安装需要进行数据库的配置
mysql_secure_installation
Enter current password for root (enter for none):  # 输入数据库超级管理员root的密码(注意不是系统root的密码),第一次进入还没有设置密码则直接回车
Set root password? [Y/n]  # 设置密码,y
New password:  # 新密码
Re-enter new password:  # 再次输入密码
Remove anonymous users? [Y/n]  # 移除匿名用户, y
Disallow root login remotely? [Y/n]  # 拒绝root远程登录,n,不管y/n,都会拒绝root远程登录
Remove test database and access to it? [Y/n]  # 删除test数据库,y:删除。n:不删除,数据库中会有一个test数据库,一般不需要
Reload privilege tables now? [Y/n]  # 重新加载权限表,y。或者重启服务
测试是否能够登录成功
mysql -u root -p
创建并载入备份数据库
[root@]# mysql -u root -p
MariaDB [none]> create database wordpress;
MariaDB [none]> use wordpress;
MariaDB [wordpress]> source /root/ww.sql;
备份数据库
[root@]# mysqldump -u root -p wordpress > /root/ww.sql;
创建数据库用户并授权
用户 user_wordpress
密码 12345678
MariaDB [(none)]> use mysql;
MariaDB [(mysql)]> create user 'user_wordpress'@'%' identified by '12345678';
MariaDB [(mysql)]> select host,user from user;
+-----------+----------------+
| host      | user           |
+-----------+----------------+
| %         | user_wordpress |
| 127.0.0.1 | root           |
| ::1       | root           |
| localhost | root           |
+-----------+----------------+
MariaDB [(mysql)]> grant select,insert,update,delete,create,index,alter on *.* to user_wordpress;
MariaDB [(mysql)]> flush privileges;
PHP7.4安装配置
这里选用remi的源来安装,首先添加源:
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
安装PHP
yum --enablerepo=remi install php74-php
安装你所需要php扩展模块
yum --enablerepo=remi install  php74-php-fpm php74-php-gd php74-php-xml php74-php-sockets php74-php-session php74-php-snmp php74-php-mysql
注:扩展安装格式php74-php-扩展模块名,缺什么扩展只要按照格式安装相应模块即可
开机启动
php74 -v
systemctl restart php74-php-fpm
systemctl enable php74-php-fpm
查看php7.4的安装路径
whereis php
创建链接php文件
ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php
修改配置
vi /etc/opt/remi/php74/php.ini
#修改对应
memory_limit = 512M
vi /etc/opt/remi/php74/php-fpm.d/www.conf
#找到
user = apache
group = apache
#改为
user = nginx
group = nginx
卸载 php7.4
yum remove php74-php*
wordpress
下载 wordpress-5.8.2-zh_CN.tar.gz 随便一个版本
放到 /usr/share/nginx/html下解压
cd /usr/share/nginx/html
tar -xf wordpress-5.8.2-zh_CN.tar.gz
cd wordpress
cp wp-config-sample.php wp-config.php
vim wp-config.php
#如下配置 上面配置的数据库在这里填上
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'user_wordpress' );
/** MySQL database password */
define( 'DB_PASSWORD', '12345678' );










