lamp平台构建
1.安装apache
//下载epel源
[root@localhost ~]# yum -y install epel-release
//安装工具包
[root@localhost ~]# yum groups mark install 'Development Tools' -y
//创建用户
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
//安装依赖包
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make
//下载apr、apr-util、httpd源码包并解压
[root@localhost src]# wget https://dlcdn.apache.org/apr/apr-1.7.0.tar.gz
[root@localhost src]# wget https://dlcdn.apache.org/apr/apr-util-1.6.1.tar.gz
[root@localhost src]# wget https://dlcdn.apache.org/httpd/httpd-2.4.49.tar.gz
[root@localhost src]# tar xf apr-1.7.0.tar.gz
[root@localhost src]# tar xf apr-util-1.6.1.tar.gz
[root@localhost src]# tar xf httpd-2.4.49.tar.gz
[root@localhost src]# ls
apr-1.7.0 apr-util-1.6.1 debug httpd-2.4.49.tar.gz
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.49 kernels
//编译安装apr
[root@localhost src]# cd apr-1.7.0/
[root@localhost apr-1.7.0]# vim configure
$RM "$cfgfile" //删除该行
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make -j2
[root@localhost apr-1.7.0]# make install
//编译安装apr-util
[root@localhost apr-1.7.0]# cd ../apr-util-1.6.1/
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.6.1]# make
[root@localhost apr-util-1.6.1]# make install
//编译安装httpd
[root@localhost apr-util-1.6.1]# cd ../httpd-2.4.49/
[root@localhost httpd-2.4.49]# ./configure --prefix=/usr/local/apache \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util/ \
> --enable-modules=most \
> --enable-mpms-shared=all \
> --with-mpm=prefork
[root@localhost httpd-2.4.49]# make -j2
[root@localhost httpd-2.4.49]# make install
//安装后的配置
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@localhost ~]# source /etc/profile.d/httpd.sh
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@localhost ~]# vim /etc/man_db.conf
MANDATORY_MANPATH /usr/local/apache/man //加入此行
[root@localhost ~]# sed -i '/#ServerName/s/#//g' /usr/local/apache/conf/httpd.conf
//配置开机自启
[root@localhost ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=httpd server daemon
Documentation=man:httpd(8)
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl enable --now httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# ss -anltu
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
tcp LISTEN 0 128 *:80 *:*
tcp LISTEN 0 128 [::]:22 [::]:*
2.安装mysql