CentOS7下安装配置LAMP详细教程
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7下安装配置LAMP详细教程相关的知识,希望对你有一定的参考价值。
一. 关闭CentOS7防火墙和SELinux
1.关闭CentOS7防火墙
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动
2.关闭SElinux安全系统
vim /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled
重启CentOS
二. yum安装gcc和gcc-c++编译工具
yum install gcc
yum install gcc-c++
三. 安装基础软件包
1.yum安装python-devel
yum -y install python-devel
2.安装XML程序库libxml2
cd /libxml2-2.9.1
./configure --prefix=/usr/local/libxml2
make
make install
3.安装libmcrypt加密扩展库
cd /libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt/
make
make install
4.安装mhash扩展库
cd /mhash-0.9.9.9
./configure
make
make install
5.安装mhash扩展库
cd /ftp/mcrypt-2.6.8
LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib
./configure --with-libmcrypt-prefix=/usr/local/libmcrypt
make
make install
6.安装zlib压缩函式库
cd /zlib-1.2.8
./configure
make
make install
7.安装图片处理函数库libpng
cd /libpng-1.5.26
./configure --prefix=/usr/local/libpng/
make
make install
8.安装图片处理函数库libjpeg
mkdir /usr/local/jpeg9
mkdir /usr/local/jpeg9/bin
mkdir /usr/local/jpeg9/lib
mkdir /usr/local/jpeg9/include
mkdir -p /usr/local/jpeg6/man/man1
cd /jpeg-9
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
9.安装freetype
cd /freetype-2.6.3
./configure --prefix=/usr/local/freetype/
make
make install
10.安装GD库
cd /libgd-2.1.1
vim gd_png.c(修改#include "png.h"为#include "/usr/local/libpng/include/png.h")
./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg9/
--with-freetype=/usr/local/freetype/ --with-png=/usr/local/libpng/
make
make install
11.安装curl库
cd curl-7.48.0
./configure --prefix=/usr/local/curl
make
make install
四. 安装apache
1.在http://httpd.apache.org/download.cgi下载httpd-2.4.18.tar.gz
2.在http://apr.apache.org/download.cgi下载apr-1.5.2.tar.gz和apr-util-1.5.4.tar.gz
3.在http://pcre.org/下载pcre-8.38.tar.gz
tar -zxvf apr-1.5.2.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
tar -zxvf httpd-2.4.18.tar.gz
cp -r apr-1.5.2 httpd-2.4.18/srclib/apr
cp -r apr-util-1.5.4 httpd-2.4.18/srclib/apr-util
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make
make install
4.安装apache
cd /httpd-2.4.18
./configure --prefix=/usr/local/apache2/ \
--sysconfdir=/usr/local/apache2/etc/ \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared
make
make install
五. 编译安装mysql
1.yum安装cmake和ncurses库
yum -y install ncurses-devel
yum -y install cmake bison
2.创建mysql系统用户
groupadd mysql
useradd -r -g mysql mysql
3.在http://www.boost.org/下载boost库(mysql5.7.11必须使用boost_1_59_0.tar.gz)
tar -zvxf boost_1_59_0.tar.gz
mkdir /usr/local/boost
cp -rf ./boost_1_59_0 /usr/local/boost
4.cmake编译安装mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_BOOST=/usr/local/boost \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
make
make install
5.mysql目录权限配置及初始化
cd /usr/local/mysql
mkdir -p /var/mysql/data
./bin/mysqld --initialize \
--user=mysql \
--datadir=/var/mysql/data \
--basedir=/usr/local/mysql \
--socket=/tmp/mysql.sock
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf
添加:port=3306
basedir=/usr/local/mysql
datadir=/var/mysql/data
socket=/tmp/mysql.sock
log-error = /var/log/mysql-error.log
#启动mysql修改密码
/usr/local/mysql/bin/mysqld_safe --user=mysql &
/usr/local/mysql/bin/mysql --user=root --password=初始密码
set password=password(‘161718hsq‘);
六. 编译安装php
yum install openssl openssl-devel
yum install libXpm-devel
1.rpm -ql libXpm :查询出libXpm的安装位置,发现在/usr/lib64/ 下
2.重新编译php,./configure中增加 --with-xpm-dir=/usr/lib64/
cd php-7.0.4
./configure --prefix=/usr/local/php/ \
--with-config-file-path=/usr/local/php/etc/ \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-libxml-dir=/usr/local/libxml2/ \
--with-jpeg-dir=/usr/local/jpeg9/ \
--with-png-dir=/usr/local/libpng/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-soap \
--with-curl=/usr/local/curl\
--with-openssl\
--enable-mbstring=all \
--enable-sockets \
--enable-mysqlnd\
--with-mysqli=mysqlnd\
--with-pdo-mysql=mysqlnd\
--with-zlib \
--enable-ftp
make
make install
cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/apache2/etc/httpd.conf
#修改apache配置文件 AddType application/x-httpd-php .php .phtml .phps
/usr/local/apache2/bin/apachectl start
本文出自 “残梦” 博客,谢绝转载!
以上是关于CentOS7下安装配置LAMP详细教程的主要内容,如果未能解决你的问题,请参考以下文章