您的位置:首页 > 运维架构 > Linux

在CentOS 7上编译安装lamp

2016-07-21 15:45 483 查看
1.编译安装httpd-2.4.10
(1)首先安装”DevelopmentTools”和“Server Platform Development”
~]# yum groupinstall -y “Development Tools” “ServerPlatform Development”(2)安装增强版正则表达式分析器pcre-devel,以及openssl-devel,apr-devel,apr-util-devel,libevent-devel
~]# yum install -y pcre-devel openssl-devel apr-develapr-util-devel libevent-devel(3)下载httpd-2.4.10源码包并展开。
~]# tar xvf httpd-2.4.10.tar.bz2(4)制作makefile文件
./configure --prefix=/usr/local/apache24--sysconfdir=/etc/httpd24 --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(5)编译并安装httpd-2.4.10
~]# make && make install(6)将httpd相关可执行文件搜索路径导入到环境变量
~]# vim /etc/profile.d/http24.shexportPATH=/user/local/apache24/bin:$PATH~]# source /etc/profile.d/http24.sh(7)将库文件做软链接至/usr/incloud/httpd
~]# ln -sv /usr/local/apache24/incloud /use/incloud/httpd(8)启动httpd服务
~]# apachectl start2.安装mariadb-5.5.46
(1)将mariadb-5.5.46-tar.gz解压到/usr/local目录下
~]#tar xvf mariadb-5.5.46-tar.gz -C /usr/local
(2)为mariadb创建数据目录
~]#mkdir -pv /data/mydata
~]#chown -R mysql:mysql /data/mydata
(3)将解压后的目录链接至/usr/local/mysql目录,便于以后滚动
~]#ln -sv /usr/local/mariadb-5.5.46 /usr/local/mysql
(4)将/usr/local/mysql目录下的所有文件属主改为root,属组改为mysql
~]#cd /usr/local/mysql
~]#chown -R root:mysql ./*
(5)初始化mariadb
~]#cd /usr/local/mysql
~]#scripts/mysql_install_db --user=mysql --datadir=/data/mydata
(6)编辑配置文件
~]#cp support-files/my-large.cnf /etc/my.cnf
~]#vim /etc/my.cnf
datadir=/data/mydata
innodb_file_per_table= ON
skip_name_resolve= ON
(7)启动脚本
~]#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
~]#chmod +x /etc/rc.d/init.d/mysqld
(8) 将mariadb相关可执行文件搜索路径导入到环境变量
~]#vim /etc/profile.d/mysql.sh
exportPATH=/usr/local/mysql/bin:$PATH
~]#source /etc/profile.d/mysql.sh
(9)启动mariadb
~]#service mysqld start
3.编译安装php-5.5.40
(1)安装php依赖的程序包,libxml2-devel,gd-devel,freetype-devel,libmcrypt-devel
~]#yum install -y libxml2-devel gd-devel freetype-devel libmcrypt-devel
(2)下载php-5.4.40并展开
~]#tar xvf php-5.4.40.tar.bz2
(3)利用configure脚本制作makefile文件
~]#cd php-5.4.40
~]#./configure --prefix=/usr/local/php54 --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/apache24/bin/apxs--with-config-file-path=/etc/php54.ini --with-config-file-scan-dir=/etc/php54.d
(4)编译并安装
~]#make && make install
(5)制作配置文件
~]#cp php.ini-production /etc/php.ini
(6)增加MIME类型
~]#vim /etc/httpd24/httpd.conf
AddTypeapplication/x-httpd-php .php
(7)指明默认页面类型为index.php
~]#vim /etc/httpd24/httpd.conf
DirectoryIndexindex.php index.html
4.制作测试页面进行测试
~]#mv/usr/local/apache24/htdocs/index.{html,php}
~]#vim/usr/local/apache24/htdocs/index.php
<?php
Phpinfo();
?>



5.测试数据库连接
(1)在MariaDB里面创建数据库testdb,创建用户testuser,并给该用户授权:
~]# mysqlMariaDB[(none)]>CREATEDATABASE testdb;MariaDB[(none)]>CREATEUSER ‘testuser’@’127.0.0.1’ IDENTIFIED BY ‘testpasswd’;MariaDB[(none)]>GRANTALL ON testdb.* TO ‘testuser’@’127.0.0.1’;MariaDB[(none)]>FLUSHPRIVILEGES;(2)编辑默认主页文件/var/www/html/index.php,编写如下脚本进行测试:
<?php
$conn= mysql_connect(‘127.0.0.1’,’testuesr’,’testpasswd’);
If($conn)
echo“OK”;
else
echo“Falure”;
?>
(3)在浏览器上测试



6.安装wordpress和phpMyAdmin
(1)在httpd主配置文件中注释掉#DocumentRoot "/usr/local/apache24/htdocs"
将Include /etc/httpd24/extra/httpd-vhosts.conf取消注释。
(2)创建两个虚拟主机www1.magedu.com和www2.mage.com
~]#mkdir -pv /vhost/www{1,2}
~]#vim /etc/httpd24/extra/httpd-vhosts.conf



(3)下载worepress并解压至/vhost/www1/目录下,修改配置文件:
~]#mv wp-config-sample.php wp-config.php
~]#vim wp-config.php



(4)测试www1.magedu.com域名



(5)下载phpMyAdmin并解压至/vhost/www2目录下,并重命名改配置文件:
~]#mv config.sample.inc.php config.inc.php
(6)用openssl生成随机字符串,并填至配置文件相应位置,并修改MySQL服务器IP:
~]#openssl rand -base64 10
~]# vim config.inc.php






(7)在浏览器打开www2.magedu.com测试phpMyAdmin:


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: