httpd 2.4.9 + mysql-5.5.33 + php-5.4.26编译安装
LAMP可以理解为由Linux,Apache,MySQL,PHP组成的Web服务器架构。以下是在linux系统上安装MySQL.Apache.PHP的过程
一 安装mysql
1 准备环境下载安装包 mysql-5.5.33-linux2.6-x86_64.tar.gz
安装包组 "Develoment tools","Server Platform Developmet"
2 解压软件包,创建链接
[root@localhost ~]# tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz -C /usr/local/ [root@localhost ~]# cd /usr/local/ [root@localhost local]# ln -sv mysql-5.5.33-linux2.6-x86_64/ mysq
3 创建mysql组和用户
[root@localhost local]# groupadd -r mysql [root@localhost local]# uaeradd -g mysql -r -s /sbin/nologin mysql
4 创建/data目录,提供设备
[root@localhost mysql]# mkdir /data [root@localhost mysql]# fdisk /dev/sda [root@localhost mysql]# kpartx -af /dev/sda [root@localhost mysql]# partx -a /dev/sda [root@localhost mysql]# cat /proc/partitions major minor #blocks name 8 0 125829120 sda 8 1 204800 sda1 8 2 62914560 sda2 8 3 20979891 sda3 253 0 20971520 dm-0 253 1 2097152 dm-1 253 2 10485760 dm-2 253 3 20971520 dm-3 [root@localhost mysql]# pvcreate /dev/sda3 [root@localhost mysql]# vgcreate myvg /dev/sda3 [root@localhost mysql]# lvcreate -L 10G -n mydata myvg 格式化 [root@localhost mysql]# mke2fs -t ext4 /dev/myvg/mydata 实现开机自动挂载 [root@localhost mysql]# vim /etc/fstab
#切换到/data下,修改属主属组 [root@localhost mysql]# cd /data [root@localhost data]# mkdir mydata [root@localhost data]# chown -R mysql.mysql mydata/
#修改/usr/local/mysql下文件属主属组 [root@localhost data]# cd /usr/local/mysql [root@localhost mysql]# chown -R root.mysql ./*5 初始化
#初始化 [root@localhost mysql]# scripts/mysql_install_db --datadir=/data/mydata --user=mysql
6 配置文件
#查看/data/mydata目录下,有文件生成,初始化成功 [root@localhost mysql]# ls /data/mydata/ mysql performance_schema test
#提供服务脚本 [root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld [root@localhost mysql]# chkconfig --add mysqld [root@localhost mysql]# chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#提供配置文件 [root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf
#修改配置文件 [root@localhost mysql]# vim /etc/my.cnf # Try number of CPU‘s*2 for thread_concurrency thread_concurrency = 4 datadir=/data/mydata
不修改配置文件会启动服务不成功,如下
[root@localhost mysql]# service mysqld start Starting MySQL.The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).[FAILED]
7 检查是否安装成功
尝试启动服务 [root@localhost mysql]# vim /etc/my.cnf [root@localhost mysql]# service mysqld start Starting MySQL... [ OK ] 启动成功,查看/data/mydata下,生成相关文件 [root@localhost mysql]# ls /data/mydata ibdata1 ib_logfile1 localhost.localdomain.pid mysql-bin.000001 performance_schema ib_logfile0 localhost.localdomain.err mysql mysql-bin.index test /tmp目录下会生成套接字文件 mysql.sock [root@localhost mysql]# ls /tmp ks-script-ANevh6 ks-script-ANevh6.log mysql.sock yum.log
8 导出环境变量
编辑PATH环境变量文件 [root@localhost mysql]# vim /etc/profile.d/mysql.sh export PATH=/usr/local/mysql/bin:$PATH [root@localhost mysql]# . /etc/profile.d/mysql.sh
此时mysql命令就可以用了,工作中,此时要删除匿名用户和进行加密。此处暂不叙
9 MySQL已配置完成。导出头文件和库文件,准备安装PHP[root@localhost mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql `/usr/include/mysql‘ -> `/usr/local/mysql/include/‘ [root@localhost mysql]# vim /etc/ld.so.conf.d/mysql.conf #/usr/local/mysql/lib [root@localhost mysql]# ldconfig [root@localhost mysql]# ldconfig -p | grep mysql libtcmalloc_minimal.so.0 (libc6,x86-64) => /usr/local/mysql/lib/libtcmalloc_minimal.so.0 libmysqlclient_r.so.16 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient_r.so.16 libmysqlclient.so.18 (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so.18 libmysqlclient.so.16 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.16 libmysqlclient.so (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so
二 安装httpd
1 做准备工作
下载软件包,相关包组已安装,解决依赖关系。
安装pcre支包
[root@localhost ~]# yum install pcre-devel -y
2 安装apr-1.5.0
[root@localhost ~]# tar xf apr-1.5.0.tar.bz2 [root@localhost ~]# cd apr-1.5.0 [root@localhost apr-1.5.0]# ./configure --prefix=/usr/local/apr [root@localhost apr-1.5.0]# make && make install
3 安装apr-util-1.5.3
[root@localhost ~]# tar xf apr-util-1.5.3.tar.bz2 [root@localhost ~]# cd apr-util-1.5.3 [root@localhost apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr [root@localhost apr-util-1.5.3]# make && make installanzhuang
4 安装httpd-2.4.9
[root@localhost ~]# tar xf httpd-2.4.9.tar.bz2 [root@localhost ~]# cd httpd-2.4.9 [root@localhost httpd-2.4.9]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event --enable-deflate --enable-expire [root@localhost httpd-2.4.9]# make && make install
5 编辑主配置文件
[root@localhost ~]# vim /etc/httpd/httpd.conf
ServerRoot"/usr/local/apache"下面添加 PidFile"/var/run/http.pid
6 提供服务脚本
[root@localhost ~]# vim /etc/init.d/httpd24 [root@localhost ~]# . /etc/profile.d/httpd24.sh [root@localhost ~]# chkconfig --add httpd24 [root@localhost ~]# chkconfig --list httpd24
7 编辑PATH环境变量文件
[root@localhost ~]# . /etc/profile.d/httpd24.sh #export PATH=/use/local/apache/bin:$PATH root@localhost ~]# . /etc/profile.d/httpd24.sh
三 安装PHP
1 下载软件包,解决依赖关系
[root@localhost ~]# yum install libmcrypt-devel
[root@localhost ~]# yum install -y bzip2-devel
[root@localhost ~]# yum groupinstall "Desktop Platform Development"
2 编译安装php-5.4.26
[root@localhost php-5.4.26]# tar xf php-5.4.26.tar.bz2 [root@localhost php-5.4.26]# cd php-5.4.26 [root@localhost php-5.4.26]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-libxml-dir=/usr --with-png-dir --with-zlib --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc/ --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts3提供php
[root@localhost php-5.4.26]# make [root@localhost php-5.4.26]# make test [root@localhost php-5.4.26]# make install
3 提供配置文件
[root@localhost php-5.4.26]# cp php.ini-production /etc/php.ini
4 编辑apache的配置文件,支持php
[root@localhost php-5.4.26]# vim /etc/httpd/httpd.conf
a 添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
b DirectoryIndex index.html 中间添加 index.php
5 测试
在/usr/local/apache/htdocs目录下
[root@localhost htdocs]# cp index.html index.php [root@localhost htdocs]# vim index.php <?php phpinfo(); ?>
重启httpd 浏览器页面测试
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。