LAMP 分离部署

LAMP分离部署

环境准备

系统IP
CentOS192.168.126.136
CentOS192.168.126.144
CentOS192.168.126.148
CentOS192.168.126.49

安装过程

//关闭防火墙
[root@ansible ansible]# ansible all -m shell -a 'systemctl stop firewalld && systemctl disable firewalld '
192.168.126.148 | CHANGED | rc=0 >>

192.168.126.144 | CHANGED | rc=0 >>

192.168.126.149 | CHANGED | rc=0 >>

//关闭SELINUX

[root@ansible ansible]# ansible all -m lineinfile -a 'path=/etc/selinux/config regexp="^SELINUX=" line="SELINUX=disabled"'
192.168.126.144 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": false, 
    "msg": ""
}
192.168.126.149 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": false, 
    "msg": ""
}
192.168.126.148 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": false, 
    "msg": ""
}
//在node1上安装HTTPD服务
[root@ansible ansible]# ansible httpd -m yum -a "name=httpd"
192.168.126.144 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "msg": "Nothing to do",
    "rc": 0,
    "results": []
}

//在node2上安装MySQL服务

[root@ansible ansible]# ansible mysql -m yum -a 'name=mariadb*'
192.168.126.148 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "msg": "", 
    "rc": 0, 
    "results": [
        "package providing mariadb* is already installed"
    ]
}

//在node3上安装php服务

[root@ansible ansible]# ansible php -m yum -a "name=php"
192.168.126.149 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "msg": "", 
    "rc": 0, 
    "results": [
        "php-5.4.16-48.el7.x86_64 providing php is already installed"
    ]
}

//创建脚本文件

[root@ansible ansible]# cat mkf.sh 
#! /bin/bash
echo 102.168.126.144      apache >> /etc/hosts
echo 192.168.126.148      mysql >> /etc/hosts
echo 192.168.126.149      php >> /etc/hosts
//解析
[root@ansible ansible]# ansible all -m script -a '/etc/ansible/mkf.sh'
192.168.126.144 | CHANGED => {
    "changed": true, 
    "rc": 0, 
    "stderr": "Shared connection to 192.168.126.144 closed.\r\n", 
    "stderr_lines": [
        "Shared connection to 192.168.126.144 closed."
    ], 
    "stdout": "", 
    "stdout_lines": []
}
192.168.126.149 | CHANGED => {
    "changed": true, 
    "rc": 0, 
    "stderr": "Shared connection to 192.168.126.149 closed.\r\n", 
    "stderr_lines": [
        "Shared connection to 192.168.126.149 closed."
    ], 
    "stdout": "", 
    "stdout_lines": []
}
192.168.126.148 | CHANGED => {
    "changed": true, 
    "rc": 0, 
    "stderr": "Shared connection to 192.168.126.148 closed.\r\n", 
    "stderr_lines": [
        "Shared connection to 192.168.126.148 closed."
    ], 
    "stdout": "", 
    "stdout_lines": []
}

//启动httpd、mysql、php服务,并设置开机自启

