最小化安装的linux-LAMP搭建

1、最小化安装linux
安装完成后,设置selinux为disable,关闭iptables,关闭NetworkManager,设置安装光盘为本地yum源
过程略。
2、安装mysql
安装gcc-c++和gdb、安装cmake、安装ncurses、安装bison、安装perl
yum install gcc-c++ gdb cmake ncurses ncurses-devel bison bison-devel
cd /usr/src/
下载mysql的源码包http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.26.tar.gz
解包tar xf mysql-5.6.26.tar.gz
cd mysql-5.6.26
编译安装mysql
生成Makefile,
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
编译&安装
make && make install
确认安装结果
ls /usr/local/mysql

配置MySQL
1)配置用户
使用下面的命令查看是否有mysql用户及用户组
cat /etc/passwd 查看用户列表
cat /etc/group 查看用户组列表
如果没有就创建
groupadd mysql
useradd -r -g mysql mysql
确认一下创建结果
id mysql
修改/usr/local/mysql目录权限
chown -R mysql:mysql /usr/local/mysql
2)初始化配置
安装运行MySQL测试脚本需要的perl
yum install perl
进入安装路径
cd /usr/local/mysql
执行初始化配置脚本,创建系统自带的数据库和表
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
将mysqld设置为系统独立服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
给mysql设置密码
/usr/local/mysql/bin/mysqladmin -u root password 'abc@1234'
/usr/local/mysql/bin/mysqladmin -u root -h zabbix password 'new-password'
启动mysql服务
/usr/local/mysql/bin/mysqld_safe &
找不到则会搜索"$basedir/my.cnf",本例中是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置
3)启动MySQL
添加服务,拷贝服务脚本到init.d目录,并设置开机启动
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start --启动MySQL

3、安装apache
下载源码包和依赖包
必须安装APR、APR-Util、PCRE,gcc-c++
cd /usr/src
wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.16-deps.tar.gz
wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.16.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
分别解压
find /usr/src/ -name "*.tar.gz" | xargs -n 1 tar xf
安装apr
cd /usr/src/httpd-2.4.16/srclib/apr
./configure --prefix=/usr/local/apr
编译&安装
make && make install
安装apr-util
cd ../apr-util/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
编译&安装
make && make install
安装pcre
cd ../pcre-8.37
./configure --prefix=/usr/local/pcre \
--with-apr=/usr/local/apr/bin/apr-1-config \
--with-apr-util=/usr/local/apr-util/bin/apu-1-config
编译&安装
make && make install
安装apache http server
cd ../httpd-2.4.16
./configure --prefix=/usr/local/apache2 \
--with-pcre=/usr/local/pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util
编译&安装
make && make install
检验是否安装成功
ls /usr/local/apache2/
设置权限
chown -R daemon:daemon /usr/local/apache2/
设置apache服务自动启动
在/etc/rc.local的末尾加入一行/usr/local/apache2/bin/apachectl start

4、安装php
安装xz压缩工具
yum -y install xz
下载源码包
cd /usr/src/
wget http://cn2.php.net/get/php-5.6.13.tar.xz/from/this/mirror
tar xf php-5.6.13.tar.xz

下载安装相应的组件
安装jpeg-8d
wget http://www.ijg.org/files/jpegsrc.v8d.tar.gz
tar xf jpegsrc.v8d.tar.gz
cd jpeg-8d/
./configure --prefix=/usr/local/jpeg-8d
make && make install

安装zlib
wget http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz
tar xf zlib-1.2.8.tar.gz
cd zlib-1.2.8
CFLAGS="-O3 -fPIC" ./configure
make && make install

下载libpng
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.18.tar.xz
tar xf libpng-1.6.18.tar.xz
cd libpng-1.6.18
./configure --prefix=/usr/local/libpng

下载freetype
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.6.tar.gz
tar xf freetype-2.6.tar.gz
./configure --prefix=/usr/local/freetype
make && make install

下载gettext
wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.6.tar.xz
tar xf gettext-0.19.6.tar.xz
cd gettext-0.19.6
./configure --prefix=/usr/local/gettext --enable-shared
make && make install

安装autoconf、libtool
yum -y install libtool autoconf
下载libxml2
wget https://git.gnome.org/browse/libxml2/snapshot/libxml2-2.9.2.tar.xz
tar xf libxml2-2.9.2.tar.xz
cd libxml2-2.9.2
依次执行如下命令
libtoolize --force
aclocal
autoheader
automake --force-missing --add-missing
autoconf
./configure --prefix=/usr/local/libxml2 --with-zlib=/usr/local/zlib/
make && make install

安装gdbm
wget ftp://ftp.gnu.org/gnu/gdbm/gdbm-1.11.tar.gz
tar xf gdbm-1.11.tar.gz
cd gdbm-1.11
./configure --prefix=/usr/local/gdbm --enable-shared
make && make install

安装libiconv
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz
cd tar xf libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install

安装gd
wget https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.1.tar.xz
tar xf libgd-2.1.1.tar.xz
cd libgd-2.1.1
./configure --prefix=/usr/local/libgd2 -with-zlib=/usr/local/zlib --with-png=/usr/local/libpng --with-jpeg=/usr/local/jpeg-8d/ --with-freetype=/usr/local/freetype/
make && make install

安装php
tar xf php-5.6.13.tar.xz
cd php-5.6.13
安装php之前需安装libXpm-devel
yum -y install libXpm-devel
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-jpeg-dir=/usr/local/jpeg-8d \
--with-gettext \
--enable-mbstring \
--with-libxml-dir=/usr/local/libxml2 \
--with-png-dir=/usr/local/libpng \
--with-zlib-dir=/usr/local/lib \
--with-gd=/usr/local/libgd2 \
--with-freetype-dir=/usr/local/freetype \
--enable-trace-vars \
--with-mysql=/usr/local/mysql \
--with-gdbm-dir=/usr/local/gdbm \
--with-iconv \
--enable-sockets \
--disable-ipv6 \
--with-xpm-dir=/usr/lib64/libXpm.so \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-fpm

libtool --finish /usr/src/php-5.6.13/libs
make && make install

修改apache的配置文件:
vim /usr/local/apache2/conf/httpd.conf
确保一下字符是否存在
LoadModule php5_module modules/libphp5.so
如果没有就加上
在AddType application/*的下一行添加如下内容
AddType application/x-httpd-php .php

在DirectoryIndex index.html这一行的末尾加入index.php,即变成Directory Index index.html index.php

转载于:https://www.cnblogs.com/wangweirui/p/5066717.html

你可能感兴趣的:(最小化安装的linux-LAMP搭建)