linux7.6 yum安装配置nmp环境 并添加站点

安装nginx

# 安装
yum install -y nginx

# 设置开机自启
systemctl enable nginx

# 启动nginx
systemctl start nginx

# 查看状态
systemctl status nginx

# 查看安装目录
rpm -ql nginx

# 查看进程
ps aux|grep nginx

nginx的主要配置文件:nginx.conf

当前演示nginx配置文件目录:/etc/nginx/

安装mysql

# 安装mysql
yum install -y mysql

# 安装mysql-server
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install -y mysql-community-server mysql-devel

# 开机自启
systemctl enable mysqld

# 启动mysql
systemctl restart mysqld

# 进入mysql
mysql

# 修改mysql密码
UPDATE mysql.user set password=PASSWORD('123456') WHERE user='root' AND Host='localhost';

# 刷新权限
flush privileges;

# 查看状态
systemctl status mysqld

# 查看进程
ps aux|grep mysqld

安装PHP

因为yum中没有PHP的高版本,所以不能直接使用yum

https://rpms.remirepo.net/中进入Configuration wizard
在这里插入图片描述
选择对应的环境和版本安装类型,选完后按照提示的命令执行前面三条命令
在这里插入图片描述

# 安装
yum -y install php73 php73-php-cli php73-php-common php73-php-devel php73-php-embedded php73-php-fpm php73-php-gd php73-php-mbstring php73-php-pecl-redis php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-xml php73-php-json

# 搜索指定扩展
yum search php73 | grep swoole

# 安装扩展
yum -y install php73-php-pecl-swoole4

# 开机自启
systemctl enable php73-php-fpm

# 启动
systemctl start php73-php-fpm

# 查看安装目录
rpm -ql php73-php-fpm

PHP主要的配置文件:php.ini

当前演示php.ini/etc/opt/remi/php73/目录中

添加站点

# 查看nginx配置文件nginx.conf 
more /etc/nginx/nginx.conf

# 新建站点配置文件
vi /etc/nginx/conf.d/站点名(域名)

# 站点配置文件内容
server {
        listen 80;
        server_name xx.xx.com; # 域名
        root /usr/share/nginx/project/xx.xx.com; # 站点地址
        index index.html;

        location \ {
        }

        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;
        }
}

# 配置完就可以重启nginx
systemctl reload nginx

# 在站点目录新建文件
cd /usr/share/nginx/project/xx.xx.com

# 测试html
vi index.html
# 内容
<h1>测试index.html</h1>

# 测试PHP
vi info.php
# 内容
<?php
phpinfo();

查看nginx.conf文件中站点配置文件所在目录
在这里插入图片描述
测试PHP效果图
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值