CentOS7下安裝配置LAMP詳細教程

一. 關閉CentOS7防火牆和SELinuxphp

1.關閉CentOS7防火牆html

systemctl stop firewalld.service#中止firewall

systemctl disable firewalld.service#禁止firewall開機啓動

2.關閉SElinux安全系統python

vim /etc/selinux/config

將SELINUX=enforcing改成SELINUX=disabled

重啓CentOS

二. yum安裝gcc和gcc-c++編譯工具mysql

yum  install gcc  

yum  install gcc-c++

三. 安裝基礎軟件包linux

1.yum安裝python-develc++

yum -y install python-devel

2.安裝XML程序庫libxml2sql

cd  /libxml2-2.9.1

./configure --prefix=/usr/local/libxml2

make && make install

3.安裝libmcrypt加密擴展庫apache

cd /libmcrypt-2.5.8

./configure --prefix=/usr/local/libmcrypt/

make && make install

4.安裝mhash擴展庫vim

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/downl...

2.在http://apr.apache.org/downloa...

3.在http://pcre.org/下載pcre-8.38...

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/下載boos...

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('123456');

六. 編譯安裝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/ \

--enable-soap \

--with-xpm-dir=/usr/lib64/ \

--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
相關文章
相關標籤/搜索