LAMP

练习:编译安装amp,提供两个基于主机名的虚拟主机

     (1) https, 部署pma

     (2) 部署wordpress

编译安装:

mariadb:

# wget 10.1.0.1:/pub/Sources/7.x86_64/mariadb/mariadb-5.5.46-linux-x86_64.tar.gz
# tar -xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/
# cd /usr/local
# ln -sv mariadb-5.5.46-linux-x86_64 mysql
# cd mysql
# groupadd -r mysql
# useradd -r -g mysql mysql
# id mysql
# chown mysql:root ./*
# mkdir /mydata/data -p
# chown mysql:mysql /mydata/data
# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
# vim /etc/profile.d/mysql.sh
    export PATH=/usr/local/mysql/bin:$PATH
# . /etc/profile.d/mysql.sh
# mv /etc/my.cnf{,.bak}
# cp support-files/my-small.cnf /etc/my.cnf
# vim /etc/my.cnf   // 在[mysqld]下追加
    datadir = /mydata/data
    skip_name_resolve = ON
    innodb_file_per_table = ON
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod +x /etc/rc.d/init.d/mysqld
# service mysqld start
# chkconfig --add mysqld

httpd:

# wget 10.1.0.1:/pub/Sources/sources/httpd/httpd-2.4.10.tar.bz2
# yum groupinstall "Development Tools" "Server Platform Development" -y
# yum install pcre-devel openssl-devel libevent-devel  apr-devel apr-util-devel -y
# tar -xf httpd-2.4.10.tar.bz2
# cd httpd-2.4.10/
# ./configure --prefix=/usr/local/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
# make -j 2
# make install
# vim /etc/httpd/httpd.conf
    #<IfModule dir_module>   中修改成
    DirectoryIndex index.html index.php
    
    #<IfModule mime_module>  中追加
    AddType application/x-httpd-php .php
# vim /etc/profile.d/httpd.sh
    export PATH=/usr/local/apache2/bin:$PATH
# . /etc/profile.d/mysql.sh
# apachectl start

安装php5:

# wget 10.1.0.1:/pub/Sources/sources/php/php-5.4.40.tar.bz2 &> /dev/null
# yum install gd-devel freetype-devel libmcrypt-devel libxml2-devel -y
# tar -xf php-5.4.40.tar.bz2
# cd php-5.4.40/
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql  --with-openssl \      #\表示该行未结束
--with-mysqli=/usr/local/mysql/bin/mysql_config --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/apache2/bin/apxs \
--with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d/
# make -j 2
# make install
# cd /usr/local/php
# cp php.ini-production /etc/php.ini
# mkdir /etc/php.d/
# apachectl restart

安装wordpress

# wget 10.1.0.1:/pub/Sources/sources/http/wordpress-4.3.1-zh_CN.zip
# mv wordpress-4.3.1-zh_CN.zip /usr/local/apache2/htdocs
# cd /usr/local/apache2/htdocs
# unzip wordpress-4.3.1-zh_CN.zip
# mysql
    MariaDB [(none)]> CREATE DATABESE wordpress;
    MariaDB [(none)]> GRANT ALL ON wordpress.* TO 'gm'@'localhost' IDENTIFIED BY 'gm625';
    MariaDB [(none)]> \q
# chmdo 777 wordpress

输入网址:10.1.43.101/wordpress   进行安装

LAMP

LAMP

LAMP

LAMP           

LAMP

LAMP

练习2:脚本实现amp编译安装

#!/bin/bash
#description : 编译安装LAMP
#version 0.1
#author gm
#date 20161012
#


#mariadb:
echo "wget mariadb Package."
wget 10.1.0.1:/pub/Sources/7.x86_64/mariadb/mariadb-5.5.46-linux-x86_64.tar.gz &> /dev/null && echo "wget mariadb Package secuessful."

tar -xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local
ln -sv mariadb-5.5.46-linux-x86_64 mysql

echo "add mysql group and mysql user."
groupadd -r mysql &> /dev/null
useradd -r -g mysql mysql &> /dev/null

