zoukankan      html  css  js  c++  java
  • 云服务器部署LAMP

    一、安装Apache

    1、安装httpd服务:

    sudo yum install httpd

    2、开启服务:

    sudo systemctl start httpd

    3、访问服务器IP成功显示Testing 123..  ,即安装成功

    4、其他命令

    重启服务:sudo systemctl restart httpd
    停止服务:sudo systemctl stop httpd
    查看软件安装位置:rpm -ql httpd
    查看版本:sudo httpd -v
    
    配置文件目录:etc/httpd/conf/httpd.conf
    项目地址:var/www/html
    默认显示页面地址(Test): usr/share/httpd/noindex

    二、安装MySQL

     

    1、获取repo源

    wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

    2、安装rpm包

    rpm -ivh mysql-community-release-el7-5.noarch.rpm

    3、安装MySQL

    yum install mysql-community-server

    4、开机启动MySQL配置

    执行命令:vi /etc/rc.local,新增一行service mysqld start,保存退出即可(先按Esc键,在按英文: ,输入wq即可保存退出)

    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.
    
    touch /var/lock/subsys/local
    systemctl start mysqld
    ~                                                                                       
    ~                                                                                       
    ~                                                                                       
    ~                                                                                       
    ~                                                                                       
    ~                                                                                       
    ~                                                                                       
    ~                                                                                       
    ~                                                                                       
    ~                                                                                       
    "/etc/rc.local" 14L, 496C

    5、启动mysql

    启动:systemctl start mysqld
    重启:systemctl restart mysqld
    停止:systemctl stop mysqld
    需要先启动mysql,不然操作mysql时会报错:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' 

    6、设置密码及远程登录设置 

    登录MySQL:mysql -u root
    重置密码:set password for 'root'@'localhost' =password('1234');
    设置远程登录:grant all privileges on *.* to root@'%'identified by '1234';
    
    分配权限:create user 'username'@'%' identified by '1234'; 

    二、安装PHP

    1、安装 EPEL 源

    yum install epel-release

    2、安装 REMI 源

    yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

    3、安装 Yum 源管理工具

    yum install yum-utils

    4、安装 PHP7.3

    yum --enablerepo=remi-php73 install php

    5、安装 PHP模块

    yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll

    修改php.ini(目录:etc/php.ini)

    修改:extension_dir = "/opt/remi/php73/root/usr/lib64/php/modules/"
    在最后一行添加:extension=gd.so

    6、解析php

    更改项目根目录:DocumentRoot "/var/www/html/root/public" 和 <Directory "/var/www/html/dingcan/public">
    打开etc/httpd/conf/httpd.conf , 搜索:DirectoryIndex index.html ,改为:DirectoryIndex index.html index.htm index.php
    打开etc/httpd/conf/httpd.conf , 搜索:AddType application/x-gzip .gz .tgz,新增一行:AddType application/x-httpd-php .php 

    7、检查是否安装成功

    输入命令:php -v
    
    [root@iZ2ze3bv8i4oxk3wgzlmvwZ ~]# php -v
    PHP 7.3.23 (cli) (built: Sep 29 2020 08:33:03) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.23, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.3.23, Copyright (c) 1999-2018, by Zend Technologies

    8、更多操作

    设置开机启动:systemctl enable php73-php-fpm
    运行服务:systemctl start php73-php-fpm
    重启服务:systemctl restart php73-php-fpm
    启动服务:systemctl start php73-php-fpm
    关闭服务:systemctl stop php73-php-fpm
    检查状态:systemctl status php73-php-fpm
    查看版本:php73 -v
    卸载PHP:yum remove php

    PHP安装目录:/opt/remi/php73/root/usr/bin/php
    php配置文件目录:/etc/php.ini 和 /etc/opt/remi/php73/php.ini
    php扩展目录:/opt/remi/php73/root/usr/lib64/php/modules/
     
  • 相关阅读:
    kotlin异常类
    kotlin之null值安全性
    kotlin之操作符重载
    kotlin 之相等判断
    Java 的抽象特性:抽象类与接口深度解析
    人人都能够做深度学习应用:入门篇
    HBase源代码分析之HRegionServer上MemStore的flush处理流程(一)
    通讯录结构体方法的实现 和VS中存在的一些问题的分析
    2015爱奇艺暑期实习生面试
    cocos2d-x 源代码分析 : EventDispatcher、EventListener、Event 源代码分析 (新触摸机制,新的NotificationCenter机制)
  • 原文地址:https://www.cnblogs.com/finger-ghost/p/13804341.html
Copyright © 2011-2022 走看看