Centos7 yum 搭建Lamp服务器

造福下后来学web的师弟吧,顺便为自己的博客更新第一篇POST

0x01 更新yum源

由于自己博客用的腾讯云,直接有配置好的腾讯云yum源因此此处不做修改但还是写下yum源(163国内yum源)的更新:
  • 备份原始yum源
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bk

  • 下载新的yum源
    wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

  • 更新yum源
    mv Centos7-Base-163.repo /etc/yum.repos.d/CentOS-Base.repo yum clean all
    yum makecache


0x02 安装Apache

yum install -y httpd

  • httpd.conf的简单配置
    vim /etc/httpd/conf/httpd.conf
    修改或添加 ServerSignature On 为 ServerSignature Off 防止列出apache版本信息
    修改或添加 ServerTokens OS 为 ServerTokens Prod 防止列出apache版本信息
    将apache的web根目录下的 Options Indexes FollowSymLinks修改为 Options FollowSymLinks Includes ExecCGI
    修改 AllowOverride None 为 AllowOverride All,这样你.htaccess才能生效。
    修改 AddHandler cgi-script .cgi 为 AddHandler cgi-script .cgi .pl
    修改或添加 Options Indexes MultiViews FollowSymLinks 为 Options MultiViews FollowSymLinks
    修改 DirectoryIndex 为 Directory index.html index.php
    KeepAlive off 修改为 KeepAlive On
    增加 MaxKeepAliveRequests 1000
  • 开启apache且开机启动
    systemctl start httpd.service
    systemctl enable httpd.service

0x03 安装php及相关模块

yum install -y php php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-gd libjpeg* php-mysql php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
相关模块需要就装~

  • 测试php是否安装完毕.
    vim /var/www/html/phpinfo.php
    写入 <?php phpinfo();?>
    访问出现phpinfo页面且模块全部加载,说明安装完毕。

  • 配置php.ini
    vim /etc/php.ini
    具体的查官方php.ini的配置说明

0x04 安装mysql(mariadb)

yum install -y mariadb mariadb-server
systemctl start mariadb.service
systemctl enable mariadb.service

  • 修改mysql密码 mysql_sercure_installation 设置密码后一路 enter 到底就可以了

此处评论已关闭