栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

LAMP环境搭建

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

LAMP环境搭建

环境说明:centos最小化安装,配置腾讯yum源
#!/bin/bash

#Desc:LAMP环境搭建,mysql5.6
#1安装apache
#安装apache需要的包
#a:依赖包apr-1.5.2.tar.bz2 apr-util-1.5.4.tar.bz2
#b:源码包httpd-2.4.37.tar.bz2
tar -xvf apr-1.5.2.tar.bz2
tar -xvf apr-util-1.5.4.tar.bz2
tar -xvf httpd-2.4.37.tar.bz2

#安装apr
cd apr-1.5.2/
./configure --prefix=/usr/local/apr
make && make install
cd …
#安装apr-util
cd apr-util-1.5.4/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
cd …
#其它依赖
yum -y install pcre-devel
yum -y install expat-devel
yum -y install openssl-devel
#安装httpd
cd httpd-2.4.37/
./configure
–enable-modules=all
–enable-mods-shared=all
–enable-so
–enable-rewrite
–with-pcre
–enable-ssl
–with-mpm=prefork
–with-apr=/usr/local/apr
–with-apr-util=/usr/local/apr-util

make && make install
cd …
echo “"
echo “apache 安装完成”
echo "”
#2安装php
#安装依赖包
yum -y install libcurl-dev curl-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel
tar -xvf php-7.2.17.tar.xz
cd php-7.2.17/
./configure
–with-apxs2=/usr/local/apache2/bin/apxs
–with-mysqli
–with-pdo-mysql
–with-zlib
–with-curl
–enable-zip
–with-gd
–with-freetype-dir
–with-jpeg-dir
–with-png-dir
–enable-sockets
–with-xmlrpc
–enable-soap
–enable-opcache
–enable-mbstring
–enable-mbregex
–enable-pcntl
–enable-shmop
–enable-sysvmsg
–enable-sysvsem
–enable-sysvshm
–enable-calendar
–enable-bcmath

make && make install
cd …
echo “"
ls /usr/local/apache2/modules/libphp7.so
if [[ $? -eq 0 ]];then
echo “php 安装完成”
else
echo “php 安装失败”
exit 5
fi
echo "”
#3配置apache
httpdconf=/usr/local/apache2/conf/httpd.conf
#配置主机名
sed -i ‘/^#ServerName/c ServerName localhost:80’ KaTeX parse error: Expected 'EOF', got '#' at position 11: httpdconf #̲配置Apache语言支持(支持…)/1/g’ KaTeX parse error: Expected 'EOF', got '#' at position 21: …conf sed -i 's/#̲(.*httpd-langu…)/1/g’ $httpdconf
#开启对PHP的支持
sed -i ‘/.libphp7.so/a AddHandler php7-script .phpnAddType text/html .php’ $httpdconf
#添加index.php默认首页
sed -i ‘s/DirectoryIndex/DirectoryIndex index.php/g’ $httpdconf
#让Apache优先支持中文
#vim /usr/local/apache2/conf/extra/httpd-languages.conf
language_conf=/usr/local/apache2/conf/extra/httpd-languages.conf
#sed -i 's/#(DefaultLanguage.)/1/g’ $language_conf
sed -i ‘/DefaultLanguage nl/c DefaultLanguage zn-CH’ $language_conf
sed -i ‘/^LanguagePriority/c LanguagePriority zh-CN en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv tr zh-TW’ $language_conf

echo “"
echo “apache 配置完成”
echo "”

#写一个测试php文件
echo -e “” > /usr/local/apache2/htdocs/test.php
/usr/local/apache2/bin/apachectl start
ip=ifconfig ens33 | sed -n '2p'|sed 's/ /n/g'|sed 's/[a-z]//g'|sed '/^$/d'|sed -n '1p'
echo “测试url:$ip/test.php”

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/961901.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号