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

Linux笔记:源码安装lamp

[复制链接]

尚未签到

发表于 2015-11-15 12:57:16 | 显示全部楼层 |阅读模式
先检查编译环境
[iyunv@station39 ~]# yum grouplist
需要安装的几组工具
Development Libraries (开发库)
Development Tools (开发工具)
Legacy Software Development (传统软件开发工具)
X Software Development(有些组件在编译过程中要依赖于图形界面,需要用到这里提供的库)
PS:如果某些软件基于图形界面开发,就要考虑此软件是基于KDE开发还是GNOME开发。如果是基于KDE开发,一般使用C++语言,就要调用QT的库 。所对应的开发组件KDE Software Development。如果是基于GNOME开发,一般使用C语言,依赖于GTK2。所对应的开发组件GNOME Software Development。
构建编译环境,我们这里不需要用到图形界面,所以我只需三个开发组件,使用yum安装:
[iyunv@station39 ~]# yum -y groupinstall "Development Libraries" "Development Tools" "Legacy Software Development"
环境构建完毕之后我们就可以编译apache,mysql,php的源码包。
由于mysql的编译过程比较漫长,所以这里我们使用mysql绿色安装方式。
PS:apache目前官方正在维护的版本有三个:1.3系列 (最新版1.3.42)、2.0系列(最新版2.0.64)、 2.2系列(最新版2.2.17)。
这里所要使用到的包我们已经准备好了:
[iyunv@station39 LAMP]# ls
httpd-2.2.17.tar.bz2 mysql-5.1.50-linux-i686-glibc23.tar.gz php-5.3.5.tar.bz2
先安装mysql,这里使用绿色安装方式,直接解压到/usr/local重命名为mysql下即可使用。
[iyunv@station39 LAMP]# tar zxvf mysql-5.1.50-linux-i686-glibc23.tar.gz -C /usr/local
[iyunv@station39 LAMP]# cd /usr/local
[iyunv@station39 local]# ls
bin etc games include lib libexec mysql-5.1.50-linux-i686-glibc23 sbin share src
这里需要重命名mysql,但是不建议这么做,我们可以做一个软链接过去
[iyunv@station39 local]# ln -sv mysql-5.1.50-linux-i686-glibc23 mysql
[iyunv@station39 local]# ll
lrwxrwxrwx 1 root root 31 Mar 10 12:00 mysql -> mysql-5.1.50-linux-i686-glibc23
建议使用前先阅读INSTALL-BINARY文件。
[iyunv@station39 mysql]# groupadd -g 306 -r mysql
[iyunv@station39 mysql]# useradd -g mysql -u 306 -r -s /sbin/nologin -M mysql
[iyunv@station39 mysql]# id mysql
uid=306(mysql) gid=306(mysql) groups=306(mysql) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[iyunv@station39 mysql]# chown -R mysql:mysql .
初始化mysql数据库
[iyunv@station39 mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h station39.example.com password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
[iyunv@station39 mysql]# chown -R root .
[iyunv@station39 mysql]# chown -R mysql data/
启动mysql
[iyunv@station39 mysql]# bin/mysqld_safe --user=mysql &
[iyunv@station39 mysql]# netstat -ntlp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 23423/mysqld
将启动命令加入到环境变量里边
[iyunv@station39 mysql]# vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin //**line 44
[iyunv@station39 mysql]# source /etc/profile
安装完毕之后默认主配置文件是不存在的,但是在support-files 目录下有my.cnf的主配置文件的模板
[iyunv@station39 support-files]# ls
binary-configure config.small.ini my-innodb-heavy-4G.cnf my-small.cnf mysql.server
config.huge.ini magic my-large.cnf mysqld_multi.server ndb-config-2-node.ini
config.medium.ini my-huge.cnf my-medium.cnf mysql-log-rotate
[iyunv@station39 support-files]# cp my-large.cnf /etc/my.cnf
mysql.server 是mysql的启动脚本,复制到/etc/init.d目录下
[iyunv@station39 support-files]# cp mysql.server /etc/init.d/mysqld
加入到chkconfig列表中
[iyunv@station39 support-files]# chkconfig --add mysqld
[iyunv@station39 support-files]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
导出mysql的库文件
[iyunv@station39 support-files]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
重新读取一下库文件
[iyunv@station39 support-files]# ldconfig -v | grep mysql
导出mysql头文件,这里我们建立一个软链接
[iyunv@station39 support-files]# ln -sv /usr/local/mysql/include /usr/include/mysql
OK!至此mysql已经安装完成!下面开始安装httpd。
[iyunv@station39 support-files]# cd /root/LAMP/
[iyunv@station39 LAMP]# tar jxvf httpd-2.2.17.tar.bz2
[iyunv@station39 LAMP]# cd httpd-2.2.17
[iyunv@station39 httpd-2.2.17]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-ssl --enable-track-vars --with-z
[iyunv@station39 httpd-2.2.17]# make
[iyunv@station39 httpd-2.2.17]# make install
apache 启动脚本:/usr/local/apache/bin/apachectl
将启动命令加入到环境变量里边
[iyunv@station39 bin]# vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache/bin
[iyunv@station39 bin]# source /etc/profile
PHP安装
[iyunv@station39 bin]# cd /root/LAMP/
[iyunv@station39 LAMP]# tar jxvf php-5.3.5.tar.bz2
[iyunv@station39 LAMP]# cd php-5.3.5
[iyunv@station39 php-5.3.5]# yum install freetype-devel libpng-devel
[iyunv@station39 php-5.3.5]#./configure --prefix=/usr/local/php--with-apx2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=mysqlnd --enable-mbstring=all
[iyunv@station39 php-5.3.5]# make
[iyunv@station39 php-5.3.5]# make install
环境已经搭建完成,我们来测试一下:
[iyunv@station39 htdocs]# cd /usr/local/apache/htdocs
[iyunv@station39 htdocs]# mv index.html index.php
[iyunv@station39 htdocs]# vim index.php
<html><body><h1>It works!</h1></body></html>
<?php
phpinfo();
?>
编辑 /etc/httpd/httpd.conf 文件
DirectoryIndex index.php index.html //**line 166
AddType application/x-httpd-php .php //**line 309
重启httpd服务
OK!已经可以访问了。
本文出自 “諸葛草廬” 博客,请务必保留此出处http://lyp0909.blog.iyunv.com/508999/521611

运维网声明 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-139509-1-1.html 上篇帖子: LAMP网站架构 下篇帖子: centos6.5 编译安装lamp以及相关错误的解决
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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