编译安装 Mysql
解决依赖
[root@python ~]# yum install -y cmake ncurses-devel
这些依赖在安装 apache 时候已经安装
编译安装 Mysql
[root@python ~]# tar xf mysql-5.6.26.tar.gz -C /usr/local/src/;cd /usr/local/src/mysql-5.6.26
[root@python mysql-5.6.26]# useradd -M -s /sbin/nologin mysql
[root@python mysql-5.6.26]#cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/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
DWITH_MEMORY_STORAGE_ENGINE
DWITH_READLINE #支持readline 库。
DENABLED_LOCAL_INFILE # 允许本地倒入数据,启用加载本地数据
DMYSQL_DATADIR # mysql数据库存放路径
DMYSQL-USER # 运行mysql的用户
这些编译参数的帮助寻找方法:
http://www.mysql.com→→Documentation→→选择对应的版本(5.6)→→HTML Online→→View→→Installation & Upgrades→→Installing MySQL from Source →→MySQL Source-Configuration Options
http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
//最终的URL
配置 Mysql
[root@python mysql-5.6.26]#ccmake /usr/local/src/mysql-5.6.26/ //除开在线,可以使用本地帮助
[root@python mysql-5.6.26]#make -j 2 ; make install //以2个进程来编译,不要超过CPU核心数
[root@python ~]# cd && chown -R mysql:mysql /usr/local/mysql/
[root@python ~]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf //覆盖原文件
[root@python ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld //启动脚本
[root@python ~]# vim /etc/init.d/mysqld
basedir=
datadir=
#修改为
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
[root@python ~]# chkconfig mysqld on //开机启动
初始化数据库
[root@python ~]# /usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/etc/my.cnf \
--basedir=/usr/local/mysql/\
--datadir=/usr/local/mysql/data/\
--user=mysql
#类似于在rpm安装的时候启动数据库弹出的初始化消息
[root@python ~]#ln -s /usr/local/mysql/bin/* /bin/ //这个里面是部分命令,让系统直接调用
[root@python ~]#servie mysqld start //启动数据库
[root@python ~]#mysql_secure_installation //初始安全设置(设置root密码,qwe123)[记住,编译安装之前,记得除去mysql mysql-devel mysql-libs三个软件]
[root@python ~]# mysql -pqwe123 //测试登陆
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
编译安装 PHP
在 Nginx 中,我们使用的是 php-fpm 来对php 页面解析,PHP-FPM其实是PHP源代码的一个补丁,指在将FastCGI进程管理整合进PHP包中。必须将它patch到你的PHP源代码中,再编译安装PHP后才可以使用。
从PHP5.3.3开始,PHP中直接整合了PHP-FPM,所以从PHP5.3.3版本以后,不需要下载PHP-FPM补丁包了,下面是PHP-FPM官方发出来的通知:
http://php-fpm.org/download
解决依赖
[root@python ~]# yum install php-pear -y
pear按照一定的分类来管理pear应用代码库,你的pear代码可以组织到其中适当的目录中,其他人可以方便的检索并分享到你的成果
pear不仅仅是一个代码仓库,它同时也是一个标准,使用这个标准来书写你的php代码,将会增强你的程序的可读性,复用性,减少出错的几率
Pear通过两个类为你搭建了一个框架,实现了诸如析构函数,错误捕获功能,你通过继承就可以使用这些功能
PHP 添加 libmcrypt 拓展
安装加密算法扩展库
[root@python ~]# tar xf libmcrypt-2.5.8.tar.bz2 -C /usr/local/src/
[root@python ~]# cd /usr/local/src/libmcrypt-2.5.8/
[root@python ~]# ./configure --prefix=/usr/local/libmcrypt ; make ; make install ; cd
[root@python ~]# yum install -y libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype freetype-devel libzip libzip-devel
[root@python ~]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf #此行原有
/usr/local/libmcrypt/lib #此行添加
/usr/local/mysql/lib #此行添加
[root@python ~]# ldconfig
[root@python ~]# echo 'ldconfig'>> /etc/rc.local
编译安装 PHP
[root@python LNMP软件包]# tar xf php-5.6.13.tar.bz2 -C /usr/local/src/
[root@python LNMP软件包]# cd /usr/local/src/php-5.6.13/
[root@python php-5.6.13]#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-mysqlnd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --with-mcrypt=/usr/local/libmcrypt
如果上面在make的时候 提示libzip相关的报错,可以安装下面的方法来解决:
先 执行 make clean
然后 安装压缩支持库
tar xf libzip-1.1.2.tar.gz -C /usr/local/src/
cd /usr/local/src/libzip-1.1.2/
./configure --prefix=/usr/local/libzip && make && make install
再重新编译
配置 php 和 php-fpm
PHP 配置文件:
[root@python ~]# cp /usr/local/src/php-5.6.13/php.ini-production /usr/local/php/php.ini
PHP-FPM配置文件:
[root@python ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
修改 /usr/local/php/etc/php-fpm.conf 运行用户和组改为nginx:
[root@python ~]# ll /usr/local/php/etc/php-fpm.conf
-rw-r--r--. 1 root root 22794 6月 20 16:19 /usr/local/php/etc/php-fpm.conf
[root@python ~]# chown nginx:nginx /usr/local/php/etc/php-fpm.conf
[root@python ~]# ll /usr/local/php/etc/php-fpm.conf
-rw-r--r--. 1 nginx nginx 22794 6月 20 16:19 /usr/local/php/etc/php-fpm.conf
PHP-FPM启动脚本:
[root@python ~]# cp /usr/local/src/php-5.6.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@python ~]# chmod +x /etc/init.d/php-fpm
[root@python ~]# chkconfig php-fpm on
[root@python ~]# /etc/init.d/php-fpm start
Starting php-fpm done
测试LNMP的PHP支持
[root@python ~]# echo "" > /usr/local/nginx/html/index.php
浏览器访问: http://192.168.1.128