什么是LAMP
LAMP 是Linux Apache MySQL PHP的简写,其实就是把Apache, MySQL以及PHP安装在Linux系统上,组成一个环境来运行php的脚本语言。Apache是最常用的WEB服务软件,而MySQL是比较小型的数据库软件。
环境:CentOS7
查看Swap分区的大小以及使用情况,一般使用free命令即可,如下所示,Swap大小为512M,目前没有使用Swap分区
bash
1➜ ~ free -m
2 total used free shared buff/cache available
3Mem: 512 206 138 26 166 305
4Swap: 512 0 512
COPY
1.创建要作为swap分区的文件:增加1GB大小的交换分区,则命令写法如下,其中的count等于想要的块的数量(bs*count=文件大小)。
1dd if=/dev/zero of=/var/swapfile bs=1M count=1024
COPY
2.格式化为交换分区文件:
1mkswap /var/swapfile # 建立swap的文件系统
COPY
3.启用交换分区文件:
1swapon /var/swapfile # 启用swap文件
COPY
4.使系统开机时自启用,在文件/etc/fstab中添加一行: /var/swapfile swap swap defaults 0 0
bash
1dd if=/dev/zero of=/var/swapfile bs=1M count=1024
2mkswap /var/swapfile
3swapon /var/swapfile
4echo "/root/swapfile swap swap defaults 0 0" >> /etc/fstab
COPY
bash
1➜ ~ sudo yum install httpd
2Loaded plugins: fastestmirror
3Loading mirror speeds from cached hostfile
4 * base: mirror.fileplanet.com
5 * epel: d2lzkl7pfhq30w.cloudfront.net
6 * extras: mirror.jaleco.com
7 * updates: centos-distro.cavecreek.net
8Resolving Dependencies
9--> Running transaction check
10---> Package httpd.x86_64 0:2.4.6-88.el7.centos will be installed
11--> Finished Dependency Resolution
12
13Dependencies Resolved
14
15================================================================================
16 Package Arch Version Repository Size
17================================================================================
18Installing:
19 httpd x86_64 2.4.6-88.el7.centos base 2.7 M
20
21Transaction Summary
22================================================================================
23Install 1 Package
24
25Total download size: 2.7 M
26Installed size: 9.4 M
27Is this ok [y/d/N]: y
28Downloading packages:
29httpd-2.4.6-88.el7.centos.x86_64.rpm | 2.7 MB 00:00
30Running transaction check
31Running transaction test
32Transaction test succeeded
33Running transaction
34 Installing : httpd-2.4.6-88.el7.centos.x86_64 1/1
35 Verifying : httpd-2.4.6-88.el7.centos.x86_64 1/1
36
37Installed:
38 httpd.x86_64 0:2.4.6-88.el7.centos
39
40Complete!
COPY
bash
1➜ ~ yum install mysql
2Loaded plugins: fastestmirror
3Loading mirror speeds from cached hostfile
4 * base: mirror.fileplanet.com
5 * epel: d2lzkl7pfhq30w.cloudfront.net
6 * extras: repos-lax.psychz.net
7 * updates: centos-distro.cavecreek.net
8Resolving Dependencies
9--> Running transaction check
10---> Package mariadb.x86_64 1:5.5.60-1.el7_5 will be installed
11--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.60-1.el7_5 for package: 1:mariadb-5.5.60-1.el7_5.x86_64
12--> Running transaction check
13---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be installed
14--> Finished Dependency Resolution
15
16Dependencies Resolved
17
18================================================================================
19 Package Arch Version Repository Size
20================================================================================
21Installing:
22 mariadb x86_64 1:5.5.60-1.el7_5 base 8.9 M
23Installing for dependencies:
24 mariadb-libs x86_64 1:5.5.60-1.el7_5 base 758 k
25
26Transaction Summary
27================================================================================
28Install 1 Package (+1 Dependent package)
29
30Total download size: 9.6 M
31Installed size: 53 M
32Is this ok [y/d/N]: y
33Downloading packages:
34(1/2): mariadb-libs-5.5.60-1.el7_5.x86_64.rpm | 758 kB 00:00
35(2/2): mariadb-5.5.60-1.el7_5.x86_64.rpm | 8.9 MB 00:00
36--------------------------------------------------------------------------------
37Total 14 MB/s | 9.6 MB 00:00
38Running transaction check
39Running transaction test
40Transaction test succeeded
41Running transaction
42 Installing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 1/2
43 Installing : 1:mariadb-5.5.60-1.el7_5.x86_64 2/2
44 Verifying : 1:mariadb-5.5.60-1.el7_5.x86_64 1/2
45 Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 2/2
46
47Installed:
48 mariadb.x86_64 1:5.5.60-1.el7_5
49
50Dependency Installed:
51 mariadb-libs.x86_64 1:5.5.60-1.el7_5
52
53Complete!
COPY
bash
1yum install gcc autoconf gcc-c++ \
2libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel \
3systemd-devel \
4openjpeg-devel -y # 安装编译库和依赖包
5cd /tmp
6wget http://cn2.php.net/distributions/php-7.2.4.tar.gz
7tar zxvf php-7.2.4.tar.gz
8#添加php-fpm用户
9#创建群组
10groupadd php-fpm
11#创建一个用户,不允许登陆和不创主目录
12useradd -s /sbin/nologin -g php-fpm -M php-fpm
13
14cd ./php-7.2.4
15./configure \
16--prefix=/usr/local/php \
17--with-config-file-path=/usr/local/php/etc \
18--with-zlib-dir \
19--with-freetype-dir \
20--enable-mbstring \
21--with-libxml-dir=/usr \
22--enable-xmlreader \
23--enable-xmlwriter \
24--enable-soap \
25--enable-calendar \
26--with-curl \
27--with-zlib \
28--with-gd \
29--with-pdo-sqlite \
30--with-pdo-mysql \
31--with-mysqli \
32--with-mysql-sock \
33--enable-mysqlnd \
34--disable-rpath \
35--enable-inline-optimization \
36--with-bz2 \
37--with-zlib \
38--enable-sockets \
39--enable-sysvsem \
40--enable-sysvshm \
41--enable-pcntl \
42--enable-mbregex \
43--enable-exif \
44--enable-bcmath \
45--with-mhash \
46--enable-zip \
47--with-pcre-regex \
48--with-jpeg-dir=/usr \
49--with-png-dir=/usr \
50--with-openssl \
51--enable-ftp \
52--with-kerberos \
53--with-gettext \
54--with-xmlrpc \
55--with-xsl \
56--enable-fpm \
57--with-fpm-user=php-fpm \
58--with-fpm-group=php-fpm \
59--with-fpm-systemd \
60--disable-fileinfo
61 make && make install
COPY
bash
1yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
2yum install yum-utils
3yum-config-manager --enable remi-php73
4yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
COPY
bash
1➜ php-7.2.4 yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
2Loaded plugins: fastestmirror
3remi-release-7.rpm | 15 kB 00:00
4Examining /var/tmp/yum-root-F1IWpp/remi-release-7.rpm: remi-release-7.6-1.el7.remi.noarch
5Marking /var/tmp/yum-root-F1IWpp/remi-release-7.rpm to be installed
6Resolving Dependencies
7--> Running transaction check
8---> Package remi-release.noarch 0:7.6-1.el7.remi will be installed
9--> Finished Dependency Resolution
10
11Dependencies Resolved
12
13================================================================================
14 Package Arch Version Repository Size
15================================================================================
16Installing:
17 remi-release noarch 7.6-1.el7.remi /remi-release-7 18 k
18
19Transaction Summary
20================================================================================
21Install 1 Package
22
23Total size: 18 k
24Installed size: 18 k
25Is this ok [y/d/N]: y
26Downloading packages:
27Running transaction check