yum 安装 lnmp

一. 系统

更新

yum -y update

二. 安装nginx

创建文件

    vim /etc/yum.repos.d/nginx.repo

文件内容,这配置是安装最新的稳定版1.8

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1

然后

  yum -y install nginx

检查是否安装成功

  systemctl start nginx

访问你的ip

三.安装Mysql5.7

下载mysql的repo源

wget http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm

安装mysql-community-release-el7-7.noarch.rpm包

 sudo rpm -Uvh mysql57-community-release-el7-7.noarch.rpm

安装msyql

sudo yum install mysql-server

重启mysql

service mysqld restart

查看临时密码

sudo grep 'temporary password' /var/log/mysqld.log

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPass4!';

四.安装php

安装Php和php 扩展


sudo yum install php php-mysql php-fpm php-mbstring php-gd php-pear php-mcrypt  php-mhash php-eaccelerator  php-cli php-


imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mssql php-snmp php-soap php-tidy php-common php-devel php-pecl-


xdebug -y


编辑php配置文件


sudo vi /etc/php.ini


cgi.fix_pathinfo=0


设置php-fpm配置文件


sudo vi /etc/php-fpm.d/www.conf


listen = /var/run/php-fpm/php-fpm.sock


启动php-fpm服务


sudo systemctl start php-fpm


设置开机自动重启php-fpm


sudo systemctl enable php-fpm.service

五.nginx配置 

编辑站点配置文件


sudo vi /etc/nginx/conf.d/default.conf


server {
    listen       80;
    server_name  drupaluser.org;


    root   /opt/data;
    index index.php index.html index.htm;


    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }


    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}


重启nginx


sudo systemctl restart nginx

 


五.测试php脚本web服务


编辑测试文件


sudo vi /opt/data/info.php
<?php phpinfo()?>


访问页面,能看到php各种配置信息的话说明配置成功。
http://drupaluser.org/info.php


删除测试文件


sudo rm /opt/data/info.php


到此CentOS 7下nginx,mysql,php安装配置全部完成,可以做为web平台的应用环境使用。

 

完成

转载于:https://www.cnblogs.com/da-guang/p/6935729.html

在CentOS 7上使用yum安装LNMP是一种方便且快捷的方法。首先,您需要准备工作并切换到里云yum源。具体步骤如: 1. 备份原有的yum源: `mv /etc/yum.repos.d/Cent-Base.repo /etc/yum.repos.d/COS-Base.repo.backup` 2. 下载新的CentOS-Base.repo到/etc/yum.repos.d/: `wget -O /etc/y.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo` 或者 `curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo` 3. 清理缓存: `yum clean all` 4. 生成缓存: `yum makecache` 接下来,您可以使用以下命令来安装LNMP包: `yum install epel-release` 安装EPEL以便安装源以外的软件,如Nginx、phpMyAdmin等。 最后,您可以使用以下命令启动服务: `service nginx start` 这是使用yum安装LNMP的步骤和命令。通过这种方法,您可以方便地安装LNMP并使用各种服务。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [centos7搭建LNMP环境-编译安装&yum安装-超详细](https://blog.csdn.net/handsomezls/article/details/116259445)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [centos7 使用YUM安装lnmp环境](https://blog.csdn.net/weixin_40288231/article/details/106334673)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值