部署 LAMP 架构

部署 LAMP 架构

Apache

1)编译安装依赖环境

yum -y install make gcc gcc-c++ openssl openssl-devel expat-devel

' 编译安装 apr '
wget http://archive.apache.org/dist/apr/apr-1.6.2.tar.gz
tar xzvf apr-1.6.2.tar.gz
rm -rf apr-1.6.2.tar.gz
cd apr-1.6.2/
./configure --prefix=/usr/local/apr
make && make install

' 编译安装 apr-util'
wget http://archive.apache.org/dist/apr/apr-util-1.6.0.tar.gz
tar xzvf apr-util-1.6.0.tar.gz
rm -rf apr-util-1.6.0.tar.gz
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
' 编译安装 pcre' 

部署 LAMP 架构

' 安装上传下载服务 '
yum install lrzsz -y

' 编译安装 pcre' 
tar xzvf pcre-8.41.tar.gz
rm -rf pcre-8.41.tar.gz
./configure --prefix=/usr/local/pcre
make && make install

2)编译安装Apache

wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.51.tar.gz
tar xzvf httpd-2.4.51.tar.gz

rm -rf httpd-2.4.51.tar.gz

cd httpd-2.4.51/

./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-modules=most --enable-mpms-shared=all --with-mpm=event

make && make install
参数 说明
–prefix=/usr/local/apache 安装路径
–enable-so 支持动态加载模块
–enable-rewrite 支持网站地址重写
–enable-ssl 支持SSL加密
–with-pcre=/usr/local/pcre pcre路径
–with-apr=/usr/local/apr apr路径
–with-apr-util=/usr/local/apr-util apr-util路径

3)配置文件及相应目录

` 配置文件 ` 
/usr/local/apache/conf/httpd.conf

` 网站根目录 `
/usr/local/apache/htdocs/

4)生成启动脚本并启动

' 方式一 '
cp /usr/local/apache/bin/apachectl /etc/init.d/
chmod +x /etc/init.d/apachectl
/etc/init.d/apachectl start				# Start

' 方式二 '
vim /usr/lib/systemd/system/apache.service
[Unit]
Description=Apache
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/apachectl start
ExecReload=/etc/init.d/apachectl restart
ExecStop=/etc/init.d/apachectl stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target

systemctl start apache.service			# Start
systemctl enable apache.service			# Enable

5)测试是否启动

yum install lsof -y

lsof -i:80

netstat -nltp | grep httpd
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      19613/httpd  
上一篇:记录error: rpmdb: BDB0113 Thread/process 61227/140631941699392 failed: BDB1507 Thread died in Berkeley


下一篇:编译安装apache2.4