lamp

 

安装apache服务

本地下载后利用xftp传输
[root@apache ~]# ls
anaconda-ks.cfg    apr-util-1.6.1.tar.gz
apr-1.7.0.tar.bz2  httpd-2.4.46.tar.gz
安装开发工具包
[root@apache ~]#  yum groups mark install 'Development Tools'
安装所需要包
[root@apache ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++
创建apache服务的用户和组
[root@apache ~]# groupadd -r apache
[root@apache ~]# useradd -r -M -s /nologin -g apache apache[root@apache ~]# id apache
uid=994(apache) gid=990(apache) 组=990(apache)
解压apr,并编译apr
[root@apache ~]# tar xf apr-1.7.0.tar.bz2 
[root@apache apr-1.7.0]# vim configure
# $RM "$cfgfile"        //将此行加上注释
[root@apache apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@apache apr-1.7.0]# make && make install
解压apr-util包,并编译
[root@apache ~]# tar xf apr-util-1.6.1.tar.gz
[root@apache apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@apache apr-util-1.6.1]# make && make install
解压httpd,并编译
[root@apache ~]# tar xf httpd-2.4.46.tar.gz
[root@apache httpd-2.4.46]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --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@apache httpd-2.4.46]# make && make install
配置HTTP的服务
设置环境变量
[root@apache ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@apache ~]# source /etc/profile.d/httpd.sh
添加映射文件
[root@apache ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@apache ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config
取消注释,关闭警告信息
[root@apache ~]# sed -i '/#ServerName/s/#//g' /etc/httpd24/httpd.conf 
启动apache服务
[root@apache ~]# apachectl start
[root@apache ~]# ss -antl
State Recv-Q Send-Q  Local Address:Port  Peer Address:Port 
LISTEN0      128           0.0.0.0:22         0.0.0.0:*    
LISTEN0      128              [::]:22            [::]:*    
LISTEN0      128                 *:80               *:* 
apache安装完成

安装mysql服务

安装依赖包
[root@mysql ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
创建用户和组
[root@mysql ~]# groupadd -r -g 306 mysql
[root@mysql ~]# useradd -r -M -s /nologin -g 306 -u 306 mysql
在本地下载MySQL,利用xftp传输
[root@mysql ~]# ls
 anaconda-ks.cfg
'mysql-5.7.31-linux-glibc2.12-x86_64.tar (1).gz'
解压到当前目录
[root@mysql ~]# tar xf 'mysql-5.7.31-linux-glibc2.12-x86_64.tar (1).gz'
[root@mysql ~]# ls mysql-5.7.31-linux-glibc2.12-x86_64
bin   include  LICENSE  README  support-files
docs  lib      man      share
添加映射文化节
[root@mysql ~]# ln -sv mysql-5.7.31-linux-glibc2.12-x86_64 mysql
'mysql' -> 'mysql-5.7.31-linux-glibc2.12-x86_64'
[root@mysql ~]# ll
总用量 367720
-rw-------. 1 root root       1198 1月   7 2021  anaconda-ks.cfg
lrwxrwxrwx. 1 root root         35 1月   7 06:42  mysql -> mysql-5.7.31-linux-glibc2.12-x86_64
修改MySQL的属主跟属组
[root@mysql ~]# chown -R mysql.mysql ~/mysql
[root@mysql ~]# ll
lrwxrwxrwx. 1 mysql mysql        35 1月   7 06:42  mysql -> mysql-5.7.31-linux-glibc2.12-x86_64
设置环境变量
[root@mysql ~]# echo 'export PATH=~/mysql/bin:$PATH' >/etc/profile.d/mysql.sh
[root@mysql ~]# . /etc/profile.d/mysql.sh 
[root@mysql ~]# echo $PATH
/root/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
添加MySQL文件存放目录,并设置属主属组
[root@mysql ~]# mkdir /opt/data
[root@mysql ~]# chown -R mysql.mysql /opt/data
[root@mysql ~]# ll /opt/
总用量 0
drwxr-xr-x. 2 mysql mysql   6 1月   7 06:46 data
drwxr-xr-x. 7 root  root  225 1月   7 02:54 myrepo
初始化MySQL数据库
[root@mysql ~]# ~/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2021-01-07T11:52:14.867588Z 1 [Note] A temporary password is generated for root@localhost: S8ghwl4pk<52
配置映射文件
[root@mysql ~]# ln -sv ~/mysql/include/ /usr/local/include/mysql
'/usr/local/include/mysql' -> '/root/mysql/include/'
[root@mysql ~]# echo '/root/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@mysql ~]# ldconfig 
编辑配置文件
[root@mysql ~]# vim /etc/my.cnf
[root@mysql ~]# cat /etc/my.cnf
[mysqld]
basedir = /root/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
启动服务脚本
[root@mysql ~]# cp -a /root/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@mysql ~]# sed -ri 's#^(basedir=).*#\1/root/mysql#g' /etc/init.d/mysqld
[root@mysql ~]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld
启动mysql
[root@mysql ~]# service mysqld start 
Starting MySQL.Logging to '/opt/data/mysql.err'.
s SUCCESS! 
[root@mysql ~]# ss -antl
State Recv-Q Send-Q  Local Address:Port  Peer Address:Port 
LISTEN0      128           0.0.0.0:22         0.0.0.0:*    
LISTEN0      128              [::]:22            [::]:*    
LISTEN0      80                  *:3306             *:*  
更改密码
依赖包不全,安装
[root@mysql ~]# yum install libncurses*
[root@mysql ~]# mysql -uroot -p
mysql> set password = password('990304');
Query OK, 0 rows affected, 1 warning (0.00 sec)

安装php

 

yum安装php
[root@php ~]# yum -y install php*
[root@php ~]# yum -y groups mark install "Development Tools"
[root@php ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel  pcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel php72-php-mysqlnd
启动php服务
[root@php ~]# systemctl start php-fpm.service

配置apache和php

在apache主机上配置
启用http的模块
[root@apache ~]# sed -i '/proxy_module/s/#//g' /etc/httpd24/httpd.conf
[root@apache ~]# sed -i '/proxy_fcgi_module/s/#//g' /etc/httpd24/httpd.conf
[root@apache ~]# vim /etc/httpd24/httpd.conf
添加内容,
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/"
    ServerName www.wangming.com
    ProxyRequests Off    ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.170.135:9000/var/www/html/$1
    <Directory "/usr/local/apache/htdocs/">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>
在文件中找到相同的类型,加入以下两个
    AddType application/x-httpd-php .php      
    AddType application/x-httpd-php-source .phps 
[root@apache ~]#sed -i '/    DirectoryIndex/s/index.html/index.php index.html/g' /etc/httpd24/httpd.conf
修改配置文件
[root@php ~]# vim /etc/php-fpm.d/www.conf
listen.allowed_clients = 192.168.170.136      #加入apache主机ip
listen = 0.0.0.0:9000
创建测试页面
[root@php ~]# echo -e "<?php\n\tphpinfo();\n?>" > /var/www/html/index.php
[root@php ~]# chown -R apache.apache /var/www/html/
重启服务
[root@php ~]# apachectl restart
[root@php ~]# systemctl restart php-fpm.service

 

lamp

 

上一篇:这世上倒底有没有神仙——说“Excel不是数据库,是不是犯了白马非马论的错误??


下一篇:Redis启动