[root@ansible ansible]# ansible apache -m service -a "name=httpd state=started enabled=yes"
192.168.126.144 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "enabled": true, 
    "name": "httpd", 
    "state": "started", 
    "status": {
        "ActiveEnterTimestampMonotonic": "0", 
        "ActiveExitTimestampMonotonic": "0", 
        "ActiveState": "inactive", 
        "After": "systemd-journald.socket network.target remote-fs.target basic.target tmp.mount -.mount nss-lookup.target system.slice", 
        "AllowIsolate": "no", 
        "AmbientCapabilities": "0", 
        "AssertResult": "no", 
        "AssertTimestampMonotonic": "0", 
        "Before": "shutdown.target", 
        "BlockIOAccounting": "no", 
        "BlockIOWeight": "18446744073709551615", 
        "CPUAccounting": "no", 
        "CPUQuotaPerSecUSec": "infinity", 
        "CPUSchedulingPolicy": "0", 
        "CPUSchedulingPriority": "0", 
        "CPUSchedulingResetOnFork": "no", 
        "CPUShares": "18446744073709551615", 
        "CanIsolate": "no", 
        "CanReload": "yes", 
        "CanStart": "yes", 
        "CanStop": "yes", 
        "CapabilityBoundingSet": "18446744073709551615", 
        "ConditionResult": "no", 
        "ConditionTimestampMonotonic": "0", 
        "Conflicts": "shutdown.target", 
        "ControlPID": "0", 
        "DefaultDependencies": "yes", 
        "Delegate": "no", 
        "Description": "The Apache HTTP Server", 
        "DevicePolicy": "auto", 
        "Documentation": "man:httpd(8) man:apachectl(8)", 
        "EnvironmentFile": "/etc/sysconfig/httpd (ignore_errors=no)", 
        "ExecMainCode": "0", 
        "ExecMainExitTimestampMonotonic": "0", 
        "ExecMainPID": "0", 
        "ExecMainStartTimestampMonotonic": "0", 
        "ExecMainStatus": "0", 
        "ExecReload": "{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -k graceful ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", 
        "ExecStart": "{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -DFOREGROUND ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", 
        "ExecStop": "{ path=/bin/kill ; argv[]=/bin/kill -WINCH ${MAINPID} ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", 
        "FailureAction": "none", 
        "FileDescriptorStoreMax": "0", 
        "FragmentPath": "/usr/lib/systemd/system/httpd.service", 
        "GuessMainPID": "yes", 
        "IOScheduling": "0", 
        "Id": "httpd.service", 
        "IgnoreOnIsolate": "no", 
        "IgnoreOnSnapshot": "no", 
        "IgnoreSIGPIPE": "yes", 
        "InactiveEnterTimestampMonotonic": "0", 
        "InactiveExitTimestampMonotonic": "0", 
        "JobTimeoutAction": "none", 
        "JobTimeoutUSec": "0", 
        "KillMode": "control-group", 
        "KillSignal": "18", 
        "LimitAS": "18446744073709551615", 
        "LimitCORE": "18446744073709551615", 
        "LimitCPU": "18446744073709551615", 
        "LimitDATA": "18446744073709551615", 
        "LimitFSIZE": "18446744073709551615", 
        "LimitLOCKS": "18446744073709551615", 
        "LimitMEMLOCK": "65536", 
        "LimitMSGQUEUE": "819200", 
        "LimitNICE": "0", 
        "LimitNOFILE": "4096", 
        "LimitNPROC": "7152", 
        "LimitRSS": "18446744073709551615", 
        "LimitRTPRIO": "0", 
        "LimitRTTIME": "18446744073709551615", 
        "LimitSIGPENDING": "7152", 
        "LimitSTACK": "18446744073709551615", 
        "LoadState": "loaded", 
        "MainPID": "0", 
        "MemoryAccounting": "no", 
        "MemoryCurrent": "18446744073709551615", 
        "MemoryLimit": "18446744073709551615", 
        "MountFlags": "0", 
        "Names": "httpd.service", 
        "NeedDaemonReload": "no", 
        "Nice": "0", 
        "NoNewPrivileges": "no", 
        "NonBlocking": "no", 
        "NotifyAccess": "main", 
        "OOMScoreAdjust": "0", 
        "OnFailureJobMode": "replace", 
        "PermissionsStartOnly": "no", 
        "PrivateDevices": "no", 
        "PrivateNetwork": "no", 
        "PrivateTmp": "yes", 
        "ProtectHome": "no", 
        "ProtectSystem": "no", 
        "RefuseManualStart": "no", 
        "RefuseManualStop": "no", 
        "RemainAfterExit": "no", 
        "Requires": "-.mount basic.target", 
        "RequiresMountsFor": "/var/tmp", 
        "Restart": "no", 
        ~~省略~~ 
[root@ansible ansible]# ansible mysql -m service -a "name=mariadb state=started enabled=yes"
192.168.126.148 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "enabled": true, 
    "name": "mariadb", 
    "state": "started", 
    "status": {
        "ActiveEnterTimestampMonotonic": "0", 
        "ActiveExitTimestampMonotonic": "0", 
        "ActiveState": "inactive", 
        "After": "-.mount tmp.mount syslog.target system.slice systemd-journald.socket network.target basic.target", 
        "AllowIsolate": "no", 
        "AmbientCapabilities": "0", 
        "AssertResult": "no", 
        "AssertTimestampMonotonic": "0", 
        "Before": "shutdown.target", 
        "BlockIOAccounting": "no", 
        "BlockIOWeight": "18446744073709551615", 
        "CPUAccounting": "no", 
        "CPUQuotaPerSecUSec": "infinity", 
        "CPUSchedulingPolicy": "0", 
        "CPUSchedulingPriority": "0", 
        "CPUSchedulingResetOnFork": "no", 
        "CPUShares": "18446744073709551615", 
        "CanIsolate": "no", 
        "CanReload": "no", 
        "CanStart": "yes", 
        "CanStop": "yes", 
        "CapabilityBoundingSet": "18446744073709551615", 
        "ConditionResult": "no", 
        "ConditionTimestampMonotonic": "0", 
        "Conflicts": "shutdown.target", 
        "ControlPID": "0", 
        "DefaultDependencies": "yes", 
        "Delegate": "no", 
        "Description": "MariaDB database server", 
        "DevicePolicy": "auto", 
        "ExecMainCode": "0", 
        "ExecMainExitTimestampMonotonic": "0", 
        "ExecMainPID": "0", 
        "ExecMainStartTimestampMonotonic": "0", 
        "ExecMainStatus": "0"
        ~~省略~~ 
[root@ansible ansible]# ansible php -m service -a "name=php-fpm state=started enabled=yes"
192.168.126.149 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "enabled": true, 
    "name": "php-fpm", 
    "state": "started", 
    "status": {
        "ActiveEnterTimestampMonotonic": "0", 
        "ActiveExitTimestampMonotonic": "0", 
        "ActiveState": "inactive", 
        "After": "basic.target syslog.target system.slice systemd-journald.socket -.mount tmp.mount network.target", 
        "AllowIsolate": "no", 
        "AmbientCapabilities": "0", 
        "AssertResult": "no", 
        "AssertTimestampMonotonic": "0", 
        "Before": "shutdown.target", 
        "BlockIOAccounting": "no", 
        "BlockIOWeight": "18446744073709551615", 
        "CPUAccounting": "no", 
        "CPUQuotaPerSecUSec": "infinity", 
        "CPUSchedulingPolicy": "0", 
        "CPUSchedulingPriority": "0", 
        "CPUSchedulingResetOnFork": "no", 
        "CPUShares": "18446744073709551615", 
        "CanIsolate": "no", 
        "CanReload": "yes", 
        "CanStart": "yes", 
        "CanStop": "yes", 
        "CapabilityBoundingSet": "18446744073709551615", 
        "ConditionResult": "no", 
        "ConditionTimestampMonotonic": "0", 
        "Conflicts": "shutdown.target", 
        "ControlPID": "0", 
        "DefaultDependencies": "yes", 
        "Delegate": "no", 
        "Description": "The PHP FastCGI Process Manager", 
        "DevicePolicy": "auto", 
        "EnvironmentFile": "/etc/sysconfig/php-fpm (ignore_errors=no)", 
        "ExecMainCode": "0", 
        "ExecMainExitTimestampMonotonic": "0", 
        "ExecMainPID": "0", 
        "ExecMainStartTimestampMonotonic": "0", 
        "ExecMainStatus": "0", 
        "ExecReload": "{ path=/bin/kill ; argv[]=/bin/kill -USR2 $MAINPID ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", 
        "ExecStart": "{ path=/usr/sbin/php-fpm ; argv[]=/usr/sbin/php-fpm --nodaemonize ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", 
        "FailureAction": "none", 
        "FileDescriptorStoreMax": "0", 
        "FragmentPath": "/usr/lib/systemd/system/php-fpm.service", 
        "GuessMainPID": "yes", 
        "IOScheduling": "0", 
        "Id": "php-fpm.service",

//使用shell、lineinfile、copy模块来修改httpd的配置

[root@ansible ansible]# ansible apache -m shell -a 'sed -i "/DirectoryIndex/s/index.html/index.php index.html/g" /etc/httpd/conf/httpd.conf'
192.168.126.144 | CHANGED | rc=0 >> 
[root@ansible ansible]# ansible apache -m lineinfile -a 'path=/etc/httpd/conf/httpd.conf insertafter="AddType application/x-gzip.gz.tgz" line="AddType application/x-httpd-php .php"'
192.168.126.144 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": true, 
    "msg": "line added"
}   
[root@ansible ansible]# ansible apache -m lineinfile -a 'path=/etc/httpd/conf/httpd.conf insertafter="AddType application/x-gzip .gz.tgz" line="AddType application/x-httpd-php-source.phps"'
192.168.126.144 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": true, 
    "msg": "line added"
}
[root@ansible ansible]# ansible apache -m lineinfile -a 'path=/etc/httpd/conf/httpd.conf insertafter="# LoadModule foo_module modules/mod_foo.so" line="LoadModule proxy_module modules/mod_proxy.so"'
192.168.126.144 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": true, 
    "msg": "line added"
}
[root@ansible ansible]# ansible apache -m lineinfile -a 'path=/etc/httpd/conf/httpd.conf insertafter="# LoadModule foo_module modules/mod_foo.so" line="LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so"'
192.168.126.144 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": true, 
    "msg": "line added"
}

