Mysql二进制包安装 yum -y install gcc yum -y install perl-Module-Install cd /usr/local/src wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86.86.tar.gz tar -zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql useradd -s /sbin/nologin mysql cd /usr/local/mysql mkdir /data/mysql -p chown mysql:mysql /data/mysql ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql cp support-files/my-default.cnf /etc/my.cnf cp support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysql chkconfig --add mysqld chkconfig mysqld on service mysqld start //启动服务 ps aux |grep mysqld netstat -tlnp|grep 3306

Mysql源代码安装 yum -y install gcc gcc-c++ ncurses-devel perl cmake autoconf 3. 创建mysql的数据库存放目录 mkdir -p /data/mysql 4、 创建mysql用户及用户组 useradd -r mysql -s /sbin/nologin id mysql 5.设置mysql的数据库存放目录权限 chown -R mysql:mysql /data/mysql 6.编译安装MySQL cd /usr/local/src tar -zxvf mysql-5.6.36.tar.gz cd mysql-5.6.36 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1 echo $? make && make install echo $? 7.配置MySQL 7.1 初始化配置 cd /usr/local/mysql 进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表 scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql 7.2 设置配置文件 \cp ./support-files/my-default.cnf /etc/my.cnf 修改配置文件 vim /etc/my.cnf 改为如下: basedir = /usr/local/mysql datadir = /data/mysql 7.3启动MySQL 添加服务,拷贝服务脚本到init.d目录,并设置开机启动 cp support-files/mysql.server /etc/init.d/mysqld chkconfig mysqld on service mysqld start --启动MySQL ss -nat |grep 3306 LISTEN 0 80 :::3306 :::* 8、设置PATH,要不不能直接调用mysql 修改/etc/profile文件,在文件末尾添加 export PATH=/usr/local/mysql/bin:$PATH 关闭文件,运行下面的命令,让配置立即生效 source /etc/profile Error FATAL ERROR: please install the following Perl modules before executing scripts/mysql_install_db: Data::Dumper 解决:yum -y install autoconf

apache安装 httpd-2.4.33 apr-1.6.3 apr-util-1.6.1

2.下载软件包 wget https://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz -O /usr/local/src/apr-1.6.3.tar.gz wget https://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz -O /usr/local/src/apr-util-1.6.1.tar.gz wget https://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz -O /usr/local/src/httpd-2.4.33.tar.gz

3.依赖包 yum -y install libtool-ltdl-devel.x86_64 expat-devel pcre.x86_64 pcre-devel.x86_64 如无gcc,可将开发工具组装上 rpm -q gcc yum group -y install "Development Tools"

4.编译安装

4.1 解压软件包 cd /usr/local/src/ tar zxvf httpd-2.4.33.tar.gz tar zxvf apr-1.6.3.tar.gz
tar zxf apr-util-1.6.1.tar.gz

4.2 编译安装apr cd apr-1.6.3/ ./configure --prefix=/usr/local/apr echo $? make && make install echo $?

4.3编译安装apr-util cd ../apr-util-1.6.1/ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr echo $? make && make install echo $?

4.4编译安装httpd cd ../httpd-2.4.33/ ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most echo $? make && make install echo $?

4.5防火墙规则设定及selinux状态 systemctl status firewalld.service firewall-cmd --get-default-zone firewall-cmd --zone=public --add-service=http --permanent firewall-cmd --reload

getenforce

4.6启动httpd /usr/local/apache2.4/bin/apachectl start

4.7测试 服务端查看端口 netstat -nltup | grep :80

从宿主机访问

Error 1 xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory #include <expat.h> 解决:yum -y install expat-devel

Error 2 configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ 解决:yum -y install pcre.x86_64 pcre-devel.x86_64

Error 3 collect2: error: ld returned 1 exit status make[2]: *** [htpasswd] Error 1 解决:yum -y install libtool-ltdl-devel.x86_64 注意:如果已经编译过了apr-util,需要重新编译

Error 4 configure: error: no acceptable C compiler found in $PATH 解决:yum group -y install "Development Tools"

httpd配置选项 ./configure
--prefix=/usr/local/apache2.4
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util
--enable-so
--enable-mods-shared=most 报错参考:https://www.jianshu.com/p/ba5d5622e9d8

php安装 2 依赖安装 yum -y install libxml2-devel libpng-devel openssl openssl-devel bzip2 bzip2-devel libjpeg-devel freetype-devel libmcrypt.x86_64 libmcrypt-devel.x86_64

3.编译安装php cd /usr/local/src/ wget http://cn2.php.net/distributions/php-5.6.30.tar.gz tar zxvf php-5.6.30.tar.gz cd 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-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 make && make install echo $? cp php.ini-production /usr/local/php/etc/php.ini

  1. 配置httpd支持php httpd主配置文件/usr/local/apache2.4/conf/httpd.conf vim /usr/local/apache2.4/conf/httpd.conf //修改以下4个地方 ServerName-->我改的localhost Require all denied-->Require all granted AddType application/x-httpd-php .php-->增加这一行 DirectoryIndex index.html index.php-->增加 index.php //修改配置文件后测试语法 /usr/local/apache2.4/bin/apachectl -t //启动服务 /usr/local/apache2.4/bin/apachectl start //重载配置文件 /usr/local/apache2.4/bin/apachectl graceful 查看php模块 /usr/local/php/bin/php -m 查看php的配置路径已经参数 /usr/local/php/bin/php -i |less 5.验证

curl localhost //增加如下内容,验证php解析是否正常 vim /usr/local/apache2.4/htodcs/index.php <?php phpinfo; ?> curl localhost/index.php


Error Cannot find OpenSSL's <evp.h> yum install openssl openssl-devel

configure: error: Please reinstall the BZip2 distribution yum install bzip2 bzip2-devel

configure: error: jpeglib.h not found. yum -y install libjpeg-devel

configure: error: freetype-config not found. yum install freetype-devel

configure: error: mcrypt.h not found. Please reinstall libmcrypt. libmcrypt.x86_64 libmcrypt-devel.x86_64

最化安装后需安装 vim-enhanced epel-release wget sysstat

libtool --finish /usr/local/src/php-5.6.30/libs

apache和php的集合 1修改ServerName Require all denied改为allow 2在 /usr/local/apache2.4/conf/httpd.conf <IfModule mime_module>标签下添加 AddType application/x-httpd-php.php解析php /usr/local/apache2.4/bin/apachectl -t //测试语法 /usr/local/apache2.4/bin/apachectl graceful //重新加载 /usr/local/apache2.4/bin/apachectl start netstat -tnlp