感谢MK老师提供技术指导以及资料、视频
特别鸣谢步行街同学一路陪伴,耐心指导
拷贝源码包
[[email protected] ~]# [email protected]:/Users/duwen/Desktop/LAMP/apr-1.5.2.tar.gz /root The authenticity of host‘10.211.55.2 (10.211.55.2)‘ can‘t be established. RSA key fingerprint is d6:3c:6e:2f:5d:46:c0:70:8b:a4:2f:40:d6:d5:3e:36. Are you sure you want tocontinue connecting (yes/no)? yes Warning: Permanently added‘10.211.55.2‘ (RSA) to the list of known hosts. Password: apr-1.5.2.tar.gz 100%1007KB 1.0MB/s 00:00 [[email protected] ~]# [email protected]:/Users/duwen/Desktop/LAMP/apr-util-1.5.4.tar.gz /root Password: apr-util-1.5.4.tar.gz 100% 854KB 853.6KB/s 00:00 [[email protected] ~]# [email protected]:/Users/duwen/Desktop/LAMP/boost_1_60_0.tar.gz /root Password: boost_1_60_0.tar.gz 100% 86MB 86.2MB/s 00:01 [[email protected] ~]# [email protected]:/Users/duwen/Desktop/LAMP/httpd-2.4.18.tar.gz /root Password: httpd-2.4.18.tar.gz 100% 6887KB 6.7MB/s 00:00 [[email protected] ~]# [email protected]:/Users/duwen/Desktop/LAMP/mysql-5.7.11.tar.gz /root Password: mysql-5.7.11.tar.gz 100% 47MB 46.9MB/s 00:01 [[email protected] ~]# [email protected]:/Users/duwen/Desktop/LAMP/pcre-8.38.zip /root Password: pcre-8.38.zip 100% 2235KB 2.2MB/s 00:00 [[email protected] ~]# [email protected]:/Users/duwen/Desktop/LAMP/php-7.0.5.tar.gz /root Password: php-7.0.5.tar.gz 100% 17MB 17.3MB/s 00:00 [[email protected] ~]# [[email protected] ~]# ls anaconda-ks.cfg apr-util-1.5.4.tar.gz httpd-2.4.18.tar.gz install.log.syslog pcre-8.38.zip 公共的 视频 文档 音乐 apr-1.5.2.tar.gz boost_1_60_0.tar.gz install.log mysql-5.7.11.tar.gz php-7.0.5.tar.gz 模板 图片 下载 桌面 [[email protected] ~]#
安装依赖包
[[email protected] ~]# tar zxfapr-1.5.2.tar.gz [[email protected] ~]# cdapr-1.5.2 [[email protected] apr-1.5.2]#./configure --prefix=/usr/local/apr [[email protected] apr-1.5.2]#make && make install [[email protected]]# ./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr [[email protected]]# [[email protected]]# [[email protected]]# make && make install ---------------------------------------------------------------------- /usr/bin/install -c -m 644aprutil.exp /usr/local/apr-util/lib /usr/bin/install -c -m 755apu-config.out /usr/local/apr-util/bin/apu-1-config [[email protected]]# [[email protected]]# cd [[email protected] ~]# unzip -opcre-8.38.zip [[email protected] ~]# cdpcre-8.38 [[email protected] pcre-8.38]#./configure --prefix=/usr/local/pcre [[email protected] pcre-8.38]#make [[email protected] pcre-8.38]#make install
安装apache
[[email protected] ~]# tar zxfhttpd-2.4.18.tar.gz -C /usr/local/src/ [[email protected] ~]# cd/usr/local/src/httpd-2.4.18/ [[email protected] httpd-2.4.18]#./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite--enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/--with-pcre=/usr/local/pcre/
[[email protected] httpd-2.4.18]#make -j 4 [[email protected] httpd-2.4.18]#make install
配置文件
[[email protected] httpd-2.4.18]#ls /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf
存放网站的根目录
[[email protected] httpd-2.4.18]#ls /usr/local/apache2/htdocs/ index.html [[email protected] httpd-2.4.18]#
生成启动脚本
[[email protected] httpd-2.4.18]#cp /usr/local/apache2/bin/apachectl /etc/init.d/
//先停止服务,
[[email protected] httpd-2.4.18]#/etc/init.d/httpd stop 停止 httpd: [失败] [[email protected] httpd-2.4.18]#chkconfig httpd off [[email protected] httpd-2.4.18]#
//让apache 开机启动,还要再在apachectl 文件的头部的注释中加两条命令。
[[email protected] httpd-2.4.18]#vim /etc/init.d/apachectl [[email protected] httpd-2.4.18]#head -5 !$ head -5 /etc/init.d/apachectl #!/bin/sh # #chkconfig:2345 64 36 #description:Activates/Deactivatesall network interfaces configured to # Licensed to the ApacheSoftware Foundation (ASF) under one or more [[email protected] httpd-2.4.18]#
设置开机启动
[[email protected] httpd-2.4.18]#cd
[[email protected] ~]# chkconfig--add apachectl
[[email protected] ~]# chkconfig--list apachectl
apachectl 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[[email protected] ~]#
启动阿帕奇
[[email protected] ~]#/etc/init.d/apachectl start
AH00557: httpd:apr_sockaddr_info_get() failed for duwen112
AH00558: httpd: Could notreliably determine the server‘s fully qualified domain name, using 127.0.0.1.Set the ‘ServerName‘ directive globally to suppress this message
[[email protected]2 ~]#
测试一下
源码apache运行身份是daemon rpm安装的httpd运行身份是apache
[[email protected]~]# ps -aux |grep apach Warning:bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ root 3396 0.0 0.2 74872 2248 ? Ss 15:06 0:00 /usr/local/apache2/bin/httpd -k start daemon 3397 0.0 0.4 484668 4704 ? Sl 15:06 0:01 /usr/local/apache2/bin/httpd -k start daemon 3398 0.0 0.4 484668 4704 ? Sl 15:06 0:01 /usr/local/apache2/bin/httpd -k start daemon 3399 0.0 0.4 419132 4208 ? Sl 15:06 0:01 /usr/local/apache2/bin/httpd -k start root 9670 0.0 0.0 103260 844 pts/1 S+ 15:38 0:00 grep apach [[email protected]~]# id daemon uid=2(daemon)gid=2(daemon) 组=2(daemon),1(bin),4(adm),7(lp) [[email protected]~]#
安装MySQL
创建mysql用户
[[email protected]~]# useradd mysql [[email protected]~]# vim /etc/passwd [[email protected]~]# tail -1 !$ tail -1/etc/passwd mysql:x:500:500::/home/mysql:/sbin/nolongin [[email protected]~]#
解压
[[email protected]~]# tar zxf mysql-5.7.11.tar.gz -C /usr/local/src/ [[email protected]~]# cd /usr/local/src/mysql-5.7.11/ [[email protected]]#
安装cmake
//一般是会带的,检查下吧,
[[email protected]]# yum install -y cmake Loadedplugins: product-id, refresh-packagekit, security, subscription-manager Thissystem is not registered to Red Hat Subscription Management. You can usesubscription-manager to register. Settingup Install Process Nopackage cmake available. Error:Nothing to do [[email protected]]# [[email protected]]# rpm -ivh /mnt/Packages/cmake-2.6.4-5.el6.x86_64.rpm warning: /mnt/Packages/cmake-2.6.4-5.el6.x86_64.rpm:Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:cmake ########################################### [100%] [[email protected]]#
开始编译
[[email protected]]# mkdir /server/ [[email protected]]# cd /usr/local//src/mysql-5.7.11/ [[email protected]]# [[email protected]]# cmake -DCMAKE_INSTALL_PREFIX=/server/mysql-5.7 -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=/server/mysql/data-DMYSQL_USER=mysql CMakeError at CMakeLists.txt:21 (CMAKE_MINIMUM_REQUIRED): CMake 2.8.2 or higher is required. You are running version 2.6.4 --Configuring incomplete, errors occurred!
//不知不觉就出错了,我以为是cmake的问题呢!一直弄cmake
[[email protected]]# [email protected]:/Users/duwen/Downloads/cmake-3.3.2-1mgc30.x86_64.rpm /root Password: cmake-3.3.2-1mgc30.x86_64.rpm 100% 7723KB 7.5MB/s 00:00 [[email protected]]# rpm -ivh /root/cmake-3.3.2-1mgc30.x86_64.rpm error:Failed dependencies: emacs-filesystem >= 24.3 isneeded by cmake-3.3.2-1mgc30.x86_64 libarchive.so.13()(64bit) is neededby cmake-3.3.2-1mgc30.x86_64 libc.so.6(GLIBC_2.14)(64bit) isneeded by cmake-3.3.2-1mgc30.x86_64 libc.so.6(GLIBC_2.15)(64bit) isneeded by cmake-3.3.2-1mgc30.x86_64 libform.so.6()(64bit) is needed bycmake-3.3.2-1mgc30.x86_64 libjsoncpp.so.0()(64bit) is neededby cmake-3.3.2-1mgc30.x86_64 libncurses.so.6()(64bit) is neededby cmake-3.3.2-1mgc30.x86_64 libstdc++.so.6(CXXABI_1.3.5)(64bit)is needed by cmake-3.3.2-1mgc30.x86_64 libstdc++.so.6(GLIBCXX_3.4.15)(64bit)is needed by cmake-3.3.2-1mgc30.x86_64 libstdc++.so.6(GLIBCXX_3.4.18)(64bit)is needed by cmake-3.3.2-1mgc30.x86_64 libtinfo.so.6()(64bit) is needed bycmake-3.3.2-1mgc30.x86_64 libz.so.1(ZLIB_1.2.3.3)(64bit) isneeded by cmake-3.3.2-1mgc30.x86_64 [[email protected]]# rpm -e cmake [[email protected]]#
//高版本好像安装不了额,我还是卸载cmake从新安装吧,安装过程就不写了,上面有rpm安装的,就是2.6的
//然后,我觉得可能是包解压不完整、包传输过程丢失数据、包不兼容等等问题,换了mk老师使用的mysql安装包,事实上好像就是包不兼容哈
[[email protected]~]# [[email protected]~]# scp [email protected]:/Users/duwen/Desktop/mysql-5.5.30.tar.gz /root Password: mysql-5.5.30.tar.gz 100% 23MB 23.4MB/s 00:00 [[email protected]~]# tar zxf mysql mysql-5.5.30.tar.gz mysql-5.7.11.tar.gz mysql.txt [[email protected]~]# tar zxf mysql-5.5.30.tar.gz -C /usr/local/src/ [[email protected]~]# cd /usr/local/src/mysql-5.5.30/ [[email protected]]# cmake -DCMAKE_INSTALL_PREFIX=/server/mysql-5.7 -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=/server/mysql/data-DMYSQL_USER=mysql
没有报错了
cmake编译选项的含义:
-DCMAKE_INSTALL_PREFIX=/server/mysql-5.5 #指定 mysql 安装的根目录,只要/server 目录存在就可以了,mysql-5.5在安装时,会自动创建。这个 值可以在服务器启动时,通过--basedir 来设置。 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock #mysql 服务器用于监听的套接字,这个必需是一个绝对路径,默认是/tmp/mysql.sock。在服务器启动时,可通过--socket 来改变。 -DDEFAULT_CHARSET=utf8 设置 mysql 默认使用 utf8 字符集,不指定,默认使用 latin1 西欧字符集。 -DDEFAULT_COLLATION=utf8_general_ci #默认字符校对。 db.opt -DWITH_EXTRA_CHARSETS=all #指定 mysql 扩展字符集支持所有的字符集。默认 mysql 支持所有字符集 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 #静态编译 Myisam、Innobase、Memory 存储引擎到mysql 服务器。这样 mysql 服务器就支持这三 种存储引擎了。 -DWITH_READLINE=1 #支持readline 库 。 -DENABLED_LOCAL_INFILE=1 #允许从本地导入数据 ,启用加载本地数据 -DMYSQL_DATADIR=/server/mysql/data#mysql 数据库存放数据的目录 -DMYSQL_USER=mysql #指定运行mysql 服务的用户 注:具体编译参数参考:http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
make,放个图证明我没有报错
make install
配置mysql运行环境,这个是安装目录
[[email protected]ysql-5.5.30]# chown -R mysql:mysql /server/mysql-5.7/ [[email protected]]# ##修改mysql安装目录的权限,允许mysql用户对mysql数据库文件夹读写
复制mysql配置文件
[[email protected]]# ll my.cnf -rw-r--r--.1 root root 251 8月 9 2013 my.cnf [[email protected]]# mv ./my.cnf ./my.cnf.back [[email protected]]# cd [[email protected]~]# cp /usr/local/src/mysql-5.5.30/support-files/my-large.cnf /etc/my.cnf [[email protected]~]#
设置 mysqld5.5 服务开机启动
[[email protected] ~]# [[email protected] ~]# cp/usr/local/src/mysql-5.5.30/support-files/mysql.server /etc/init.d/mysqld5.5 [[email protected] ~]# chmod +x /etc/init.d/mysqld5.5 [[email protected] ~]# vim /etc/init.d/mysqld5.5 [[email protected] ~]# head -70 /etc/init.d/mysqld5.5 | tail-5 basedir=/server/mysql-5.7 bindir=/server/mysql-5.7/bin if test -z"$datadir" then datadir=/server/mysql-5.7/data [[email protected] ~]#
加入开机启动项
[[email protected]~]# chkconfig mysqld5.5 on [[email protected]~]# chkconfig --list mysqld5.5 mysqld5.5 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 [[email protected]~]#
初始化mysql
[[email protected]~]# cd /usr/local/src/mysql-5.5.30/scripts/ [[email protected]]# chmod +x mysql_install_db [[email protected]]# ./mysql_install_db --defaults-file=/etc/my.cnf--basedir=/server/mysql-5.7 --datadir=/server/mysql-5.7/data --user=mysql
开启mysql并测试登录
设置mysql的root账户密码
安装php
这里用mk安装过的包
[[email protected]~]# ls anaconda-ks.cfg apr-util-1.5.4.tar.gz install.log mysql.txt 公共的 文档 apr-1.5.2 boost_1_60_0.tar.gz install.log.syslog pcre-8.38 模板 下载 apr-1.5.2.tar.gz cmake-3.3.2-1mgc30.x86_64.rpm mysql-5.5.30.tar.gz pcre-8.38.zip 视频 音乐 apr-util-1.5.4 httpd-2.4.18.tar.gz mysql-5.7.11.tar.gz php-7.0.5.tar.gz 图片 桌面 [[email protected]~]# scp [email protected]:/Users/duwen/Desktop/php-5.4.14.tar.bz2 /root Password: php-5.4.14.tar.bz2 100% 11MB 11.4MB/s 00:00 [[email protected]~]#
解压并进入路径
[[email protected] ~]# tar -jxfphp-5.4.14.tar.bz2 -C /usr/local/src/ [[email protected] ~]# cd/usr/local/src/ [[email protected] src]# ls httpd-2.4.18 mysql-5.5.30 mysql-5.7.11 php-5.4.14 [[email protected] src]# cd php-5.4.14/
配置
[[email protected]]# ./configure --prefix=/server/php-5.4--with-mysql=/server/mysql-5.7 --with-apxs2=/usr/local/apache2/bin/apxs--with-config-file-path=/server/php-5.4
配置是成功的,有图有真相
[[email protected]]# make -j 4
//这里有个make test ,这个是个坑运行时间长的不要不要的,mk说是执行echo $?,返回0
[[email protected]]# make install
生成php配置文档
[[email protected]]# cd [[email protected]~]# cp /usr/local/src/php-5.4.14/php.ini-production /server/php-5.4/php.ini [[email protected]~]#
查看服务器原先参数
[[email protected]~]# /server/php-5.4/bin/php -i | grep configure PHPWarning: Unknown: It is not safe to relyon the system‘s timezone settings. You are *required* to use the date.timezonesetting or the date_default_timezone_set() function. In case you used any ofthose methods and you are still getting this warning, you most likelymisspelled the timezone identifier. We selected the timezone ‘UTC‘ for now, butplease set date.timezone to select your timezone. in Unknown on line 0 ConfigureCommand => ‘./configure‘ ‘--prefix=/server/php-5.4‘‘--with-mysql=/server/mysql-5.7‘ ‘--with-apxs2=/usr/local/apache2/bin/apxs‘‘--with-config-file-path=/server/php-5.4‘ [[email protected]~]#
如果一切顺利,会成功一个模块,如图
让阿帕奇支持php
[[email protected]~]# vim /usr/local/apache2/conf/httpd.conf [[email protected]~]#
还有这个
AddTypeapplication/x-httpd-php .php
位置如图
这里是重启Apache,但是出错了
[[email protected] ~]# vim/usr/local/apache2/conf/httpd.conf
[[email protected] ~]#/etc/init.d/apachectl stop
AH00526: Syntax error on line 312 of/usr/local/apache2/conf/httpd.conf:
AddType requires at least twoarguments, a mime type followed by one or more file extensions
[[email protected] ~]# vim/usr/local/apache2/conf/httpd.conf
[[email protected] ~]#/etc/init.d/apachectl stop
AH00526: Syntax error on line 312 of/usr/local/apache2/conf/httpd.conf:
AddType requires at least twoarguments, a mime type followed by one or more file extensions
[[email protected] ~]# vim /usr/local/apache2/conf/httpd.conf
[[email protected] ~]#/etc/init.d/apachectl stop
AH00557: httpd:apr_sockaddr_info_get() failed for duwen112
AH00558: httpd: Could not reliablydetermine the server‘s fully qualified domain name, using 127.0.0.1. Set the ‘ServerName‘directive globally to suppress this message
[[email protected] ~]#
//就上面这个问题百度了好久,看视频查资料NNNN
最后
/usr/local/apache2/conf/httpd.conf中ServerName(或/etc/httpd/conf/httpd.conf)前面的“#”拿掉就好了
重启服务
[[email protected]]# /etc/init.d/apachectl stop
httpd (nopid file) not running
[[email protected]]# /etc/init.d/apachectl start
[[email protected]]#
给php加个东西,等下回来修改,这里先占个位置
测试下