LAMP环境版本

  • 操作系统:Centos 7
  • Mysql:5.7.11
  • Apache:2.4.18
  • PHP:7.0.4

安装Mysql

下载链接:http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.11.tar.gz

为mysql创建专属帐号

[plain] view plaincopy
  1. shell> groupadd mysql
  2. shell> useradd -r -g mysql -s /bin/false mysql

源码编译安装

[plain] view plaincopy
  1. shell> tar zxvf mysql-5.7.11.tar.gz
  2. shell> cd mysql-5.7.11
  3. shell> cmake .
  4. shell> make
  5. shell> make install

安装后设置

注意:从Mysql5.7开始,mysql默认安装后不再是空密码,而是生成一个随机密码,除非初始化时指定--initialize-insecure。
所有用户拥有对于MySQL默认安装test数据库的访问权限(即使没有授予权限)为了安全考虑5.7版本中不在有test数据库。
更为重要的是,MySQL 5.7版本提供了更为简单SSL安全访问配置,并且默认连接就采用SSL的加密方式
[plain] view plaincopy
  1. shell> cd /usr/local/mysql
  2. shell> chown -R mysql .  #修改目录所有者为mysql
  3. shell> chgrp -R mysql .  #修改目录所属组为mysql
  4. shell> bin/mysqld --initialize-insecure --user=mysql --datadir=/data/mysql  #初始化mysql,初始化为空,数据库存放目录指定为/data/mysql
  5. shell> bin/mysql_ssl_rsa_setup #启动ssl加密方式连接
  6. shell> chown -R root .   #修改目录所有者为root
  7. shell> chown -R mysql /data/mysql  #修改数据库目录所有者为mysql

安装mysql服务

只需要将mysql安装目录下的mysql.server复制过去就OK了。
[plain] view plaincopy
  1. shell> cp support-files/mysql.server /etc/init.d/mysql.server
  2. shell> service mysql start   #启动服务

安装Apache

下载链接:http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.18.tar.gz

源码编译安装

[plain] view plaincopy
  1. shell> ./configure --prefix=/usr/local/apahche \
  2. --enable-so #动态共享对象,可实现模块动态生效 \
  3. --enable-rewrite #启用Rewrite功能 \
  4. --enable-ssl #支持SSL/TLS,可以实现https访问 \
  5. --enable-deflate #支持压缩 \
  6. shell> make
  7. shell> make install

apache的启动与关闭

[plain] view plaincopy
  1. shell> /usr/local/apache/bin/apachectl start    #启动
  2. shell> /usr/local/apache/bin/apachectl stop     #停止
  3. shell> /usr/local/apache/bin/apachectl restart  #重启

将apache添加到Linux的服务并设置自启动

[plain] view plaincopy
  1. shell> cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd   #设置为系统服务
  2. shell> ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S80httpd   #在启动级别3中自启动
  3. shell> service httpd restart   #通过服务来重启apache

运行测试页面

在客户端浏览器上输入服务器的IP地址,看是否能正常打开网页。

常见问题

  • configure: error: APR not found.

    解决方法: 安装对应依赖库
    [plain] view plaincopy
    1. shell> yum install apr apr-util-devel
  • configure: error: pcre-config for libpcre not found.
    解决方法:安装对应依赖库

    [plain] view plaincopy
    1. yum install pcre pcre-devel

  • 启动apache时报:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.44.13.173. Set the 'ServerName' directive globally to suppress this message
    解决方法:修改配置文件httpd.conf设置ServerName localhost:80

安装PHP

下载链接:http://php.net/downloads.php

