linux编译lamp,编译安装LAMP

编译安装LAMP

(1) 系统环境:CentOS 6, 7

CentOS 6:apr, apr-util的版本为1.3.9,不适用于httpd-2.4;

CentOS 7:apr, apr-util的版本为1.4+,

(2) 开发环境:Development Tools, Server Platform Development(3) 各程序版本

httpd: 2.2, 2.4

php:5.3.x 5.4.x, 5.6.x

mysql:5.1, 5.5, 5.6, 5.7, 5.8, 8.0

mariadb:5.x, 10.x

(4) httpd+php

php的编译选项:

Modules:--with-apxshttpd MPM:

prefork:

worker, event:专用选项–enable-maintainer-zts

fpm:--enable-fpm

本次安装以CentOS 7为例进行安装

安装httpd-2.4

[root@centos7 ~]# mkdir -p /usr/local/lamp  #创建lamp目录

[root@centos7 ~]# yum -y groupinstall "Development Tools" "Server Platform Development"  #安装开发环境

[root@centos7 ~]# yum -y install pcre-devel openssl-devel libevent-devel apr-devel apr-util-devel  #安装依赖包

[root@centos7 ~]# useradd -r -s /sbin/nologin apache  #创建apache系统用户

[root@centos7 ~]# tar xf httpd-2.4.6.tar.bz2  #解压

[root@centos7 ~]# cd httpd-2.4.6/

[root@centos7 httpd-2.4.6]# ./configure --prefix=/usr/local/lamp/apache2 --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-pcre --with-zlib --with-apr=/usr --with-apr-util=/usr  #配置httpd

[root@centos7 httpd-2.4.6]# make   #编译

[root@centos7 httpd-2.4.6]# make install #安装

[root@centos7 ~]# echo "export PATH=/usr/local/lamp/apache2/bin:$PATH" > /etc/profile.d/httpd.sh  #配置PATH环境变量

[root@centos7 ~]# . /etc/profile.d/httpd.sh   #生效

[root@centos7 ~]# vim /etc/httpd/httpd.conf   #编辑配置文件

3c8ce6380daa33c267ccb0e2e66a02de.png

3c8ce6380daa33c267ccb0e2e66a02de.png

[root@centos7 ~]# apachectl start  #启动httpd服务

3c8ce6380daa33c267ccb0e2e66a02de.png

3c8ce6380daa33c267ccb0e2e66a02de.png

安装mariadb

安装MariaDB:

1.预制的包管理器格式的程序包:

rpm包:

os vendor:mariadb-devel

MariaDB官方

2.通用二进制格式的程序包:

3.源码包编译:项目构建工具为cmake, 而非流行的make;

本次以通用二进制格式包的安装配置

[root@centos7 ~]# useradd -r -s /sbin/nologin mysql  #创建mysql系统用户

[root@centos7 ~]# tar xf mariadb-VERSION-linux-x86_64.tar.gz -C /usr/local/lamp  #解压至/usr/local/lamp目录下

[root@centos7 ~]# cd /usr/local/lamp

[root@centos7 lamp]# ln -s mariadb-VERSION-linux-x86_64 mysql  #创建软连接

[root@centos7 ~]# cd mysql

[root@centos7 mysql]# chown -R mysql:mysql ./*  #修改属主属组为mysql

[root@centos7 mysql]# mkdir -pv /mydata/data  #为mysql创建数据目录

[root@centos7 mysql]# chown -R mysql:mysql /mydata/data  #修改数据目录属主属组为msql

[root@centos7 mysql]# ./scripts/mysql_install_db  --user=mysql  --datadir=/mydata/data --skip_name_resolve   #安装mysql

[root@centos7 mysql]# cp support-files/my-large.cnf  /etc/my.cnf  #生成配置文件

[root@centos7 mysql]# cp support-files/mysql.server  /etc/rc.d/init.d/mysqld   #生成服务脚本文件

[root@centos7 mysql]# chkconfig --add mysqld   #添加开机自启动

[root@centos7 mysql]# chkconfig --level 2345 mysqld on  #开机在2345运行级别下启动

[root@centos7 mysql]# vim /etc/my.cnf  #编辑配置文件

3c8ce6380daa33c267ccb0e2e66a02de.png

[root@centos7 mysql]# service mysqld start   #启动mysql服务

Starting MySQL.. SUCCESS!

