首页 > 系统相关 >阿里云安装CentOS+LAMP环境

阿里云安装CentOS+LAMP环境

时间:2022-10-13 10:37:34浏览次数:43  
标签:httpd CentOS etc LAMP 阿里 php70u conf mysql yum


一. 更新CONTOS相关仓库
1.安装ius仓库

yum install https://centos7.iuscommunity.org/ius-release.rpm

2.仓库相关其他命令

查看当前系统的资源仓库 
yum repolist

搜索某个第三方仓库
yum search epel

二. 安装apache

1.首先查看系统是否已经安装了Apache,敲rpm -qa httpd。

阿里云安装CentOS+LAMP环境_mysql

2.敲yum search httpd,搜索Apache。

阿里云安装CentOS+LAMP环境_mysql_02

3.敲yum install httpd -y,安装成功如下显示:

阿里云安装CentOS+LAMP环境_php_03

4.几条基本命令,rpm -qa httpd.

阿里云安装CentOS+LAMP环境_php_04

5.查看软件安装位置,rpm -ql httpd.

阿里云安装CentOS+LAMP环境_mysql_05

6.启动Apache,首先查看80端口是否被占用。netstat -tpln.

阿里云安装CentOS+LAMP环境_mysql_06

7.把80端口释放后,在启动Apache服务器,默认使用80端口。 ps -ef | grep nginx查找nginx进程。

8.然后敲,kill -quit 进程号,即可。或者killall httpd

9.端口释放后,启动Apache。敲systemctl start httpd。

阿里云安装CentOS+LAMP环境_php_07


10.查看httpd服务状态

阿里云安装CentOS+LAMP环境_apache_08

11.配置虚拟主机.
修改虚拟主机配置文件

apache的配置文件在/etc/httpd/conf目录下的httpd.conf文件中可以在这里文件里直接添加虚拟主机的配置设置
httpd.conf在/etc/httpd/conf下
默认自动引用 /etc/httpd/conf.d/下的所有.conf文件
所以我们把 vhost.conf建立在 /etc/httpd/conf.d/目录下
cd /etc/httpd/conf.d/

vim vhost.conf

添加:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ServerName apache.dev
ErrorLog logs/domain2.com-error_log
CustomLog logs/domain2.com-access_log common
</VirtualHost>

编辑完了别忘了

httpd -t   

测试没问题了再重启apache

三. yum安装mariadb

1.查看是否已经安装mariadb

阿里云安装CentOS+LAMP环境_php_09

yum list installed |grep mariadb

2.查看可安装的版本,这里安装mariadb101u版本

阿里云安装CentOS+LAMP环境_apache_10

3.因为依赖的mariadb-libs包版本比较低,所以会提示冲突,删除依赖的包

yum remove mariadb-libs

阿里云安装CentOS+LAMP环境_php_11

4.安装mariadb101u

yum install mariadb101u-server 

阿里云安装CentOS+LAMP环境_mysql_12

5.安装完成MariaDB,首先启动MariaDB

systemctl start mariadb

6.设置开机启动

systemctl enable mariadb

阿里云安装CentOS+LAMP环境_php_13

7.接下来进行MariaDB的相关简单配置

mysql_secure_installation
首先是设置密码,会提示先输入密码

Enter current password for root (enter for none):<–初次运行直接回车

设置密码

Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码

其他配置

Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车

Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,

Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车

Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车

初始化MariaDB完成,接下来测试登录

mysql -uroot -ppassword
完成。

8.配置MariaDB的字符集

文件/etc/my.cnf

vi /etc/my.cnf
在[mysqld]标签下添加

init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
文件/etc/my.cnf.d/client.cnf

vi /etc/my.cnf.d/client.cnf
在[client]中添加

default-character-set=utf8
文件/etc/my.cnf.d/mysql-clients.cnf

vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加

default-character-set=utf8
全部配置完成,重启mariadb

systemctl restart mariadb
之后进入MariaDB查看字符集