echo "change file user:group."
cd mysql
chown mysql:root ./*
mkdir /mydata/data -p
chown mysql:mysql /mydata/data

echo "first bulid mysqldb."
scripts/mysql_install_db --user=mysql --datadir=/mydata/data && echo -e "\033[33mmysql db is secuessful.\033[0m"

echo "change PATH."
cat > /etc/profile.d/mysql.sh << end
export PATH=/usr/local/mysql/bin:$PATH
end
. /etc/profile.d/mysql.sh

echo "Add configure file."
mv /etc/my.cnf{,.bak}
cp support-files/my-small.cnf /etc/my.cnf
sed -i '/\[mysqld\]/a \datadir = /mydata/data\nskip_name_resolve = ON\ninnodb_file_per_table = ON' /etc/my.cnf

echo "Add server file."
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
service mysqld start &> /dev/null && echo -e "\033[32mmariadb server is start.\033[0m"


#httpd:
echo "wget httpd Package."
wget 10.1.0.1:/pub/Sources/sources/httpd/httpd-2.4.10.tar.bz2 &> /dev/null && echo "wget httpd Package secuessful."
yum groupinstall "Development Tools" "Server Platform Development" -y -q
yum install pcre-devel openssl-devel libevent-devel  apr-devel apr-util-devel -y -q

tar -xf httpd-2.4.10.tar.bz2
cd httpd-2.4.10/

echo "configure httpd.............." 
./configure --prefix=/usr/local/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 &> /dev/null
make -j 2  &> /dev/null
make install &> /dev/null

echo "change PATH."
cat > /etc/profile.d/httpd.sh << end
export PATH=/usr/local/apache2/bin:$PATH
end
. /etc/profile.d/mysql.sh

echo "change /etc/httpd/httpd.conf file."
echo "ServerName www.gm.com:80" >> /etc/httpd/httpd.conf
sed -i 's@^[[:space:]]*DirectoryIndex.*@& index.php@' /etc/httpd/httpd.conf
sed -i '/^[[:space:]]*AddType/a \AddType application/x-httpd-php .php' /etc/httpd/httpd.conf
apachectl start && echo -e "\033[33mhttpd is start.\033[0m"


#安装php5:
echo "wget php Package."
wget 10.1.0.1:/pub/Sources/sources/php/php-5.4.40.tar.bz2 &> /dev/null && echo "wget php Package secuessful."
yum install gd-devel freetype-devel libmcrypt-devel libxml2-devel -y -q
tar -xf php-5.4.40.tar.bz2
cd php-5.4.40/

echo "configure php................."
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql  --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config \    #\表示该行未结束
--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/apache2/bin/apxs --with-config-file-path=/etc/php.ini \
--with-config-file-scan-dir=/etc/php.d/ &> /dev/null

make -j 2 &> /dev/null
make install &> /dev/null

cp php.ini-production /etc/php.ini
mkdir /etc/php.d/
apachectl restart && echo -e "\033[33mhttpd+php is start.\033[0m"


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

(0)
megedugaomegedugao
上一篇 2016-10-12
下一篇 2016-10-12

相关推荐

  • CentOS安装本地 YUM源 产生的问题和解决过程

    本人刚刚踏入Linux的神秘殿堂就被如何安装软件这样的问题难倒了,经过Google大神的指点,终于找到了如何配置YUM源的方法,其中也不是一帆风顺,也产生了一些小问题,这些都是基础知识,希望能够帮到刚刚学习Linux的朋友。     由于VMware的终端不好用,所以想换成XShell,过程中又需要配置网络属性,桥接到…

    Linux干货 2016-01-05
  • N26-第五周博客作业

    一、显示当前系统上root、fedora或user1用户的默认shell; [root@promote home]# grep -E ‘^(root|fedora|user1)’ /etc/passwd |cut -d : -f7 /bin/bash /bin/bash /bin/bash [root@promote home]# 注…

    Linux干货 2017-05-15
  • 马哥教育网络班22期第5周课程作业

    1、显示当前系统上root、fedora或user1用户的默认shell; cat /etc/passwd | grep ^root | cut -d: -f7 2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello(); …

    Linux干货 2016-12-05
  • mariadb之再次演练

    架构图如下: 1.按照架构图所示,准备机器,做好时间同步,主机名解析 192.168.42.150 node1 [proxySQL keepalived]192.168.42.151 node2 [proxySQL keepalived]192.168.42.152 node3 [mysql-master wha]192.168.42.153 node4 […

    Linux干货 2016-03-06
  • linux 启动管理

    1、Linux系统启动流程:POST 加电自检 — BIOS(Boot Sequence)–>MBR(bootloader,446)(加载前512字节后的驱动程序,进入/boot目录,加载内核)–>Kernel–>initrd–>(系统根路径 /)(ROOTFS)/sbin/…

    Linux干货 2017-09-03
  • 运维成长记

     在学校里学到的是知识,而企业更看重的是技能和能力。我们需要把知识先转化为技能,然后实践中通过总结提升,转变为自己的能力。这个过程或许会很漫长,但是时间会证明一切。成长的过程注定是痛苦的,欲戴王冠,必承其重!我们有理由相信:运气也是实力的一部分! 第一次接触linux还是在大学的课堂上,看着老师在物理机上用VM虚拟出一台Ubuntu的时候,真实感觉…

    Linux干货 2017-07-11