编译安装Apache 2.4.33
修改默认yum源
cd /etc/yum/repo.d
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
mv CentOS-Base.repo CentOS-Base.repo.bak
mv CentOS-Base-163.repo CentOS-Base.repo
1、卸载系统自带的Apache
rpm -qa | grep httpd
rpm -e --nodeps 软件包名
2、创建软件存放目录及安装开发包组软件
yum groupinstall "Development tools" -y
3、安装apr、apr-util、pcre依赖包
yum install apr-devel apr-util-devel pcre-devel openssl-devel -y
4、下载文件
wget http://archive.apache.org/dist/httpd/httpd-2.4.29.tar.gz
5、解压文件
tar -xzvf httpd-2.4.29.tar.gz
6、编译与安装
./configure --prefix=/usr/local/apache2 --enable-modules=all --enable-mods-shared=all --enable-so --enable-rewrite
make && make install
7、启动服务
/usr/local/apache2/bin/apachectl start
8、修改域名设置
vim /usr/local/apache2/conf/httpd.conf
修改servername 为127.0.0.1:80
9、域名目录
echo "test index" > /usr/local/apache2/htdocs/index.html
10、访问测试
curl localhost
编译安装Mysql 5.7.31
1、下载软件包
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
2、安装开发依赖包
yum install zlib-devel gcc-c++ ncurses-devel libaio libaio-devel -y
yum remove mariadb-libs -y
3、安装mysql
useradd mysql -s /sbin/nologin -M
mkdir /mysql/data -p
chown -R mysql.mysql /mysql/
tar -xzvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz -C /usr/local
ln -s /usr/local/mysql-5.7.31-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
4、初始化
./bin/mysqld --initialize --basedir=/usr/local/mysql --datadir=/mysql/data/ --user=mysql
vim /etc/init.d/mysqld
5、添加环境变量
echo 'export PATH=$PATH:/usr/local/mysql/bin' >>/etc/profile && source /etc/profile
/etc/init.d/mysqld start
6、修改密码开启远程访问
alter user 'root'@'localhost' IDENTIFIED BY '520521.....dQ';
use mysql;
update user set Host='%' where User='root';
flush privileges;
编译安装PHP
1、检查基础环境
ls -ld /usr/local/apache2
ls -ld /usr/local/mysql
2、检查apache和mysql是否运行
ps -ef | grep httpd
ps -ef | grep mysqld
lsof -i :80
3、安装php所需的库文件
yum install gcc zlib libjpeg freetype libpng
gd curl zlib-devel libxml2 libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel openssl-devel libxslt-devel -y
4、安装php
tar -xzvf php-5.5.14.tar.gz
cd php-5.5.14
./configure \
--prefix=/usr/local/php-5.5.14 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-xmlrpc \
--with-openssl \
--with-zlib \
--with-freetype-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--enable-short-tags \
--enable-sockets \
--enable-zend-multibyte \
--enable-soap \
--enable-mbstring \
--enable-static \
--enable-gd-native-ttf \
--with-curl \
--with-xsl \
--enable-ftp \
--with-libxml2-dir
cd /usr/local/mysql/lib
ln -s libmysqlclient.so.20.3.18 libmysqlclient_r.so
make && make install
5、建立软链接
ln -s /usr/local/php-5.5.14 /usr/local/php
6、复制配置文件到安装目录
cd ..
cp php-5.5.14/php.ini-production /usr/local/php/lib/php.ini
7、配置apache支持php程序
cd /usr/local/apache2/conf
cp httpd.conf httpd.conf.bak
vim httpd.conf
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
User php
Group php
useradd php -s /sbin/nologin -M
<Ifmodule dir_module>
DirectoryIndex index.php index.html
</Ifmodule>
8、重启apache
/usr/local/apache2/bin/apachectl -t
/usr/local/apache2/bin/apachectl graceful
9、测试php
echo "" > /usr/local/apache2/htdocs/index.php