[root@centos7 mysql]#

3c8ce6380daa33c267ccb0e2e66a02de.png

[root@centos7 ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh   #配置PATH环境变量

[root@centos7 ~]# . /etc/profile.d/mysql.sh   #生效

[root@centos7 ~]# mysql_secure_installation   #可对数据库做安全配置

[root@centos7 ~]# mysql  #测试数据库

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 5.5.46-MariaDB-log MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>     #数据库配置成功!!!!

基于module安装php

Modules:--with-apxshttpd MPM:

prefork:

worker, event:专用选项--enable-maintainer-zts

[root@centos7 ~]# yum -y install gd-devel freetype-devel libxml2-devel libmcrypt-devel   #安装php依赖包

[root@centos7 ~]# tar xf php-5.4.40.tar.bz2  #解压

[root@centos7 ~]# cd php-5.4.40/

[root@centos7 php-5.4.40]# ./configure --prefix=/usr/local/lamp/php5 --with-mysql=/usr/local/lamp/mysql --with-mysqli=/usr/local/lamp/mysql/bin/mysql_config --with-openssl --enable-mbstring --enable-xml --enable-sockets --with-freetype-dir --with-gd --with-libxml-dir=/usr --with-zlib --with-jpeg-dir --with-png-dir --with-mcrypt --with-apxs2=/usr/local/lamp/apache2/bin/apxs --with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d/  #配置php参数

[root@centos7 php-5.4.40]# make  #编译

[root@centos7 php-5.4.40]# make install  #安装

[root@centos7 php-5.4.40]# cp php.ini-production /etc/php.ini  #复制配置文件

[root@centos7 php-5.4.40]# vim /etc/httpd/httpd.conf  #编辑httpd配置文件整合httpd+php

3c8ce6380daa33c267ccb0e2e66a02de.png

3c8ce6380daa33c267ccb0e2e66a02de.png

[root@centos7 ~]# vim /usr/local/lamp/apache2/htdocs/index.php   #创建默认访问页

3c8ce6380daa33c267ccb0e2e66a02de.png

测试

3c8ce6380daa33c267ccb0e2e66a02de.png

基于php-fpm安装php

fpm:--enable-fpm

[root@centos7 ~]# yum -y install gd-devel freetype-devel libxml2-devel libmcrypt-devel  #安装php依赖包

[root@centos7 ~]# tar xf php-5.4.40.tar.bz2  #解压

[root@centos7 ~]# cd php-5.4.40/

[root@centos7 php-5.4.40]# ./configure --prefix=/usr/local/lamp/php5 --with-mysql=/usr/local/lamp/mysql --with-mysqli=/usr/local/lamp/mysql/bin/mysql_config --with-openssl --enable-mbstring --enable-xml --enable-sockets --with-freetype-dir --with-gd --with-libxml-dir=/usr --with-zlib --with-jpeg-dir --with-png-dir --with-mcrypt --enable-fpm --with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d/  #配置php参数

[root@centos7 php-5.4.40]# make  #编译

[root@centos7 php-5.4.40]# make install  #安装

[root@centos7 php-5.4.40]# cp php.ini-production /etc/php.ini  #复制配置文件

[root@centos7 php-5.4.40]# cp /usr/local/lamp/php5/php-fpm.conf.default /usr/local/lamp/php5/php-fpm.conf  #生成php-fpm配置文件

[root@centos7 php-5.4.40]# vim /etc/httpd/httpd.conf  #编辑httpd配置文件整合httpd+php

3c8ce6380daa33c267ccb0e2e66a02de.png

3c8ce6380daa33c267ccb0e2e66a02de.png

3c8ce6380daa33c267ccb0e2e66a02de.png

[root@centos7 php-5.4.40]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm   #生成php-fpm服务脚本文件

[root@centos7 php-5.4.40]# chkconfig --add php-fpm   #添加php-fpm开机自启动

[root@centos7 php-5.4.40]# chkconfig --level 2345 php-fpm on   #开机在2345运行级别下开启此服务

[root@centos7 ~]# service php-fpm start   #开启php-fpm服务

3c8ce6380daa33c267ccb0e2e66a02de.png

测试

3c8ce6380daa33c267ccb0e2e66a02de.png

原创文章,作者:zhai796898,如若转载,请注明出处:http://www.178linux.com/57262

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值