第一部分:装好并配置LAMP

一、配置CentOS7

1、开SSH

systemctl enable sshd

2、安装rz

yum -y install lrzsz

之后上传文件一定要用-be参数(其中-b是--binary用二进制的方式上传,-e是--escape强制escape所有控制字符),否则上传的文件不完整

rz –be

3、安装wget

yum -y install wget

4、关闭SELINUX

vi /etc/sysconfig/selinux

修改下边红字部分

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of three two values:

# targeted - Targeted processes are protected,

# minimum - Modification of targeted policy. Only selected processes are protected.

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

5、关闭防火墙

systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

 

 

二、Apache

1、安装Apache

yum -y install httpd httpd-devel

安装路径:/etc/httpd

配置文件:/etc/httpd/conf/httpd.conf

模块路径:/usr/lib64/httpd/modules/

web目录:/var/www/html

2、配置httpd,将服务器名称替换为您自己的环境

vi /etc/httpd/conf/httpd.conf

#改用户和组

User www

Group www

#添加只能使用目录名称访问的文件名

DirectoryIndex index.html index.php

# server's response header(安全性)

ServerTokens Prod

# keepalive is ON

KeepAlive On

3、创建对应权限账户

groupadd www

useradd www -g www -s /sbin/nologin -M

4、启动和激活服务

systemctl start httpd

systemctl enable httpd

 

 

三、PHP

1、安装

不要用yum install php-fpm安装,否则安装上的是源里的旧版本PHP,最好用编译安装

(1)首先安装必须的组件

yum -y install gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel

其中libxml2的版本必须大于2.7.0

注意libmcrypt和libmcrypt-devel已不被任何源支持,所以要单独安装

下载libmcrypt-2.5.7.tar.gz

mkdir /home/software

cd /home/software