以home目录为例,进入/home

cd /home

是否安装gcc与gcc-c++,没有则安装

yum -y install gcc gcc-c++

一、安装Apache

  • 下载httpd
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.39.tar.gz
  • 下载依赖
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
wget https://github.com/libexpat/libexpat/releases/download/R_2_0_1/expat-2.0.1.tar.gz
  • 解压
// 根据自己实际包名解压
tar zxvf apr-1.7.0.tar.gz
tar zxvf apr-util-1.6.1.tar.gz
tar zxvf pcre-8.40.tar.gz
tar zxvf expat-2.0.1.tar.gz
tar zxvf httpd-2.4.39.tar.gz 
  • 安装依赖
    • 安装apr
cd /home/apr-1.7.0
./configure --prefix=/usr/local/apr
make && make install

--prefix=路径    表示安装地址

    • 安装expat
cd /home/expat-2.0.1
./configure
make && make install

注:需要先安装expat,再安装apr-util。安装apr-util可能会报

    • 安装apr-util
cd /home/apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install

--without-名称=路径  表示不包含的

--with-名称=路径     表示包含

    • 安装pcre
cd /home/cd pcre-8.40
./configure --prefix=/usr/local/pcre
make && make install
  • 安装apache
cd /home/httpd-2.4.39
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so --enable-rewrite
make && make install

 

--enable-so    将apache的其它模块设置为动态开启,如果不能动态开启,就需要重新安装了

--enable-rewrite  开启apache重写机制

  • 启动apache
// 启动
/usr/local/apache/bin/apachectl

// 让文件在任意位置可调用
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
// 现在任意位置即可调用httpd来 开启/关闭 apache
// 关闭 service httpd stop // 开启 service httpd start // 重启 service httpd restart

 

 二、安装MySQL

  • 下载mysql
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.43.tar.gz
  • 安装依赖
yum -y install cmake ncurses ncurses-devel autoconf
  • 解压
tar zxvf mysql-5.6.43.tar.gz
  • 为mysql添加用户组
groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
  • 安装MySQL
cd /home/mysql-5.6.43
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install
-DCMAKE_INSTALL_PREFIX  指定mysql的安装地址
-DMYSQL_DATADIR      指定mysql的数据存储地址
  • 配置mysql
cd /usr/local/mysql
cp
support-files/my-default.cnf /etc/my.cnf // 编辑 vi my.cnf // 修改内容 [client] port = 3306 default-character-set=utf8 [mysqld] port = 3306 character_set_server=utf8 skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M socket = /data/mysql/mysql.sock basedir=/data/mysql datadir=/data/mysql/data
// 初始化数据
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/
// 任意位置启动/关闭mysql
cp support-files/mysql.server /etc/init.d/mysqld

service mysqld start
service mysqld restart
service mysqld stop
// 设置root账号的密码
./bin/mysqladmin -u root password 'youpassword'
// 把mysql的相关文件 改为mysql组的mysql用户
chown -R mysql:mysql /usr/local/mysql
chown mysql:mysql /etc/my.cnf

三、安装PHP

  • 下载php
wget https://www.php.net/distributions/php-7.1.13.tar.gz
  • 安装依赖
yum -y install jpeg8 gd libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
  • 安装php
tar zxvf php-7.1.13.tar.gz
cd /home/php-7.1.13
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-xml --enable-pdo --enable-mbstring=all --enable-mbregex --enable-shared
make && make install

参数作用,详见:https://www.cnblogs.com/hubing/p/3735452.html

  • 添加apache与php交互
vi /usr/local/apache/conf/httpd.cnf

151行后添加如下内容

AddType application/x-httpd-php .php
  • 添加配置文件
// 拷贝配置文件到安装目录
cp ./php.ini-development /usr/local/php/etc/php.ini

在/usr/local/apache/htdocs/添加一个php文件,启动apache,能解析配置成功

posted on 2019-04-17 14:26  stars523  阅读(1615)  评论(0编辑  收藏  举报