linux下PHP7环境搭建
LAMP环境版本
- 操作系统:Centos 7
- Mysql:5.7.11
- Apache:2.4.18
- PHP:7.0.4
安装Mysql
为mysql创建专属帐号
- shell> groupadd mysql
- shell> useradd -r -g mysql -s /bin/false mysql
源码编译安装
- shell> tar zxvf mysql-5.7.11.tar.gz
- shell> cd mysql-5.7.11
- shell> cmake .
- shell> make
- shell> make install
安装后设置
- shell> cd /usr/local/mysql
- shell> chown -R mysql . #修改目录所有者为mysql
- shell> chgrp -R mysql . #修改目录所属组为mysql
- shell> bin/mysqld --initialize-insecure --user=mysql --datadir=/data/mysql #初始化mysql,初始化为空,数据库存放目录指定为/data/mysql
- shell> bin/mysql_ssl_rsa_setup #启动ssl加密方式连接
- shell> chown -R root . #修改目录所有者为root
- shell> chown -R mysql /data/mysql #修改数据库目录所有者为mysql
安装mysql服务
- shell> cp support-files/mysql.server /etc/init.d/mysql.server
- shell> service mysql start #启动服务
安装Apache
源码编译安装
- shell> ./configure --prefix=/usr/local/apahche \
- --enable-so #动态共享对象,可实现模块动态生效 \
- --enable-rewrite #启用Rewrite功能 \
- --enable-ssl #支持SSL/TLS,可以实现https访问 \
- --enable-deflate #支持压缩 \
- shell> make
- shell> make install
apache的启动与关闭
- shell> /usr/local/apache/bin/apachectl start #启动
- shell> /usr/local/apache/bin/apachectl stop #停止
- shell> /usr/local/apache/bin/apachectl restart #重启
将apache添加到Linux的服务并设置自启动
- shell> cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd #设置为系统服务
- shell> ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S80httpd #在启动级别3中自启动
- shell> service httpd restart #通过服务来重启apache
运行测试页面
常见问题
- configure: error: APR not found.
解决方法: 安装对应依赖库[plain] view plaincopy
- shell> yum install apr apr-util-devel
- configure: error: pcre-config for libpcre not found.
解决方法:安装对应依赖库[plain] view plaincopy
- 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
安装依赖库
- zlib官网:http://www.zlib.net/[plain] view plaincopy
- shell> tar xf zlib.1.2.8.tar.gz
- shell> cd zlib.1.2.8
- shell> ./configure
- shell> make test
- shell> make install
- GD库
libpng官网:http://www.libpng.org/[plain] view plaincopy
- shell> tar xf libpng-1.6.21
- shell> cd libpng-1.6.21
- shell> ./configure --prefix=/usr/local/libpng
- shell> make
- shell> make check
- shell> make install
jpeg
官网:http://www.ijg.org/[php] view plaincopy- shell> tar xf jpegsrc.v9.tar.gz
- shell> cd jpeg-9
- shell> ./configure --prefix=/usr/local/libjpeg
- shell> make
- shell> make install
- libcurl-devel
[plain] view plaincopy
- yum install libcurl-devel
- openssl-devel[plain] view plaincopy
- yum install openssl-devel
- libxslt-devel[plain] view plaincopy
- yum install libxslt-devel
- libxml2-devel[plain] view plaincopy
- yum install libxml2-devel
- freetype 字体操作库官网:http://www.freetype.org/[plain] view plaincopy
- shell> tar xf freetype-2.6.3.tar.bz2
- shell> sh autogen.sh
- shell> ./configure --prefix=/usr/local/freetype
- shell> make
- shell> make install
编译安装PHP
- ./configure --prefix=/usr/local/php \
- --with-apxs2=/usr/local/apache/bin/apxs \
- --with-curl \
- --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
- (./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
- shell> make
- shell> make install
PHP安装成功后会在apache的modules目录下生成一个libphp.so动态库文件,在apache的配置文件httpd.conf里自动增加一行
- LoadModule php7_module modules/libphp7.so
在Apache的配置文件httpd.conf的<IfModule mime_module></IfModule>块里增加一行
- AddType application/x-httpd-php .php
在网站要目录/usr/local/htdocs里增加一个index.php测试文件内容如下:
- <?php
- phpinfo();
然后我们运行此文件,如果输出了phpinfo信息,证明我们安装成功。
linux下PHP7环境搭建相关推荐
- php linux下开发教程,linux下php环境搭建教程_后端开发
linux下php环境搭建要领:起首猎取PHP.Apache以及MySQL装置包:然后装置Apache,并修正设置文件httpd.conf:接着装置MySQL,并做基础设置:末了装置PHP,并设置ph ...
- Linux下开发环境搭建---2. emacs篇
Linux下开发环境搭建---2. emacs篇 本节主要参考: 曹乐的<在Emacs下用C/C++编程> 王纯业的<Emacs 一个强大的平台> ...
- vs在linux下的环境搭建,linux下vscode环境配置
文章目录 linux下vscode环境配置 编译器,调试器安装 sudo apt update #通过以下命令安装编译器和调试器 sudo apt install build-essential gd ...
- Android Linux下开发环境搭建
开发环境--这个没有要求你一定得在什么系统下开发,你对哪个环境熟悉就用哪个. 如果习惯Windows的话,那在Windows下开发:如果对Linux比较熟,那你就用Linux. 不过,话说回来,Lin ...
- Zedboard学习(二):zedboard的Linux下交叉编译环境搭建
环境准备 首先肯定是要下载xilinx-2011.09-50-arm-xilinx-linux-gnueabi.bin文件,这是官方提供的linux下交叉编译链安装文件,下载地址为:https://p ...
- Linux下python环境搭建
前言:在Linux平台上搭建环境,往往因为系统版本.下载版本等原因,跟随安装教程安装,导致环境搭建失败.这里就总结一些我所遇到的问题及解决方法. Linux版本:Cen ...
- linux下cgi环境搭建,CGI Linux下搭建环境
CGI Linux下搭建环境 一.简述 记--在Ubuntu系统搭建CGI编程测试环境,服务器使用apache,还可以使用其它服务器如lighttpd,boa,nigx. 二.安装apache 命令: ...
- W800/Nepture/Hi3861/BL602 Harmony OS IOT Linux下开发环境搭建
OpenHarmony(以下简称OH)自开源以来,已经过去了1年多.一年多时间,许多厂商争先恐后加入到OH的队伍中来,这一年多,发展迅速. 我有幸可以在这OH发展的初期加入到OH的开发中来,成为OH中 ...
- linux使用fabric教程,Hyperledger fabric在Linux下的环境搭建
本文介绍如何在Ubuntu和CentOS系统下安装部署fabric环境,并在单机上运行一个示例启动fabric网络. 一.Ubuntu cURLsudo apt-get install curl Gi ...
最新文章
- matlab白化滤波,基于预白化方法的降噪预处理技术与流程
- char* p = 123,字符串在内存中的哪个位置?
- 网站推广专员浅析网站推广运营如何提升企业网站转化率?
- tomcat服务器访问网址组成
- java添加容器_如何为Java应用程序构建docker容器
- MySQL学习笔记(二)—— MySQL的安装
- c#异常处理_C#异常处理能力问题和解答 套装2
- pe估值 python_Python编程学习笔记(7)
- MYSQL 单表一对多查询,将多条记录合并成一条记录
- Windows Phone 7 自定义弹出窗口
- python列表删除多个相同元素_Python遍历列表删除多个元素或者重复元素
- CFFI - ABI模式与API模式
- 软件项目管理案例教程(第三版)其它课后题答案持续更新,欢迎收藏+关注
- python求最值_Python应用:python求极值点(波峰波谷)
- 网课答案公众号搭建-网课题库接口
- 详谈SSD硬盘接口: SATA、mSATA 、PCIe、M.2和U.2
- 【理财入门一】三大资产与财务自由
- 计算机管理服务修复,电脑提示“部署映像服务和管理工具错误87”的修复步骤...
- [.NET]CheckBoxList 用法
- MybatisPlus多表联查分页多条件查