安装依赖库

  • zlib
    官网:http://www.zlib.net/
    [plain] view plaincopy
    1. shell> tar xf zlib.1.2.8.tar.gz
    2. shell> cd zlib.1.2.8
    3. shell> ./configure
    4. shell> make test
    5. shell> make install
  • GD库
    libpng
    官网:http://www.libpng.org/
    [plain] view plaincopy
    1. shell> tar xf libpng-1.6.21
    2. shell> cd libpng-1.6.21
    3. shell> ./configure --prefix=/usr/local/libpng
    4. shell> make
    5. shell> make check
    6. shell> make install

    jpeg

    官网:http://www.ijg.org/
    [php] view plaincopy
    1. shell> tar xf jpegsrc.v9.tar.gz
    2. shell> cd jpeg-9
    3. shell> ./configure --prefix=/usr/local/libjpeg
    4. shell> make
    5. shell> make install
  • libcurl-devel
    [plain] view plaincopy
    1. yum install libcurl-devel
  • openssl-devel
    [plain] view plaincopy
    1. yum install openssl-devel
  • libxslt-devel
    [plain] view plaincopy
    1. yum install libxslt-devel
  • libxml2-devel
    [plain] view plaincopy
    1. yum install libxml2-devel
  • freetype 字体操作库
    官网:http://www.freetype.org/
    [plain] view plaincopy
    1. shell> tar xf freetype-2.6.3.tar.bz2
    2. shell> sh autogen.sh
    3. shell> ./configure --prefix=/usr/local/freetype
    4. shell> make
    5. shell> make install

编译安装PHP

