查询Linux系统是多少位
# uname -i
下载
# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz # wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz # wget http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz # wget http://am1.php.net/distributions/php-5.6.30.tar.gz # wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
解压
# tar zxvf httpd-2.4.25.tar.gz # tar zxvf apr-1.5.2.tar.gz # tar zxvf apr-util-1.5.4.tar.gz # tar zxvf php-5.6.30.tar.gz
安装gcc
# yum install gcc -y
源码包安装apr
# cd apr-1.5.2/ # ./configure --prefix=/usr/local/apr # make && make install
源码包安装apr-util
# cd ../apr-util-1.5.4/ # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr # make && make install
源码包安装apache
# cd ../httpd-2.4.25/ # yum install pcre-devel -y # ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most # make && make install
--enable-so 表示启用DSO
DSO的意思是把某些功能以模块(一个功能模块就是一个so文件,这些文件在编译完httpd后会看到)的形式展现出来。
--enable-mods-shared=most表示以共享的方式安装大多数功能模块,安装后会在modules目录下面看到这些文件
查看httpd的目录结构以及modules目录下面的模块文件
# ls /usr/local/apache2.4/
查看加载了哪些模块
# /usr/local/apache2.4/bin/apachectl -M
以上以AH0058开头的行,并不是错误,仅仅是一个警告。可以在配置文件中定义ServerName使其消失。
shared表示模块为共享模块。static表示以静态的形式存在。
动态与静态的区别在于,静态模块直接和主程序绑定在一起。动态的模块都是一个独立存在的文件(modules目录下面的.so文件就是)
安装mysql5.6.36(二进制免编译安装包)
初始化
# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz # mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql # useradd -s /sbin/nologin mysql # cd /usr/local/mysql/ # mkdir -p /data/mysql # chown -R mysql:mysql /data/mysql/ # ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql -bash: ./scripts/mysql_install_db: /usr/bin/perl: 坏的解释器: 没有那个文件或目录 # yum install perl perl-devel -y FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper [root@localhost mysql]# yum list|grep -i perl|grep -i dumper perl-Data-Dumper.x86_64 2.145-3.el7 base perl-XML-Dumper.noarch 0.81-17.el7 base # yum install perl-Data-Dumper.x86_64 -y [root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory [root@localhost mysql]# yum install libaio-devel -y [root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
[root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf cp: overwrite '/etc/my.cnf'? y [root@localhost mysql]# vim /etc/my.cnf
配置启动脚本文件
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld [root@localhost mysql]# chmod 755 /etc/init.d/mysqld [root@localhost mysql]# vim /etc/init.d/mysqld
加入到自启动列表中
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# service mysqld start [root@localhost mysql]# /etc/init.d/mysqld start [root@localhost mysql]# systemctl start mysqld.service [root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql &
[root@localhost mysql]# service mysqld stop [root@localhost mysql]# /etc/init.d/mysqld stop [root@localhost mysql]# systemctl stop mysqld.service [root@localhost mysql]# killall mysqld
安装Mariadb
[root@localhost src]# wget https://downloads.mariadb.com/MariaDB/mariadb-10.2.6/bintar-linux-glibc_214-x86_64/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz [root@localhost src]# tar -zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz [root@localhost src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb [root@localhost mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb --datadir=/data/mariadb [root@localhost mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf [root@localhost mariadb]# vim /usr/local/mariadb/my.cnf //定义basedir和datadir [root@localhost mariadb]# cp support-files/mysql.server /etc/init.d/mariadb [root@localhost mariadb]# vim /etc/init.d/mariadb //定义basedir、datadir、conf [root@localhost mariadb]# /etc/init.d/mariadb start
安装php5
[root@localhost src]# cd php-5.6.30/ [root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
出现以上错误,则如下处理
[root@localhost php-5.6.30]# vi /usr/local/apache2.4/bin/apxs //将第一行改为"#!/usr/bin/perl -w"
[root@localhost php-5.6.30]# yum install libxml2-devel.x86_64 -y
[root@localhost php-5.6.30]# yum install openssl-devel.x86_64 -y
[root@localhost php-5.6.30]# yum install bzip2-devel.x86_64 -y
[root@localhost php-5.6.30]# yum install libjpeg-turbo-devel.x86_64 -y
[root@localhost php-5.6.30]# yum install libpng-devel.x86_64 -y
[root@localhost php-5.6.30]# yum install freetype-devel.x86_64 -y
[root@localhost php-5.6.30]# yum install epel-release -y [root@localhost php-5.6.30]# yum install libmcrypt-devel -y [root@localhost php-5.6.30]# make [root@localhost php-5.6.30]# make install
查看php加载的模块
[root@localhost php-5.6.30]# /usr/local/php/bin/php -m
测试LAMP是否成功
[root@localhost php-5.6.30]# /usr/local/apache2.4/bin/apachectl -t [root@localhost php-5.6.30]# /usr/local/apache2.4/bin/apachectl start [root@localhost php-5.6.30]# netstat -tlnp|grep httpd tcp6 0 0 :::80 :::* LISTEN 67172/httpd [root@localhost php-5.6.30]# curl localhost <html><body><h1>It works!</h1></body></html>
查询apache加载的模块
[root@localhost php-5.6.30]# /usr/local/apache2.4/bin/apachectl -M
apache的配置文件为/usr/local/apache2.4/conf/httpd.conf
[root@localhost php-5.6.30]# vim /usr/local/apache2.4/conf/httpd.conf
查看php的相关信息(包括编译参数,配置文件的路径)
# /usr/local/php/bin/php -i
[root@localhost php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini
安装php7
[root@localhost src]# wget http://tw2.php.net/distributions/php-7.2.1.tar.gz [root@localhost src]# tar -zxvf php-7.2.1.tar.gz [root@localhost src]# cd php-7.2.1/ [root@localhost php-7.2.1]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif [root@localhost php-7.2.1]# make [root@localhost php-7.2.1]# make install