设为首页 收藏本站
查看: 2025|回复: 0

Cent OS 中LAMP 环境源码搭建

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-3-30 08:56:29 | 显示全部楼层 |阅读模式
导读:什么是LAMP?
LAMP指的Linux(操作系统)、ApacheHTTP 服务器,MySQL(有时也指MariaDB,数据库软件) 和PHP(有时也是指Perl或Python) 的第一个字母,一般用来建立web应用平台。

本案环境与说明:
环境
1
2
3
[iyunv@bright ~]# cat /etc/centos-release && uname -r
CentOS release 6.6 (Final)
2.6.32-504.el6.x86_64



软件版本:
1
2
3
4
5
6
mysql-5.7.6-m16-linux-glibc2.5-x86_64.tar.gz
httpd-2.4.10.tar.gz
apr-1.5.1.tar.gz
apr-util-1.5.4.tar.gz  
libmcrypt-2.5.6.tar.gz  
php-5.6.6.tar.gz



文中所用软件下载地址:
http://mirrors.sohu.com/
http://mirrors.cnnic.cn/apache/
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt

一、安装MySQL
wget http://mirrors.sohu.com/mysql/My ... bc2.5-x86_64.tar.gz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@bright ~]# useradd -s /sbin/nologin mysql
[iyunv@bright ~]# tar zxvf mysql-5.7.6-m16-linux-glibc2.5-x86_64.tar.gz
[iyunv@bright ~]# cd /usr/local/
[iyunv@bright local]# mv /root/mysql-5.7.6-m16-linux-glibc2.5-x86_64 .
[iyunv@bright local]# ln -s mysql-5.7.6-m16-linux-glibc2.5-x86_64 mysql
[iyunv@bright local]# cd mysql
[iyunv@bright mysql]# mkdir /data/mysql
[iyunv@bright mysql]# chown -R root .
[iyunv@bright mysql]# chown -R mysql /data/mysql
[iyunv@bright mysql]# chgrp -R mysql .
[iyunv@bright mysql]# bin/mysql_install_db --user=mysql --datadir=/data/mysql
[iyunv@bright mysql]# cp support-files/my-default.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[iyunv@bright mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[iyunv@bright mysql]# chmod 755 /etc/init.d/mysqld
[iyunv@bright mysql]# vim /etc/init.d/mysqld
[iyunv@bright mysql]# chkconfig --add mysqld
[iyunv@bright mysql]# service mysqld start
Starting MySQL. SUCCESS!




二、安装Apache

Centos6 yum安装的apr版本已经不适用httpd-2.4版本了。所以,需要源码编译apr以及apr-util
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.1.tar.gz
2.1    安装apr
1
2
3
4
[iyunv@bright ~]# tar zxvf apr-util-1.5.4.tar.gz
[iyunv@bright ~]# cd apr-1.5.1
[iyunv@bright apr-1.5.1]# ./configure --prefix=/usr/local/apr
[iyunv@bright apr-1.5.1]# make && make install



2.2    安装apr-util
1
2
3
4
[iyunv@bright ~]# cd apr-util-1.5.4
[iyunv@bright apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[iyunv@bright apr-util-1.5.4]# make && make install
[iyunv@bright apr-util-1.5.4]# echo $?



2.3    安装Apache
检查开发环境,没有的直接yum

1
2
3
4
5
[iyunv@bright ~]# rpm -q gcc cmake pcre-devel
gcc-4.4.7-11.el6.x86_64
cmake-2.8.12.2-4.el6.x86_64
package pcre-devel is not installed
[iyunv@bright ~]# yum install pcre-devel



安装:
1
2
3
4
5
6
7
8
[iyunv@bright ~]# tar -zxvf httpd-2.4.10.tar.gz
[iyunv@bright ~]# cd httpd-2.4.10
[iyunv@bright httpd-2.4.10]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre --enable-mods-shared=most
[iyunv@bright httpd-2.4.10]# make && make install
[iyunv@bright ~]# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
[iyunv@bright ~]# ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd
[iyunv@bright ~]# vi /etc/rc.d/init.d/httpd
[iyunv@bright ~]# chkconfig --add httpd




三、安装PHP
wget http://mirrors.sohu.com/php/php-5.6.6.tar.gz
wget ftp://mcrypt.hellug.gr/pub/crypt ... mcrypt-2.5.6.tar.gz
3.1    检查开发环境,没有的直接yum
(如有某某.so,.h文件无法找到,用yum provides "*/*.h"去查找)
1
2
3
4
5
6
7
8
9
[iyunv@bright ~]# rpm -q libxml2-devel libjpeg-turbo libpng-devel freetype-devel gd-devel libmcrypt-devel openssl-devel
libxml2-devel-2.7.6-14.el6_5.2.x86_64
libjpeg-turbo-1.2.1-3.el6_5.x86_64
libpng-devel-1.2.49-1.el6_2.x86_64
freetype-devel-2.3.11-14.el6_3.1.x86_64
package gd-devel is not installed
package libmcrypt-devel is not installed
openssl-devel-1.0.1e-30.el6.x86_64
[iyunv@bright ~]# yum install gd-devel



3.2    Centos6 默认的yum源没有libmcrypt-devel 这个包,只能借助第三方yum源,本案tar包安装
1
2
3
4
[iyunv@bright ~]# tar zxvf libmcrypt-2.5.6.tar.gz
[iyunv@bright ~]# cd libmcrypt-2.5.6
[iyunv@bright libmcrypt-2.5.6]# ./configure --prefix=/usr/local/libmcrypt
[iyunv@bright libmcrypt-2.5.6]# make && make install



3.3    安装php
1
2
3
4
5
6
[iyunv@bright ~]# tar zxvf php-5.6.6.tar.gz
[iyunv@bright ~]# cd php-5.6.6
[iyunv@bright php-5.6.6]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt=/usr/local/libmcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6
[iyunv@bright php-5.6.6]# make && make install
[iyunv@bright php-5.6.6]# echo $?
0



四、配置apache和php与测试

1.修改AddType参数
1
2
3
4
5
6
7
8
[iyunv@bright ~]# vi /usr/local/apache2/conf/httpd.conf   
[iyunv@bright ~]# cat /usr/local/apache2/conf/httpd.conf | grep AddType | grep -v ^$ | grep -v ^#
    # AddType allows you to add to or override the MIME configuration
    #AddType application/x-gzip .tgz
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz             #在本行下面新增下行
    AddType application/x-httpd-php .php            #增加的内容
    #AddType text/html .shtml



wKioL1UVh8DC4ucVAABczNLC9rw534.jpg
2.修改DirectoryIndex 参数
1
2
3
[iyunv@bright ~]# cat /usr/local/apache2/conf/httpd.conf | grep index.html | grep -v ^$
#    DirectoryIndex index.html
    DirectoryIndex index.html index.htm index.php   #修改后的内容



wKiom1UVhp-QWvW2AACMYeCK1H0762.jpg
3.修改ServerName参数
1
2
3
4
[iyunv@bright ~]# cat /usr/local/apache2/conf/httpd.conf | grep ServerName| grep -v ^$
# ServerName gives the name and port that the server uses to identify itself.
#ServerName www.example.com:80
ServerName localhost:80                             #修改后的内容




4. 测试解析php
在/usr/local/apache2/htdocs/中创建一个文件,内容如下。
1
2
3
4
5
6
7
[iyunv@bright ~]# cat /usr/local/apache2/htdocs/index.php
<?php
    echo "php解析正常\n";
?>
[iyunv@bright ~]# service httpd restart
[iyunv@bright ~]# curl localhost/index.php
php解析正常




MySQL密码修改之官方文档:
http://dev.mysql.com/doc/refman/5.6/en/alter-user.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-51992-1-1.html 上篇帖子: LAMP之编译安装搭建 下篇帖子: LAMP测试环境搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表