centos6源码编译安装lamp
扫描二维码
随时随地手机看文章
(笔记 有待测试)
1.安装编译开发环境 (centos7不分组,所以不可以)# yum groupinstall "Development Tools" "Server Platform Development" -y
2.安装pcre(httpd依赖)
# yum install pcre-devel -y
3. 下载安装包(apr,apr-util,httpd-2.4,phpMyAdmin),解压安装(怎么下载,怎么传至centos省略)
# tar xf apr-1.5.0.tar.bz2
# cd apr-1.5.0
# ./configure --prefix=/usr/local/apr(新建apr文件夹)
# make && make install
# tar xf apr-util-1.5.3.tar.bz2
# cd apr-util-1.5.3
# ./configure --prefix=/usr/local/apr-util --with-par=/usr/local/apr(指定apr的位置)
# make && make install
4.解压安装httpd
# tar xf httpd-2.4.10
# cd httpd-2.4.10
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl -enable-cgi --enable-rewrite-with-zlib --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event
# make && make install
(dso机制 模块化 cgi url重写 传输压缩 pcre正则表达式 启用大多数模块 默认event)
5.为方便提供service脚本
# cd /etc/rc.d/init.d/
# cp httpd httpd24
# vim httpd24
修改对应文件路径(参考):
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
pidfile=${PIDFILE-/var/run/httpd/httpd24.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
保存退出。
6.测试httpd
# httpd -t 显示 Syntax OK
# hash -r 移除所有缓存
# vim /etc/profile.d/httpd.sh(创建)
export PATH=/usr/local/apache/bin:$PATH
保存退出
# . /etc/profile.d/httpd.sh (执行)
# httpd -t 显示 Syntax OK
# hash
显示 hits comand
1 /usr/local/apache/bin/httpd
# service httpd24 start
显示 Start httpd: [OK]
# ss -tnl
: : : 80 (被监听)
# ps aux | grep httpd
# httpd -M (查看 mpm_event_module 是否启动)
7.安装mariadb
下载mariadb-5.5.44.tar
# tar xf mariadb-5.5.44.tar.gz -C /usr/local
# mkdir -pv /mydata/data (存放数据库数据)
# useradd -r mysql
# chown -R mysql.mysql /mydata/data/
# cd /usr/local
# ln -sv mariadb-5.5.44 mysql (链接至mysql)
# cd mysql
# chown -R root.mysql ./*
# scripts/mysql_install_db --datadir=/mydata/data/ --user=mysql
# mkdir /etc/mysql
# cp support-files/my-large.cnf /etc/mysql/my.cnf
# vim my.cnf
The MariaDB server下添加:
datadir=/mydata/data
innodb_file_per_table=on
skip_name_resolve=on
保存退出
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# server mysqld start
# ss -tnl (查看3306口是否开启)
# /usr/local/mysql/bin/mysql (查看MariaDB可用)
8.下载安装php
配置依赖关系:
# yum -y groupinstall "Desktop Platform Development"
# yum -y install bzip2-devel libmcrypt-devel libxml2-devel
# tar xf php-5.4.26.tar.bz2
# cd 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-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enablesockets --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-zts
提示什么没安装 就安装“什么—devel”包,然后重新./configure
# make && make install (多开线程 -j)
为php提供配置文件
# cp php.ini-production /etc/php.ini
编辑apache配置文件httpd.conf ,以apache支持php
# vim /etc/httpd/httpd.conf
添加如下二行:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
定位至DirectoryIndex index.html修改为:
DirectoryIndex index.php index.html
重启httpd