//把虚拟站点文件传输到apache服务器上

[root@ansible ansible]# cat /root/httpd.conf 
<VirtualHost *:80>
        DocumentRoot "/var/www/html/"
        ServerName www.mkf.com
        ProxyRequests Off
        ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.126.149:8800/www/html/$1
</VirtualHost>
[root@ansible ansible]# ansible apache -m copy -a 'src=/root/httpd.conf dest=/etc/httpd/conf.d/'
192.168.126.144 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "checksum": "df113d18483bfccfe4b4621ddfa44922c95a8548", 
    "dest": "/etc/httpd/conf.d/httpd.conf", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "a1972762529884da5120d31d08de5698", 
    "mode": "0644", 
    "owner": "root", 
    "size": 205, 
    "src": "/root/.ansible/tmp/ansible-tmp-1626921192.98-47279-86143886268835/source", 
    "state": "file", 
    "uid": 0
}
[root@php ~]# cat /etc/httpd/conf/httpd.conf
#Example:
#LoadModule foo_module modules/mod_foo.so
#
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
Include conf.modules.d/*.conf

//使用lineinfile模块来修改php的配置文件

[root@ansible ansible]# ansible php -m lineinfile -a 'path=/etc/php-fpm.d/www.conf regexp="listen = /usr" line="listen = 0.0.0.0:8800"'
192.168.126.149 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": true, 
    "msg": "line added"
}
[root@ansible ansible]# ansible php -m lineinfile -a 'path=/etc/php-fpm.d/www.conf regexp="listen.allowed_clients = 127.0.0.1" line="listen.allowed_clients = 192.168.126.149"'
192.168.126.149 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "backup": "", 
    "changed": true, 
    "msg": "line replaced"
}

//把php测试文件index.php放到php服务器上

[root@ansible ansible]# ansible php -m copy -a 'src=/root/index.php dest=/www/html/'
192.168.126.149 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "checksum": "8cdacfa1ec940e21858b76583aaf876549d8556d", 
    "dest": "/www/html/index.php", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "bf1c9e55ca2bfcfcdfd08d6d7ae2c8f6", 
    "mode": "0644", 
    "owner": "root", 
    "size": 13, 
    "src": "/root/.ansible/tmp/ansible-tmp-1626922616.43-77844-39004525474201/source", 
    "state": "file", 
    "uid": 0
}

//网站源码要放在php服务端的/var/www/html目录
//httpd服务配置添加远程调用php服务

[root@apache ~]# vim /etc/httpd/conf/httpd.conf
#probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php-source .phps
    AddType application/x-httpd-php .php
    Proxyrequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.14.10:9000/var/www/html/$1

//修改php服务监听方式

[root@php ~]# vim /etc/php-fpm.d/www.conf
; Note: This value is mandatory.
;listen = /run/php-fpm/www.sock
listen = 9000

; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 511
;listen.backlog = 511

//使用service模块重启服务

[root@ansible ansible]# ansible apache -m service -a 'name=httpd state=restarted'
192.168.126.144 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "name": "httpd", 
    "state": "started", 
    "status": {
        "ActiveEnterTimestamp": "四 2021-07-22 12:20:24 CST", 
        "ActiveEnterTimestampMonotonic": "1242819340", 
        "ActiveExitTimestampMonotonic": "0", 
        "ActiveState": "active", 
        "After": "-.mount system.slice tmp.mount remote-fs.target nss-lookup.target network.target basic.target systemd-journald.socket", 
        "AllowIsolate": "no", 
        "AmbientCapabilities": "0", 
        "AssertResult": "yes", 
        "AssertTimestamp": "四 2021-07-22 12:20:24 CST", 
        "AssertTimestampMonotonic": "1242781584", 
        "Before": "shutdown.target multi-user.target", 
        "BlockIOAccounting": "no", 
        "BlockIOWeight": "18446744073709551615", 
        "CPUAccounting": "no", 
        "CPUQuotaPerSecUSec": "infinity", 
        "CPUSchedulingPolicy": "0", 
        "CPUSchedulingPriority": "0", 
        "CPUSchedulingResetOnFork": "no", 
        "CPUShares": "18446744073709551615", 
        "CanIsolate": "no", 
        "CanReload": "yes", 
        "CanStart": "yes", 
        "CanStop": "yes", 
        "CapabilityBoundingSet": "18446744073709551615", 
        "ConditionResult": "yes", 
        "ConditionTimestamp": "四 2021-07-22 12:20:24 CST", 
        "ConditionTimestampMonotonic": "1242781584", 
        "Conflicts": "shutdown.target", 
        "ControlGroup": "/system.slice/httpd.service", 
        "ControlPID": "0", 
        "DefaultDependencies": "yes", 
        "Delegate": "no", 
        "Description": "The Apache HTTP Server", 
        "DevicePolicy": "auto", 
        "Documentation": "man:httpd(8) man:apachectl(8)", 
        "EnvironmentFile": "/etc/sysconfig/httpd (ignore_errors=no)", 
        "ExecMainCode": "0", 
        "ExecMainExitTimestampMonotonic": "0", 
        "ExecMainPID": "28535", 
        "ExecMainStartTimestamp": "四 2021-07-22 12:20:24 CST", 
        "ExecMainStartTimestampMonotonic": "1242782155", 
        "ExecMainStatus": "0", 
        "ExecReload": "{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -k graceful ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", 
        "ExecStart": "{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -DFOREGROUND ; ignore_errors=no ; start_time=[四 2021-07-22 12:20:24 CST] ; stop_time=[n/a] ; pid=28535 ; code=(null) ; status=0/0 }", 
        "ExecStop": "{ path=/bin/kill ; argv[]=/bin/kill -WINCH ${MAINPID} ; ignore_errors=no ; start_time=[四 2021-07-22 12:18:05 CST] ; stop_time=[四 2021-07-22 12:18:05 CST] ; pid=25482 ; code=exited ; status=1 }", 
        "FailureAction": "none", 
        "FileDescriptorStoreMax": "0", 
        "FragmentPath": "/usr/lib/systemd/system/httpd.service", 
        "GuessMainPID": "yes", 
        "IOScheduling": "0", 
        "Id": "httpd.service", 
        "IgnoreOnIsolate": "no", 
        "IgnoreOnSnapshot": "no", 
        "IgnoreSIGPIPE": "yes", 
        "InactiveEnterTimestamp": "四 2021-07-22 12:18:05 CST", 
        "InactiveEnterTimestampMonotonic": "1103554956", 
        "InactiveExitTimestamp": "四 2021-07-22 12:20:24 CST", 
        "InactiveExitTimestampMonotonic": "1242782184", 
        "JobTimeoutAction": "none", 
        "JobTimeoutUSec": "0", 
        "KillMode": "control-group", 
        "KillSignal": "18", 
        "LimitAS": "18446744073709551615", 
        "LimitCORE": "18446744073709551615", 
        "LimitCPU": "18446744073709551615", 
        "LimitDATA": "18446744073709551615", 
        "LimitFSIZE": "18446744073709551615", 
        "LimitLOCKS": "18446744073709551615", 
        "LimitMEMLOCK": "65536", 
        "LimitMSGQUEUE": "819200", 
        "LimitNICE": "0", 
        "LimitNOFILE": "4096", 
        "LimitNPROC": "7152", 
        "LimitRSS": "18446744073709551615", 
        "LimitRTPRIO": "0", 
        "LimitRTTIME": "18446744073709551615", 
        "LimitSIGPENDING": "7152", 
        "LimitSTACK": "18446744073709551615", 
        "LoadState": "loaded", 
        "MainPID": "28535", 
        "MemoryAccounting": "no", 
        "MemoryCurrent": "18446744073709551615", 
        "MemoryLimit": "18446744073709551615", 
        "MountFlags": "0", 
        "Names": "httpd.service", 
        "NeedDaemonReload": "no", 
        "Nice": "0", 
        "NoNewPrivileges": "no", 
        "NonBlocking": "no", 
        "NotifyAccess": "main", 
        "OOMScoreAdjust": "0", 
        "OnFailureJobMode": "replace", 
        "PermissionsStartOnly": "no", 
        "PrivateDevices": "no", 
        "PrivateNetwork": "no", 
        "PrivateTmp": "yes", 
        "ProtectHome": "no", 
        "ProtectSystem": "no", 
        "RefuseManualStart": "no", 
        "RefuseManualStop": "no", 
        "RemainAfterExit": "no", 
        "Requires": "basic.target -.mount", 
        "RequiresMountsFor": "/var/tmp", 
        "Restart": "no", 
        "RestartUSec": "100ms", 
        "Result": "success", 
        "RootDirectoryStartOnly": "no", 
        "RuntimeDirectoryMode": "0755", 
        "SameProcessGroup": "no", 
        "SecureBits": "0", 
        "SendSIGHUP": "no", 
        "SendSIGKILL": "yes", 
        "Slice": "system.slice", 
        "StandardError": "inherit", 
        "StandardInput": "null", 
        "StandardOutput": "journal", 
        "StartLimitAction": "none", 
        "StartLimitBurst": "5", 
        "StartLimitInterval": "10000000", 
        "StartupBlockIOWeight": "18446744073709551615", 
        "StartupCPUShares": "18446744073709551615", 
        "StatusErrno": "0", 
        "StatusText": "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec", 
        "StopWhenUnneeded": "no", 
        "SubState": "running", 
        "SyslogLevelPrefix": "yes", 
        "SyslogPriority": "30", 
        "SystemCallErrorNumber": "0", 
        "TTYReset": "no", 
        "TTYVHangup": "no", 
        "TTYVTDisallocate": "no", 
        "TasksAccounting": "no", 
        "TasksCurrent": "6", 
        "TasksMax": "18446744073709551615", 
        "TimeoutStartUSec": "1min 30s", 
        "TimeoutStopUSec": "1min 30s", 
        "TimerSlackNSec": "50000", 
        "Transient": "no", 
        "Type": "notify", 
        "UMask": "0022", 
        "UnitFilePreset": "disabled", 
        "UnitFileState": "enabled", 
        "WantedBy": "multi-user.target", 
        "Wants": "system.slice", 
        "WatchdogTimestamp": "四 2021-07-22 12:20:24 CST", 
        "WatchdogTimestampMonotonic": "1242819315", 
        "WatchdogUSec": "0"
    }
}
[root@ansible ~]# ansible php -m service -a 'name=php-fpm state=restarted'192.168.126.149 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "name": "php-fpm", 
    "state": "started", 
    "status": {
        "ActiveEnterTimestamp": "四 2021-07-22 13:19:09 CST", 
        "ActiveEnterTimestampMonotonic": "409639815", 
        "ActiveExitTimestampMonotonic": "0", 
        "ActiveState": "active", 
        "After": "systemd-journald.socket tmp.mount system.slice -.mount syslog.target network.target basic.target", 
        "AllowIsolate": "no", 
        "AmbientCapabilities": "0", 
        "AssertResult": "yes", 
        "AssertTimestamp": "四 2021-07-22 13:19:09 CST", 
   ~~省略~~
[root@ansible ~]# ansible mysql -m service -a 'name=mariadb state=restarted'
192.168.126.148 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "name": "mariadb", 
    "state": "started", 
    "status": {
        "ActiveEnterTimestamp": "四 2021-07-22 13:12:30 CST", 
        "ActiveEnterTimestampMonotonic": "12795795", 
        "ActiveExitTimestampMonotonic": "0", 
        "ActiveState": "active", 
        "After": "system.slice syslog.target basic.target -.mount systemd-journald.socket tmp.mount network.target", 
        "AllowIsolate": "no", 
        "AmbientCapabilities": "0", 
        "AssertResult": "yes", 
        "AssertTimestamp": "四 2021-07-22 13:12:26 CST", 
        "AssertTimestampMonotonic": "9286224", 
        "Before": "shutdown.target multi-user.target", 
        "BlockIOAccounting": "no", 
        "BlockIOWeight": "18446744073709551615", 
        "CPUAccounting": "no", 
        "CPUQuotaPerSecUSec": "infinity", 
        "CPUSchedulingPolicy": "0", 
        "CPUSchedulingPriority": "0", 
        "CPUSchedulingResetOnFork": "no", 
        "CPUShares": "18446744073709551615", 
        "CanIsolate": "no", 

访问apache主机的IP

在这里插入图片描述
配置文件出问题,但是服务可以使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值