LAMP 源码安装基于centos6.6

    

lamp流程:

    1. 用户发送http请求到达httpd服务器

    2. httpd解析url获取需要的资源的路径,通过内核空间读取硬盘资源,如是静态资源,则构建响应报文,发回给用户

    3. 如果是动态资源,将资源地址发给php解析器,解析php程序文件,解析完毕将内容发回给httpd,httpd构建响应报文,发回给用户

    4. 如果涉及到数据库操作,则利用php-mysql驱动,获取数据库数据,返回给PHP解析器。


环境介绍: centos6.6  httpd-2.4.16 mysql-5.6.10  php-5.6.11

环境配置脚本

[root@localhost ~]# ./env.sh


#!/bin/bash

setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
iptables -F
service iptables save
service NetworkManager stop

chkconfig NetworkManager off

reboot


xftp 把apr-util-1.5.4.tar.gz    httpd-2.4.16.tar.gz libmcrypt-2.5.8.tar.gz  mysql-5.6.10.tar.gz apr-1.5.2.tar.gz  Discuz_X3.2_SC_UTF8.zip  libiconv-1.13.1.tar.gz  mhash-0.9.9.9.tar.gz    php-5.6.11.tar.gz传输到~目录下

环境部署软件脚本 LAMP.sh

#!/bin/bash

yum install -y wget gcc  gcc-c++  make  cmake bison  bison-devel libaio-devel  perl file patchmlocate flex diffutils readline-devel libcap-devel glibc-devel glib2-develautoconf automake libgcrypt* libtool* openssl openssl-devel ncursesncurses-devel libxml2  libxml2-*libmcrypt* curl curl-devel zlib zlib-devel bzip2*  gd gd-devel libjpeg libjpeg-devel  libpng libpng-devel  mcrypt freetype*gettext gettext-devel pcre pcre-devel --skip-broken &> /dev/null
cd ~
tar -zxf apr-1.5.2.tar.gz -C /usr/local/src/
cd /usr/local/src/apr-1.5.2
./configure --prefix=/usr/local/apr &> /dev/null
make  &> /dev/null
make install &> /dev/null




cd ~
tar -zxf apr-util-1.5.4.tar.gz -C /usr/local/src/ 
cd /usr/local/src/apr-util-1.5.4/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr &> /dev/null
make  &> /dev/null
make install &> /dev/null


cd ~
tar -zxf httpd-2.4.16.tar.gz -C /usr/local/src/
cd /usr/local/src/httpd-2.4.16/
./configure --prefix=/usr/local/httpd  --sysconfdir=/etc/httpd --enable-rewrite --enable-ssl --enable-cgi --enable-expires=shared --enable-mods-shared --enable-mudules=most --enable-mods-shared=all --enable-deflate --enable-speling --enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-so --enable-rewrite=shared --enable-static-support --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre &> /dev/null
make  &> /dev/null
make install &> /dev/null


cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
sed -i '2i\#chkconfig\:\ 2345\ 80\ 90' /etc/init.d/httpd 
sed -i '3i\#description\:auto\_run' /etc/init.d/httpd
chkconfig --add httpd           
chkconfig --level 235 httpd on
sed -i "s/\#ServerName www\.example.com\:80/ServerName localhost\:80/" /etc/httpd/httpd.conf
sed -i 's/DirectoryIndex index\.html/DirectoryIndex index\.html index\.php/' /etc/httpd/httpd.conf
echo  "AddType application/x-httpd-php .php" >> /etc/httpd/httpd.conf




cd ~
tar -zxf libmcrypt-2.5.8.tar.gz -C /usr/local/src/
cd /usr/local/src/libmcrypt-2.5.8
./configure &> /dev/null
make &> /dev/null
make install &> /dev/null


cd ~
tar -xzf php-5.6.11.tar.gz -C /usr/local/src
cd /usr/local/src/php-5.6.11/
./configure  --prefix=/usr/local/php --with-mysql=mysqlnd  --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-zlib --with-libxml-dir --enable-sockets --with-apxs2=/usr/local/httpd/bin/apxs  --with-mcrypt  --with-config-file-path=/etc  --with-config-file-scan-dir=/etc/php.d  --with-bz2  --with-gd  --with-mhash  --enable-gd-native-ttf  --with-iconv  --with-png-dir  --with-jpeg-dir  --with-gettext  --with-curl  --with-pear --with-freetype-dir  --enable-bcmath --enable-xml --enable-mbstring --enable-shmop --enable-soap  --enable-sysvsem  --enable-calendar --enable-zip --enable-ftp --enable-maintainer-zts  &> /dev/null
make &> /dev/null
make install &> /dev/null
cp /usr/local/src/php-5.6.11/php.ini-development /etc/php.ini


sed -i 's/short_open_tag \= Off/short_open_tag = On/' /etc/php.ini
sed -i 's/;date\.timezone \=/date\.timezone \= Asia\/Shanghai/' /etc/php.ini 


yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison opensslopenssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype* --skip-broken &> /dev/null
yum install -y perl-Module-Install.noarch  &> /dev/null


cd ~
tar zxf mysql-5.6.10.tar.gz -C /usr/local/src
useradd -d /usr/local/mysql/ -s /sbin/nologin mysql
mkdir -p /usr/local/mysql/data         
mkdir -p /usr/local/mysql/log          
chown -R mysql:mysql /usr/local/mysql/data/
chown -R mysql:mysql /usr/local/mysql/log/cd 
chmod 750 /usr/local/mysql/data     
chmod 750 /usr/local/mysql/log
cd /usr/local/src/mysql-5.6.10/


cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DSYSCONFDIR=/etc -DWITH_SSL=yes  &> /dev/null
make &> /dev/null
make install &> /dev/null


echo "/usr/local/mysql/lib" >> /etc/ld.so.conf.d/mysql.conf
ldconfig
 
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
cd /usr/local/mysql
mv /etc/my.cnf /etc/my.cnf.old
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data &> /dev/null


cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig  --add mysqld
chkconfig  --level 35 mysqld on
 
 
echo "PATH=$PATH:/usr/local/mysql/bin;export PATH" >> /etc/profile
source /etc/profile
 
service mysqld restart &> /dev/null
mysqladmin -u root password 123.com 


service httpd restart


cat >> vim /usr/local/httpd/htdocs/info.php << END
<?php
  $conn=mysqli_connect('localhost','root','123.com');
  if ($conn)
   echo "<h2>成功...</h2>";
  else
   echo "<h2>Failure...</h2>";
?>
<?php
phpinfo();
?>
END
reboot




  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值