[plain] view plaincopy
  1. ./configure --prefix=/usr/local/php \
  2. --with-apxs2=/usr/local/apache/bin/apxs \
  3. --with-curl \
  4. --with-freetype-dir=/usr/local/freetype \
  5. --with-gd \
  6. --with-gettext \
  7. --with-iconv-dir \
  8. --with-mysqli \
  9. --with-openssl \
  10. --with-pcre-regex \
  11. --with-pdo-mysql \
  12. --with-pdo-sqlite \
  13. --with-pear \
  14. --with-png-dir=/usr/local/libpng \
  15. --with-jpeg-dir=/usr/local/libjpeg \
  16. --with-xsl \
  17. --with-zlib \
  18. --enable-fpm \
  19. --enable-bcmath \
  20. --enable-libxml \
  21. --enable-inline-optimization \
  22. --enable-gd-native-ttf \
  23. --enable-mbregex \
  24. --enable-mbstring \
  25. --enable-opcache \
  26. --enable-pcntl \
  27. --enable-shmop \
  28. --enable-soap \
  29. --enable-sockets \
  30. --enable-sysvsem \
  31. --enable-xml \
  32. --enable-zip
  33. (./configure  '--prefix=/usr/local/php' '--with-freetype-dir=/usr/local/freetype' '--with-gd' '--with-gettext' '--with-iconv-dir' '--with-mysqli' '--with-openssl' '--with-pcre-regex' '--with-pdo-mysql' '--with-pdo-sqlite' '--with-pear' '--with-png-dir=/usr/local/libpng' '--with-jpeg-dir=/usr/local/libjpeg' '--with-xsl' '--with-zlib' '--enable-fpm' '--enable-bcmath' '--enable-libxml' '--enable-inline-optimization' '--enable-gd-native-ttf' '--enable-mbregex' '--enable-mbstring' '--enable-opcache' '--enable-pcntl' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvsem' '--enable-xml' '--enable-zip' '--with-curl=/usr/local/curl')指定curl为openssl
  34. shell> make
  35. shell> make install
Apache与PHP的关联

PHP安装成功后会在apache的modules目录下生成一个libphp.so动态库文件,在apache的配置文件httpd.conf里自动增加一行

[plain] view plaincopy
  1. LoadModule php7_module        modules/libphp7.so

在Apache的配置文件httpd.conf的<IfModule mime_module></IfModule>块里增加一行

[plain] view plaincopy
  1. AddType application/x-httpd-php .php

在网站要目录/usr/local/htdocs里增加一个index.php测试文件内容如下:

[php] view plaincopy
  1. <?php
  2. phpinfo();

然后我们运行此文件,如果输出了phpinfo信息,证明我们安装成功。

linux下PHP7环境搭建相关推荐

  1. php linux下开发教程,linux下php环境搭建教程_后端开发

    linux下php环境搭建要领:起首猎取PHP.Apache以及MySQL装置包:然后装置Apache,并修正设置文件httpd.conf:接着装置MySQL,并做基础设置:末了装置PHP,并设置ph ...

  2. Linux下开发环境搭建---2. emacs篇

    Linux下开发环境搭建---2. emacs篇 本节主要参考:      曹乐的<在Emacs下用C/C++编程>      王纯业的<Emacs 一个强大的平台>      ...

  3. vs在linux下的环境搭建,linux下vscode环境配置

    文章目录 linux下vscode环境配置 编译器,调试器安装 sudo apt update #通过以下命令安装编译器和调试器 sudo apt install build-essential gd ...

  4. Android Linux下开发环境搭建

    开发环境--这个没有要求你一定得在什么系统下开发,你对哪个环境熟悉就用哪个. 如果习惯Windows的话,那在Windows下开发:如果对Linux比较熟,那你就用Linux. 不过,话说回来,Lin ...

  5. Zedboard学习(二):zedboard的Linux下交叉编译环境搭建

    环境准备 首先肯定是要下载xilinx-2011.09-50-arm-xilinx-linux-gnueabi.bin文件,这是官方提供的linux下交叉编译链安装文件,下载地址为:https://p ...

  6. Linux下python环境搭建

            前言:在Linux平台上搭建环境,往往因为系统版本.下载版本等原因,跟随安装教程安装,导致环境搭建失败.这里就总结一些我所遇到的问题及解决方法.         Linux版本:Cen ...

  7. linux下cgi环境搭建,CGI Linux下搭建环境

    CGI Linux下搭建环境 一.简述 记--在Ubuntu系统搭建CGI编程测试环境,服务器使用apache,还可以使用其它服务器如lighttpd,boa,nigx. 二.安装apache 命令: ...

  8. W800/Nepture/Hi3861/BL602 Harmony OS IOT Linux下开发环境搭建

    OpenHarmony(以下简称OH)自开源以来,已经过去了1年多.一年多时间,许多厂商争先恐后加入到OH的队伍中来,这一年多,发展迅速. 我有幸可以在这OH发展的初期加入到OH的开发中来,成为OH中 ...

  9. linux使用fabric教程,Hyperledger fabric在Linux下的环境搭建

    本文介绍如何在Ubuntu和CentOS系统下安装部署fabric环境,并在单机上运行一个示例启动fabric网络. 一.Ubuntu cURLsudo apt-get install curl Gi ...

最新文章

  1. matlab白化滤波,基于预白化方法的降噪预处理技术与流程
  2. char* p = 123,字符串在内存中的哪个位置?
  3. 网站推广专员浅析网站推广运营如何提升企业网站转化率?
  4. tomcat服务器访问网址组成
  5. java添加容器_如何为Java应用程序构建docker容器
  6. MySQL学习笔记(二)—— MySQL的安装
  7. c#异常处理_C#异常处理能力问题和解答 套装2
  8. pe估值 python_Python编程学习笔记(7)
  9. MYSQL 单表一对多查询,将多条记录合并成一条记录
  10. Windows Phone 7 自定义弹出窗口
  11. python列表删除多个相同元素_Python遍历列表删除多个元素或者重复元素
  12. CFFI - ABI模式与API模式
  13. 软件项目管理案例教程(第三版)其它课后题答案持续更新,欢迎收藏+关注
  14. python求最值_Python应用:python求极值点(波峰波谷)
  15. 网课答案公众号搭建-网课题库接口
  16. 详谈SSD硬盘接口: SATA、mSATA 、PCIe、M.2和U.2
  17. 【理财入门一】三大资产与财务自由
  18. 计算机管理服务修复,电脑提示“部署映像服务和管理工具错误87”的修复步骤...
  19. [.NET]CheckBoxList 用法
  20. MybatisPlus多表联查分页多条件查

热门文章

  1. Android中垃圾回收日志信息
  2. windows server 2008R2下的mysql主从同步配置
  3. 一个漂亮的输出MySql数据库表结构的PHP页面
  4. 卡耐基大学计算机专业分类,卡内基梅隆大学计算机专业
  5. stm32数据手册boot_STM32的ISP下载的原理是什么呢?
  6. MySQL条件运算符的使用
  7. 搭建K8s集群(kubeadm方式)-部署node节点和集群测试
  8. 异步发送,那消息可靠性怎么保证?
  9. 用户认证-什么是会话
  10. 缓存redis的整合