本文共 3163 字,大约阅读时间需要 10 分钟。
一键安装LAMP
#/bin/bash #工具包yum install -y gcc pcre-devel openssl-devel expat-devel autoconf libtool gcc-c++ apr-devel apr-util-devel libxml2-devel bzip2-devel libmrpty-devel
#二进制安装MariaDB
tar xvf /data/mariadb-10.2.23-linux-x86_64.tar.gzmv mariadb-10.2.23-linux-x86_64 /usr/local/mysqlcd /usr/localln -s mariadb-10.2.23-linux-x86_64/ mysqluseradd -r -s /sbin/nologin -d /data/mysql mysqlmkdir /data/mysqlchown -R mysql.mysql /data/mysqlchown -R root.root /usr/local/mysqlcd mysql./scripts/mysql_install_db --datadir=/data/mysql --user=mysqlmkdir /etc/mysqlcp support-files/my-huge.cnf /etc/mysql/my.cnfsed -i '/skip-external-locking/i\datadir=/data/mysql' /etc/mysql/my.cnf
#设置启动脚本
cp support-files/mysql.server /etc/init.d/mysqldcp support-files/mysql.server /etc/init.d/mysqldchkconfig --add mysqld
#设置环境变量
echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/lamp.sh
#启动MariaDB
service mysqld start
#install httpd
tar xvf apr-1.7.0.tar.gztar xvf apr-util-1.6.1.tar.gztar xvf httpd-2.4.39.tar.bz2#cd httpd-2.4.39/srclib#ln -s ../../apr-1.7.0 ./apr#ln -s ../../apr-util-1.6.1 ./apr-utilmv apr-1.7.0 httpd-2.4.39/srclib/aprmv apr-util-1.6.1 httpd-2.4.39/srclib/apr-util#cd ..cd httpd-2.4.39/ ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=preforkmake -j 4 && make install echo '/app/httpd24/bin/apachectl start' >> /etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local . /etc/rc.d/rc.local
#设置环境变量
echo 'PATH=/app/http24/bin:$PATH' >> /etc/profile.d/lamp.sh
#添加apache用户 useradd -r -s /sbin/nlolgin apachesed -ri 's/^(User).*/\1 apache/' /app/httpd24/conf/httpd.confsed -ri 's/^(Group).*/\1 apache/' /app/httpd24/conf/httpd.conf/app/httpd24/bin/apachectl start
#install php
tar xvf php-7.3.5.tar.bz2cd php-7.3.5/./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockes --enable-fpm --enable-maintainer-zts --disable-fileinfomake -j 4 && make installcp php.ini-production /etc/php.inised -ri 's/^;(date\.timezone =).*/\1 "Asia/Shanghai"/' /etc/php.inicp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmcd /app/php/etccp php-fpm.conf.default php-fpm.confcd /app/php/etc/php-fpm.dcp www.conf.default www.confecho ' ' > /app/httpd24/htdocs/test.phpsed -ri 's/^user.*/user = apache/' /app/php/etc/php-fpm.d/www.confsed -ri 's/^group.*/group = apache/' /app/php/etc/php-fpm.d/www.confsed -ri 's/^#(LoadModule proxy_module.*)/\1/' /app/httpd24/conf/httpd.confsed -ri 's/^#(LoadModule proxy_fcgi_module.*)/\1/' /app/httpd24/conf/httpd.confecho 'DirectoryIndex index.php' >> /app/httpd24/conf/httpd.confecho 'ProxyRequests off' >> /app/httpd24/conf/httpd.confecho 'ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1' >> /app/httpd24/conf/httpd.conf/app/httpd24/bin/apachectl restartservice php-fpm start
转载于:https://blog.51cto.com/13749470/2396042