CentOS6.x源码编译搭建LAMP环境(详细教程)
安装apr# tar xf apr-1.4.8.tar.bz
# tar xf apr-1.4.8.tar.bz2
# cd apr-1.4.8
# ./configure --prefix=/usr/local/apr && make -j 2 && make install
安装apr-util
# tar xfapr-util-1.5.1.tar.bz2
# cd apr-util-1.5.1
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr&& make -j 2 && make install
安装sqlite
# tar xf sqlite-autoconf-3080200.tar.gz
# cd sqlite-autoconf-3080200
# ./configure --prefix=/usr/local/sqlite && make -j 2 && make install
安装apache
# tar xf httpd-2.2.25.tar.gz
# cd httpd-2.2.25
#./configure --prefix=/usr/local/apache --enable-so --enable-dav --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr-util/bin/apu-1-config --with-sqlite=/usr/local/sqlite--enable-maintainer-mode --enable-ssl --enable-cgi --enable-rewrite--with-zlib --enable-cgi
# make -j 2 && make install
配置apache启动脚本
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
# chmod +x /etc/init.d/httpd
配置开机自启
# vim /etc/init.d/httpd
# chkconfig: 2345 64 36
# description: Activates/Deactivates all network interfaces configured to
# chkconfig --add httpd
创建启动用户并修改配置文件中的监听域名
# useradd -s /sbin/nologin www
# chown www:www /usr/local/apache/ -R
测试
# /etc/init.d/httpd start
源码编译mysql
# useradd -s /sbin/nologin mysql
# tar xf mysql-5.6.19.tar.gz
# cd mysql-5.6.19
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql
安装
# make -j 2
# make install
配置运行环境
chown mysql:mysql -R /usr/local/mysql/
cp support-files/my-large.cnf /etc/my.cnf cp support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld修改启动脚本参数
vim /etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/usr/local/mysql/data初始化数据库
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql 开启启动
chkconfig --add mysqld
添加客户端命令echo "PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile && source /etc/profile && source /etc/profile
安装PHP
# tar xf php-5.4.14.tar.bz2
# cd php-5.4.14
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql--with-apxs2=/usr/local/apache/bin/apxs--with-config-file-path=/usr/local/php
# make -j 2
# make install
# cp /usr/local/src/php-5.4.14/php.ini-production /usr/local/php/etc/php.ini
# ls /usr/local/apache/modules/
httpd.explibphp5.so
# vin /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php
让apache可以识别php文件
测试lamp环境
# cat /usr/local/apache/htdocs/index.php
<?php
phpinfo();
?>
# vim /usr/local/apache/conf/httpd.conf
页:
[1]