mysql> show variables like "%character%";show variables like "%collation%";
显示为

阿里云安装CentOS+LAMP环境_apache_14

9.添加用户,设置权限

创建用户命令

mysql>create user username@localhost identified by 'password';

阿里云安装CentOS+LAMP环境_centos_15

授予外网登陆权限 

mysql>grant all privileges on *.* to username@'%' identified by 'password';

阿里云安装CentOS+LAMP环境_mysql_16

授予权限并且可以授权

mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;
简单的用户和权限配置基本就这样了。

其中只授予部分权限把 其中 all privileges或者all改为select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file其中一部分。

四. yum安装PHP

1.安装PHP

yum install php70u -y

阿里云安装CentOS+LAMP环境_mysql_17

2.yum 安装php各种拓展,选自己需要的即可。

yum install  php70u-cli php70u-common php70u-devel php70u-embedded php70u-fpm php70u-gd php70u-mbstring php70u-mysqlnd  php70u-pdo php70u-xml

五. 常用命令

  1. 查看正在运行的服务
systemctl list-unit-files --type=service | grep enabled


标签:httpd,CentOS,etc,LAMP,阿里,php70u,conf,mysql,yum
From: https://blog.51cto.com/u_15052623/5752512

相关文章

  • CentOS 7.9 安装 Consul_1.9.14
    一、CentOS7.9安装Consul_1.9.14地址https://developer.hashicorp.com/consulhttps://github.com/hashicorp/consul wget下载wgethttps://releases.hashic......
  • CentOS创建用户并追加管理员权限
    sudouseradd-m${用户名}#添加用户sudouseradd-mwork#添加work账户sudopasswd${用户名}#更改密码sudo......
  • CentOS 7.9 安装 kafka_2.13
    一、CentOS7.9安装kafka_2.13地址https://kafka.apache.org/downloads.html 二、安装准备1安装JDK在安装kafka之前必须先安装JDK和zookeeper,如何安装JDK,可......
  • 基于Alist和RaiDrive挂载阿里、天翼、123云盘、百度网盘以及对象存储
    背景说明AList是一个支持多种存储,支持网页浏览和WebDAV的文件列表程序。支持视频、音频、文档、PDF、图片预览。易于安装,并且可以在所有平台上使用。AList支持多个......
  • 16、lamp的搭建
    搭建web02服务器作为web01的负载均衡服务器:httpd和nginx配置比较相似,也有虚拟主机,一个http服务需要配置多个站点,基于ip(基本用不到)、端口(内部网站)、域名(外部网站);......
  • 支撑阿里“双十一”的消息中间件,带你云淡风轻面对高并发
    ​近几年来,“中台”一词频繁出现在大众视野中,技术中台、业务中台、数据中台、甚至AI中台……层出不穷。这体现了整个行业对构建可复用体系的高度期待,希望依托中台战略来解决......
  • 阿里云ECS虚拟机磁盘扩容过程
    阿里云ECS虚拟机磁盘扩容过程背景公司同事将很早之前的一个虚拟机重新开机.就好将一套demo环境安装进这个ECS虚拟机里面这个机器系统盘只有40G的空间.导致磁盘空间......
  • 阿里云服务器数据盘扩容后,宝塔面板显示旧容量的问题
    发现系统盘不够用了,在阿里云后台扩容后,宝塔面板上看不到新的容量,重启后还是看不见。首先,要备份数据库和重要文件的备份,创建快照,以防在硬盘扩容时出现意外导致数据丢失。......
  • centos7 hbase集群搭建
    Node1 192.168.88.151Node2 192.168.88.152Node3 192.168.88.153三台都要配wget-chttp://archive.apache.org/dist/hbase/2.2.4/hbase-2.2.4-bin.tar.gztar-xzfhb......
  • centos8安装mariadb
    1.  yuminstall-ymariadb-servermariadbmariadb-devel  -------安装2. systemctlstartmariadb  ---启动服务3. mysql_secure_installation---配置服务4.......