MYSQL源码编译
解决依赖
[root@python ~]# yum install -y cmake ncurses-devel //gcc等相关在编译apache已安装
编译安装MySql
安装之前使用 yum remove mysql 确保没有安装MySQL
[root@python LAMP软件包]# tar xf mysql-5.6.26.tar.gz -C /usr/local/src/
[root@python LAMP软件包]# cd /usr/local/src/mysql-5.6.26/
[root@python mysql-5.6.26]# useradd -M -s /sbin/nologin mysql //创建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_MYISAM_STORAGE_ENGINE
DWITH_INNOBASE_STORAGE_ENGINE
DWITH_MEMORY_STORAGE_ENGINE
#静态编译MYISAM,INNOBASE,MEMORY存储引擎到MYSQL服务 器,这样MYSQL就支持这三种存储引擎[root@python mysql-5.6.26]#make -j 2 && make install
这些编译参数的帮助寻找方法:
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
配置Mysql
[root@python mysql-5.6.26]# cd && chown -R mysql:mysql /usr/local/mysql/
[root@python ~]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf //覆盖原来文件
cp:是否覆盖"/etc/my.cnf"? y
[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 ~]# ls /usr/local/mysql/data/
auto.cnf ib_logfile0 mysql python.err
ibdata1 ib_logfile1 performance_schema test
[root@python ~]#ln -s /usr/local/mysql/bin/* /bin/ //这个里面是部分命令,让系统直接调用
[root@python ~]# service mysqld start //启动数据库
[root@python ~]# mysql_secure_installation //初始化安全设置
[root@python ~]# mysql -uroot -p123456
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 13
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
PHP原始为Personal Home Page的缩写,已经正式更名为 "PHP: Hypertext Preprocessor"。
Apache对于php的解析,就是通过众多Module中的php Module来完成的,把php最终集成到Apache系统中,还需要对Apache进行一些必要的设置.
解决依赖:
[root@python ~]# yum install -y libxml2-devel
[root@python LAMP软件包]# tar xf php-5.6.13.tar.bz2 -C /usr/local/src/ ; cd /usr/local/src/php-5.6.13
正式安装:
[root@python php-5.6.13]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php
--prefix #指定安装路径
--with-apxs2 #用apache的apxs工具将php编译成apache的一个模块
--with-mysql #与mysql结合,如果不跟路径,编译出来的版本将是低版本
--with-config-file-path #php的主配置文件php.ini路径
看到下面一段内容,表示configure成功
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[root@python php-5.6.13]# make –j 2; make install ; cd /usr/local/src/php-5.6.13
[root@python php-5.6.13]#cp php.ini-production /usr/local/php/php.ini ; cd //php配置文件
检测编译安装结果:
只有有下面这两个文件(模块),代表我们的apache就可以支持php了
[root@python ~]# ls /usr/local/apache2.4/modules/httpd.exp
/usr/local/apache2.4/modules/httpd.exp
[root@python ~]# ls /usr/local/apache2.4/modules/libphp5.so
/usr/local/apache2.4/modules/libphp5.so
配置Apache支持PHP:
[root@python ~]# vim /usr/local/apache2.4/conf/httpd.conf
248
249 DirectoryIndex index.html index.php #添加index.php
250
376 AddType application/x-compress .Z
377 AddType application/x-gzip .gz .tgz #上面两行是以前有的
378 AddType application/x-httpd-php .php #下面两行是添加的,需要添加以支持PHP
379 AddType application/x-httpd-php-source .phps
修改完,重启下Apache服务:
[root@python ~]# /etc/init.d/apache2.4 restart
测试:
[root@python ~]# vim /usr/local/apache2.4/htdocs/index.php
使用客户端浏览此页面: