1.安裝前準備,安裝所需要的rpm包 [root@centos7~]# yum -y groupinstall "Development Tools" [root@centos7~]# yum -y install pcre-devel apr-devel apr-util-devel openssl-devel 2. [root@centos7~]# tar xvf httpd-2.4.35.tar.bz2 -C /usr/local/src/ [root@centos7~]# cd /usr/local/src/httpd-2.4.35/srclib/ [root@centos7srclib]# tar xvf apr-1.6.5.tar.gz [root@centos7srclib]# tar xvf apr-util-1.6.1.tar.gz [root@centos7srclib]# mv apr-util-1.6.1 apr-util [root@centos7srclib]# mv apr-1.6.5 apr 3. [root@centos7~]# cd /usr/local/src/httpd-2.4.35/ [root@centos7 httpd-2.4.35]# ./configure --prefix=/app/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-included-apr [root@centos7 httpd-2.4.35]# make -j 2 && make install [root@centos7 ~]# useradd -r -u 48 -c "Apache" -d /usr/share/httpd -s /sbin/nologin apache [root@centos7 ~]# vim /etc/httpd24/httpd.conf User apache Group apache [root@centos7~]# /app/httpd24/bin/apachectl restart [root@centos7 ~]# ps -ef |grep httpd root 46711 1 0 09:36 ? 00:00:00 /app/httpd24/bin/httpd -k start apache 46880 46711 0 09:44 ? 00:00:00 /app/httpd24/bin/httpd -k start apache 46881 46711 0 09:44 ? 00:00:00 /app/httpd24/bin/httpd -k start apache 46882 46711 0 09:44 ? 00:00:00 /app/httpd24/bin/httpd -k start apache 46883 46711 0 09:44 ? 00:00:00 /app/httpd24/bin/httpd -k start apache 46884 46711 0 09:44 ? 00:00:00 /app/httpd24/bin/httpd -k start root 46886 1812 0 09:44 pts/0 00:00:00 grep --color=auto httpd [root@centos7~]# /app/httpd24/bin/apachectl stop [root@centos7 ~]# cd /usr/lib/systemd/system [root@centos7system]# cp sshd.service httpd24.service [root@centos7system]# vim httpd24.service [Unit] Description=The Apache HTTP 2.4.35 Server After=network.target [Service] Type=forking ExecStart=/app/httpd24/bin/apachectl start ExecReload=/bin/kill -HUP $MAINPID ExecStop=/app/httpd24/bin/apachectl stop Restart=on-failure [Install] WantedBy=multi-user.target [root@centos7~]# systemctl daemon-reload [root@centos7 ~]# systemctl start httpd24 [root@centos7~]# systemctl enable httpd24 2.安裝mariadb-server [root@centos7~]# yum -y install mariadb-server mariadb-devel [root@centos7~]# yum -y install libmcrypt-devel bzip2-devel libxml2-devel [root@centos7~]# tar xvf php-7.2.11.tar.bz2 -C /usr/local/src/ [root@centos7~]# cd /usr/local/src/php-7.2.11/ [root@centos7 ~]#./configure \ --prefix=/app/php \ --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-openssl \ --with-pdo-mysql=mysqlnd \ --enable-mbstring \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir=/usr \ --enable-xml \ --enable-sockets \ --with-apxs2=/app/httpd24/bin/apxs \ --with-config-file-path=/etc \ --with-config-file-scan-dir=/etc/php.d \ --disable-fileinfo [[email protected]]# make -j 2 && make install [root@centos7 php-7.2.11]# cp php.ini-production /etc/php.ini [root@centos7 ~]# vim /etc/httpd24/httpd.conf DirectoryIndex index.php index.html </IfModule> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps [root@centos7(nanyibo) ~]# /app/httpd24/bin/httpd -t Syntax OK [root@centos7(nanyibo) ~]# systemctl restart httpd24 [root@centos7(nanyibo) ~]# vim /app/httpd24/htdocs/info.php <?php phpinfo(); ?> 通過瀏覽器訪問 http://192.168.190.7/info.php 配置mysql [root@centos7~]# vim /etc/my.cnf.d/server.cnf [mysqld] skip_name_resolve=ON [root@centos7 ~]# systemctl start mariadb.service [root@centos7 ~]# mysql MariaDB [(none)]> create database wpdb; MariaDB [(none)]> grant all on wpdb.* to 'wpuser'@'localhost' identified by 'wppass'; MariaDB [(none)]> grant all on wpdb.* to 'wpuser'@'127.0.0.1' identified by 'wppass'; [root@centos7~]# vim /app/httpd24/htdocs/conn.php <?php $conn = mysqli_connect('127.0.0.1','wpuser','wppass'); if ($conn) echo "OK"; else echo "Failure"; ?> [root@centos7(nanyibo) ~]# tar xvf php-5.6.38.tar.bz2 -C /usr/local/src/ [root@centos7(nanyibo) ~]# cd /usr/local/src/php-5.6.38/ [root@centos7(nanyibo) php-5.6.38]# ln -sv /usr/lib64/mysql/libmysqlclient.so /usr/lib [root@centos7(nanyibo) ~]# ./configure --prefix=/app/php56 \ > --with-mysql=/usr \ > --with-openssl \ > --with-mysqli=/usr/bin/mysql_config \ > --enable-mbstring \ > --with-png-dir \ > --with-jpeg-dir \ > --with-freetype-dir \ > --with-zlib \ > --with-libxml-dir=/usr \ > --enable-xml \ > --enable-sockets \ > --enable-fpm \ > --with-mcrypt \ > --with-config-file-path=/etc/php56 \ > --with-config-file-scan-dir=/etc/php56/php.d \ > --with-bz2 [[email protected]]# make -j 2 && make install [root@centos7~]# cd /app/php56/etc/ [root@centos7 etc]# cp php-fpm.conf.default php-fpm.conf [root@centos7 etc]# vim php-fpm.conf pid = run/php-fpm.pid error_log = log/php-fpm.log pm.status_path = /status ping.path = /ping ping.response = pong pm.max_children = 50 [root@centos7 ~]# mkdir /etc/php56 [root@centos7 ~]# cp /usr/local/src/php-5.6.38/php.ini-production /etc/php56/php.ini [root@centos7~]# cp /usr/local/src/php-5.6.38/sapi/fpm/php-fpm.service /usr/lib/systemd/system [root@centos7 ~]# vim /usr/lib/systemd/system/php-fpm.service [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=simple PIDFile=/app/php56/var/run/php-fpm.pid ExecStart=/app/php56/sbin/php-fpm --nodaemonize --fpm-config /app/php56/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target [root@centos7 ~]# systemctl daemon-reload [root@centos7~]# systemctl start php-fpm.service [root@centos7 ~]# ss -tnl |grep -w 9000 LISTEN 0 128 127.0.0.1:9000 *:* [root@centos7(nanyibo) ~]# vim /etc/httpd24/httpd.conf AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps #LoadModule php7_module modules/libphp7.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_connect_module modules/mod_proxy_connect.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1 [root@centos7 ~]# /app/httpd24/bin/httpd -t Syntax OK [root@centos7~]# systemctl restart httpd24 通過瀏覽器訪問 http://192.168.153.7/info.php 安裝wordpress [root@centos7~]# tar xvf wordpress-4.9.4-zh_CN.tar.gz -C /app/httpd24/ [root@centos7 ~]# cd /app/httpd24/ [root@centos7 httpd24]# rm htdocs -rf [root@centos7httpd24]# ln -sv wordpress htdocs ‘htdocs’ -> ‘wordpress’ [root@centos7 httpd24]# setfacl -m u:apache:rwx htdocs [root@centos7 ~]# tar xvf xcache-3.2.0.tar.bz2 -C /usr/local/src/ [root@centos7 ~]# cd /usr/local/src/xcache-3.2.0/ [root@centos7 xcache-3.2.0]# /app/php56/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 [root@centos7 xcache-3.2.0]# ./configure --enable-xcache --with-php-config=/app/php56/bin/php-config [root@centos7 xcache-3.2.0]# make && make install [root@centos7 ~]# mkdir /etc/php56/php.d [root@centos7 ~]# cp /usr/local/src/xcache-3.2.0/xcache.ini /etc/php56/php.d [root@centos7~]# vim /etc/php56/php.d/xcache.ini extension = /app/php56/lib/php/extensions/no-debug-non-zts-20131226/xcache.so [root@centos7 ~]# systemctl restart php-fpm.service 機器部署 ansible.magedu.com: 192.168.190.7 centos7 node1.magedu.com: 192.168.190.101 centos7 node2.magedu.com: 192.168.190.102 centos7 node3.magedu.com: 192.168.190.103 centos6 [root@ansible~]# yum install ansible ansible-doc -l 列出所有的模塊 module_name 查看指定模塊的幫助文檔 -s module_name 簡單查看模塊的幫助文檔 [root@ansible~]# ansible all -u liubei -k -m command -a 'id' [root@ansible~]# ansible all -u liubei -k -m command -a 'ls /root' [root@ansible ~]# ansible all -u liubei -k -m command -a "ls /root" -b -K [root@ansible ~]# ansible "websrvs" --list hosts (2): 192.168.190.101 192.168.190.103 [root@ansible~]# ansible "dbsrvs" --list hosts (2): 192.168.190.102 192.168.190.103 [root@ansible ~]# ansible "websrvs:dbsrvs" --list hosts (3): 192.168.190.101 192.168.190.103 192.168.190.102 [root@ansible~]# ansible "websrvs:&dbsrvs" --list hosts (1): 192.168.190.103 [root@ansible ~]# ansible 'websrvs:!dbsrvs' --list hosts (1): 192.168.190.101 ping 模塊 command模塊 default shell模塊 [root@ansible~]# ansible all -a 'removes=/etc/redhat-release1 cat /etc/redhat-release' 如果removes=的文件不存在,則不執行後面的命令 [root@ansible ~]# ansible all -a 'creates=/etc/passwd cat /etc/redhat-release' 如果creates=的文件已經存在,則不執行後面的命令 [root@ansible~]# ansible all -m script -a '/root/f1.sh' [root@ansible ~]# ansible all -m copy -a 'src=/root/selinux_config dest=/etc/selinux/config backup=yes' [root@ansible~]# ansible all -m copy -a 'src=/etc/passwd dest=/app/mima mode=000 owner=liubei group=bin' [root@ansible~]# ansible all -m copy -a 'content="Hello\nWorld\n" dest=/app/f1' [root@ansible~]# ansible all -m fetch -a 'src=/var/log/messages dest=/root/ansible' 如果要用fetch或copy傳輸多個文件,只能先打包 [root@ansible~]# ansible all -m shell -a 'tar Jcf /root/log.tar.xz /var/log/*.log' [root@ansible ~]# ansible all -m fetch -a 'src=/root/log.tar.xz dest=/root/ansible' [root@ansible~]# ansible all -m cron -a 'minute=* weekday=2,4,6 job="/usr/bin/wall FBI WARNING" name=warningcron' [root@ansible~]# ansible all -m cron -a 'disabled=true job="/usr/bin/wall FBI WARNING" name=warningcron' [root@ansible~]# ansible all -m cron -a 'disabled=false job="/usr/bin/wall FBI WARNING" name=warningcron' [root@ansible~]# ansible all -m cron -a 'name=warningcron state=absent'
LAMP環境搭建
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.