LNMP环境搭建(用阿里云epel源安装)

本文详细介绍了如何在Linux环境中使用阿里云EPEL源安装Nginx、PHP、PHP-FPM,以及后续如何部署WordPress,包括设置数据库连接、下载安装包和权限配置等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、安装 Nginx:
1.下载阿里云镜像中的epel源
阿里云epel源链接 #redhat8版本可能会导致无法安装nginx

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install -y nginx
systemctl start nginx
cd /etc/nginx/
vim nginx.conf
server {
				listen       80 default_server;			
				listen       [::]:80 default_server;
				server_name  _;
				root         /usr/share/nginx/html;
				include /etc/nginx/default.d/*.conf;
				index	index.php index.html index.htm;	#这一句一定需要加上;为后面进行phpinfo测试
		}
location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;	#$document_root
        include        fastcgi_params;

        }

			  

**#上面一部分location配置与php解析相关,必须存在于nginx配置文件中;否则后面进行php网页测试时会出现无法进行php解析**

保存退出,重启 nginx 服务即可
AWS版nginx页面

二、安装php、php-mysql、php-fpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 
yum -y install php70w php70w-mysql php70w-fpm						

#安装php、php-msqll、php-fpm;如果使用的是AWS版的linux需要先将原有的php-common-5.4.16-46.amzn2.0.2.x86_64卸载掉再安装php70w-mysql

systemctl start php-fpm
#启动php-fpm程序
cd /var/share/nginx/html/
#切换到nginx根目录下
vim test.php
<?php
	phpinfo();
?>
								#编写测试页文件查看phpinfo信息

test.php测试页面

yum -y install mariadb-server
systemctl start mariadb
mysql_secure_installation 	#初始化数据库
mysql -u root -p					#进入数据库
create database wordpressdb;		#创建数据库名为wordpressdb
create uesr wcl@localhost identified by '8888';	#创建用户wcl;用户密码为8888
prant all privileges on wordpressdb.* to wcl@localhost;	#给wcl授权关于wordpressdb所有权限
flush privileges;	#更新数据
exit;	#退出

三、安装wordpress
1.下载wordpress安装包

wget http://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
2.将wordpress文件夹中的文件移动到/usf/share/nginx/html下
cd wordpress
mv wordpress/* /user/share/nginx/html
3.进入/use/share/nginx/html下;将wordpress中wp- conf-simple.php改成wp-conf.php
cd /user/share/nginx/html
mv wp-conf-simple.php wp-conf.php
vim wp-conf.php

wp-conf.php配置文件
#红色标记分别为:数据库名称、用户名称、用户密码

4.赋予/user/share/nginx/html下所有文件权限,并设置属主和属组为nginx:nginx;或者root:root

chmod -R 777 /user/share/nginx/html/
chown -R nginx:nginx /user/share/nginx/html/

四、在地址栏输入主机Ip:端口号/wp-admin

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值