lamp源码编译安装脚本+源码包

lamp源码编译安装脚本+源码包

最好是源码源码初始的linux Centos7版本 然后把所有安装包和执行脚本都要拷贝到/mnt目录下面

#!/usr/bin/bash

yum -y install gcc gcc-c++ make pcre-devel expat-devel perl apr* #安装所有必须组件

####################安装Apache

#安装所需编译器和组件包

if [ ! -d ];then

tar jxvf #解压Apache源码包

fi

cd #移动到解压后目录

./configure --prefix=/usr/local/--enable-so --enable-rewrite --enable-charest-lite --enable-cgi

#--prefix=/usr/local/-j16 && make install #编译和安装

cp /usr/local//etc/init.d/--add #将! -d /usr/local/] && cp /usr/local//usr/local/-i '199s/#//' /usr/local/-rf /etc/-s /usr/local//etc/#创建配置文件的软连接

ln -s /usr/local//usr/local/bin/#创建命令的软连接

wait

#######################安装MySQL##################################################

cd /mnt#回到mnt目录

yum -y install git#安装Git组件

yum install -y cmake#安装cmake工具

yum install -y ncurses-devel autoconf#安装ncurses组件

tar zxvf mysql-5.6.26.tar.gz

cd mysql-5.6.26#解压MySQL 并cd到目录

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

-DEXTRA_CHARSETS=all -DSYSCONFIDIR=/etc -DMYSQL_DATADIR=/home/mysql/ -DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock

#定义安装环境

#-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

#-DDEFAULT_COLLATION=utf8_general_ci \

#-DEXTRA_CHARSETS=all \

#-DSYSCONFIDIR=/etc \

#-DMYSQL_DATADIR=/home/mysql/ \

#-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock

make -j16 && make install#进行编译和安装

cp /usr/local/mysql/support-files/my-default-f /etc/my-f#复制模板配置文件

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld#复制执行脚本

chmod 755 /etc/init.d/mysqld #给执行脚本添加执行权限

chkconfig --add /etc/init.d/mysqld && chkconfig mysqld --level 235 on#给service工具添加MySQL服务

#echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

#source /etc/profile#定义MySQL命令到系统环境变量

ln -s /usr/local/mysql/bin/* /usr/local/bin

useradd -s /sbin/nologin mysql#创建MySQL执行用户

chown -R mysql:mysql /usr/local/mysql/#给该MySQL安装目录的属主跟属组

/usr/local/mysql/scripts/mysql_install_db \

--user=mysql \

--ldata=/var/lib/mysql \

--basedir=/usr/local/mysql \

--datadir=/home/mysql

sed -i '46s/.*/basedir=\/usr\/local\/mysql /' /etc/init.d/mysqld#添加MySQL执行脚本

sed -i '47s/.*/datadir=\/home\/mysql/' /etc/init.d/mysqld

#mysqladmin -u root -p password "abc123" #给root账号设置密码

############################安装PHP#####################################

cd /mnt

yum -y install gd libpng libpng-devel pcre pcre-devel libxml2-devel #安装必要组件

tar xjvf php-5.6.11.tar.bz2

cd php-5.6.11#解压并进入到 解压后目录

./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-apxs2=/usr/local/--with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5

make -j16 && make install#定义安装环境

cp php.ini-development /usr/local/php5/php.ini#复制PHP配置模板文件为新配置文件

ln -s /usr/local/php5/bin/* /usr/local/bin/

ln -s /usr/local/php5/sbin/* /usr/local/sbin/#创建命令的软连接

echo "

AddType application/x-.php

AddType application/x-.phps" >> /etc/-i '258s/index.html/index.php index.html/' /etc/源码包的的地址:

链接:-pan.baidu-/s/1M0p7skMwgXSsfvVoJm0kjQ

提取码:10pj

更多内容请点击【其他技术】专栏