系统:CentOS7
Apache版本:2.4.41
Mysql版本:5.5.62
PHP版本:5.6
Apache安装
1. 安装依赖包
yum install apr-util-devel pcre-devel perl -y
温馨提示:perl要先于Apache安装,不然/usr/local/apache2/bin/apxs文件没有perl路径
2. 下载Apache Httpd Server
wget https://downloads.apache.org//httpd/httpd-2.4.46.tar.gz
3. 解压、安装
tar -xvf httpd-2.4.46.tar.gz
cd httpd-2.4.46
./configure
make
make install
4. 编辑Httpd配置文件
vi /usr/local/apache2/conf/httpd.conf
加入以下代码:
ServerName local:80
Mysql安装
1. 安装依赖包
yum install cmake ncurses-devel gcc-c++ bison -y
2. 下载、解压、安装
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
tar -xvf mysql-5.5.62.tar.gz
cd mysql-5.5.62
cmake .
make
make install
3. 配置服务启动
cd /usr/local/mysql
cp support-files/my-large.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
useradd mysql
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
ln /usr/local/mysql/bin/* /usr/bin -s
PHP安装
1. 安装依赖包
yum install libxml2-devel -y
2. 下载
wget https://www.php.net/distributions/php-5.6.40.tar.gz
3. 解压、安装
tar -xvf php-5.6.40.tar.gz
cd php-5.6.40
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
make
make install
cp php.ini-production /usr/local/php/lib/php.ini
4. 整合Apache
vi /usr/local/apache2/conf/httpd.conf
加入以下代码:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html
5. 启动服务、关闭防火墙
/usr/local/apache2/bin/apachectl start
systemctl start mysqld
systemctl stop firewalld