码迷,mamicode.com
首页 > 系统相关 > 详细

LAMP平台部署与应用的源码安装shell脚本

时间:2018-10-09 17:01:41      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:work   hup   pre   mcr   evel   php-mysql   autoconf   link   emd   

#!/bin/bash
#安装apache
rpm -e httpd --nodeps
yum -y install apr apr-devel cyrus-sasl-devel expat-devel libdb-devel openldap-devel apr-util-devel apr-util pcre-devel pcre
tar zxf /httpd- -C /usr/src
#必须将httpd-
放在/下
cd /usr/src/httpd-
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
make && make install
ln -s /usr/local/httpd/bin/
/usr/local/bin
echo "[Unit]" > /lib/systemd/system/httpd.service
echo "Description=The Apache HTTP Server" >> /lib/systemd/system/httpd.service
echo "After=network.target" >> /lib/systemd/system/httpd.service
echo "[Service]" >> /lib/systemd/system/httpd.service
echo "Type=forking" >> /lib/systemd/system/httpd.service
echo "PIDFile=/usr/local/httpd/logs/httpd.pid" >> /lib/systemd/system/httpd.service
echo "ExecStart=/usr/local/bin/apachectl $OPTIONS" >> /lib/systemd/system/httpd.service
echo "ExecReload=/bin/kill -HUP $MAINPID" >> /lib/systemd/system/httpd.service
echo "KillMode=process" >> /lib/systemd/system/httpd.service
echo "Restart=on-failure" >> /lib/systemd/system/httpd.service
echo "RestartSec=42s" >> /lib/systemd/system/httpd.service
echo "[Install]" >> /lib/systemd/system/httpd.service
echo "WantedBy=graphical.target" >> /lib/systemd/system/httpd.service
systemctl enable httpd.service
sed -i ‘200c ServerName www.aaa.com:80‘ /usr/local/httpd/conf/httpd.conf
systemctl restart httpd.service

#安装MYSQL
yum -y install ncurses-devel
yum -y install autoconf
tar zxf /cmake- -C /
cd /cmake-

./configure && gmake && gmake install
cd
groupadd mysql
useradd -M -s /sbin/nologin/ mysql -g mysql
tar zxf /mysql- -C /usr/src
cd /usr/src/mysql-

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
make && make install
chown -R mysql:mysql /usr/local/mysql
rm -rf /etc/my.cnf
cp support-files/my-default.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
. /etc/profile
cp support-files/mysql.server /usr/local/mysql/bin/mysqld.sh
chmod +x /usr/local/mysql/bin/mysqld.sh
echo "[Unit]" >> /usr/lib/systemd/system/mysqld.service
echo "Description=MYSQL Server" >> /usr/lib/systemd/system/mysqld.service
echo "After=network.target" >> /usr/lib/systemd/system/mysqld.service
echo "[Service]" >> /usr/lib/systemd/system/mysqld.service
echo "User=mysql" >> /usr/lib/systemd/system/mysqld.service
echo "Group=mysql" >> /usr/lib/systemd/system/mysqld.service
echo "Type=forking" >> /usr/lib/systemd/system/mysqld.service
echo "PIDFile=/usr/local/mysql/data/localhost.localdomain.pid" >> /usr/lib/systemd/system/mysqld.service
echo "ExecStart=/usr/local/mysql/bin/mysqld.sh start" >> /usr/lib/systemd/system/mysqld.service
echo "ExecStop=/usr/local/mysql/bin/mysqld.sh stop" >> /usr/lib/systemd/system/mysqld.service
echo "[Install]" >> /usr/lib/systemd/system/mysqld.service
echo "WantedBy=multi-user.target" >> /usr/lib/systemd/system/mysqld.service
systemctl daemon-reload
systemctl start mysqld
systemctl enable mysqld
. /etc/profile

#安装PHP
rpm -e php php-cli php-ldap php-common php-mysql --nodeps
yum -y install zlib-devel libxml2-devel
tar zxf /libmcrypt -C /usr/src
cd /usr/src/libmcrypt

./configure
make && make install
ln -s /usr/local/lib/libmcrypt. /usr/lib
cd
tar zxf /mhash-
-C /usr/src
cd /usr/src/mhash-
./configure
make && make install
ln -s /usr/local/lib/libmhash
/usr/lib
cd
tar zxf /mcrypt- -C /usr/src
cd /usr/src/mcrypt-

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure
make && make install
cd
tar zxf /php- -C /usr/src
cd /usr/src/php-

./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring
make && make install
cp /usr/src/php-/php.ini-development /usr/local/php5/php.ini
sed -i ‘680c default_charset ="utf-8"‘ /usr/local/php5/php.ini
sed -i ‘s/short_open_tag = Off/short_open_tag = On/‘ /usr/local/php5/php.ini
sed -i ‘873c extension=php_mysqli.dll‘ /usr/local/php5/php.ini
tar zxf /zend-loader-php
-C /usr/src
cd /usr/src/zend-loader-php
cp ZendGuardLoader.so /usr/local/php5/lib/php
sed -i ‘340a zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so‘ /usr/local/php5/php.ini
sed -i ‘341a zend_loader.enable=1‘ /usr/local/php5/php.ini
sed -i ‘259c DirectoryIndex index.html index.php‘ /usr/local/httpd/conf/httpd.conf
sed -i ‘396a AddType application/x-httpd-php .php‘ /usr/local/httpd/conf/httpd.conf
/usr/local/httpd/bin/apachectl restart
echo "<?php" > /usr/local/httpd/htdocs/test1.php
echo "phpinfo();" >> /usr/local/httpd/htdocs/test1.php
echo "?>" >> /usr/local/httpd/htdocs/test1.php
echo "<?php" > /usr/local/httpd/htdocs/test2.php
echo "\$link=mysqli_connect(‘localhost‘,‘root‘,‘‘);" >> /usr/local/httpd/htdocs/test2.php
echo ‘if($link) echo "good";‘ >> /usr/local/httpd/htdocs/test2.php
echo ‘mysqli_close($link);‘ >> /usr/local/httpd/htdocs/test2.php
echo "?>" >> /usr/local/httpd/htdocs/test2.php
tar zxf /phpMyAdmin-
-C /usr/src
cd /usr/src
mv phpMyAdmin-* /usr/local/httpd/htdocs/phpMyAdmin
cd /usr/local/httpd/htdocs/phpMyAdmin
cp config.sample.inc.php config.inc.php

LAMP平台部署与应用的源码安装shell脚本

标签:work   hup   pre   mcr   evel   php-mysql   autoconf   link   emd   

原文地址:http://blog.51cto.com/14010760/2296275

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!