当前位置:网站首页>Shell脚本一键配置LAMP
Shell脚本一键配置LAMP
2022-07-27 05:22:00 【征服bug】
#!/bin/bash
#安装httpd服务
rpm -q httpd
if [ $? -eq httpd ]
then
rpm -e httpd
fi
#安装依赖包
rpm -ivh /mnt/Packages/apr-1.4.8-3.el7.x86_64.rpm
rpm -ivh /mnt/Packages/apr-devel-1.4.8-3.el7.x86_64.rpm
rpm -ivh /mnt/Packages/cyrus-sasl-devel-2.1.26-20.el7_2.x86_64.rpm
rpm -ivh /mnt/Packages/expat-devel-2.1.0-8.el7.x86_64.rpm
rpm -ivh /mnt/Packages/libdb-devel-5.3.21-19.el7.x86_64.rpm
rpm -ivh /mnt/Packages/openldap-devel-2.4.40-13.el7.x86_64.rpm
rpm -ivh /mnt/Packages/apr-util-devel-1.5.2-6.el7.x86_64.rpm
rpm -ivh /mnt/Packages/apr-util-1.5.2-6.el7.x86_64.rpm
rpm -ivh /mnt/Packages/pcre-devel-8.32-15.el7_2.1.x86_64.rpm
rpm -ivh /mnt/Packages/pcre-8.32-15.el7_2.1.x86_64.rpm
#安装源代码包
tar zxf /mnt/tar/httpd-2.4.25.tar.gz -C /usr/src/
cd /usr/src/httpd-2.4.25/
./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
#安装mysql
rpm -q mysql-server mysql
if [ $? -eq 0 ]
then
rpm -e mysql-server mysql
fi
#安装ncurses
rpm -ivh /mnt/Packages/ncurses-devel-5.9-13.20130511.el7.x86_64.rpm
tar zxf /mnt/tar/cmake-2.8.6.tar.gz -C /usr/src
cd /usr/src/cmake-2.8.6
./configure
gmake && gmake install
#创建mysql用户
groupadd mysql
useradd -M -g mysql mysql
#源代码安装的mysql
tar zxf /mnt/tar/mysql-5.6.36.tar.gz -C /usr/src
cd /usr/src/mysql-5.6.36/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
make && make install
#加强mysql用户权限
chown -R mysql:mysql /usr/local/mysql
rm -rf /etc/my.cnf
cp /usr/src/mysql-5.6.36/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 /usr/src/mysql-5.6.36/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
systemctl start mysqld
#安装PHP
rpm -e php php-cli php-ldap php-common php-mysql --nodeps
#安装依赖包
rpm -ivh /mnt/Packages/zlib-devel-1.2.7-17.el7.x86_64.rpm
rpm -ivh /mnt/Packages/xz-devel-5.2.2-1.el7.x86_64.rpm
rpm -ivh /mnt/Packages/libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm
#安装libcrypt
tar zxf /mnt/tar/libmcrypt-2.5.8.tar.gz -C /usr/src
cd /usr/src/libmcrypt-2.5.8
./configure && make && make install
ln -s /usr/local/lib/libmcrypt.* /usr/lib/
#安装mhash
tar zxf /mnt/tar/mhash-0.9.9.9.tar.gz -C /usr/src
cd /usr/src/mhash-0.9.9.9/
./configure && make && make install
ln -s /usr/local/lib/libmhash* /usr/lib/
#安装mcrypt
tar zxf /mnt/tar/mcrypt-2.6.8.tar.gz -C /usr/src
cd /usr/src/mcrypt-2.6.8/
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure && make && make install
#安装php
tar zxf /mnt/tar/php-5.5.38.tar.gz -C /usr/src
cd /usr/src/php-5.5.38/
./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 -f /usr/src/php-5.5.38/php.ini-development /usr/local/php5/php.ini
#更改配置文件
sed -i 's/short_open_tag.*$/short_open_tag=Off/g' /usr/local/php5/php.ini
sed -i '$a extension=php_mysqli.dll' /usr/local/php5/php.ini
sed -i 's/DirectoryIndex.*$/DirectoryIndex index.html index.php/g' /usr/local/httpd/conf/httpd.conf
sed -i '$a AddType application/x-httpd-php .php' /usr/local/httpd/conf/httpd.conf
#测试
/usr/local/httpd/bin/apachectl restart
echo -e "<?php\nphpinfo();\n?>" > /usr/local/httpd/htdocs/test1.php
systemctl start mysqld
mysqladmin -u root password ‘123456’
echo -e "<?php\n\$link=mysqli_connect('localhost','root','123456');\nif(\$link) echo \"good,mysql\";\nmysqli_close(\$link);\n?>" > /usr/local/httpd/htdocs/test2.php边栏推荐
- 5g's past and present life -- a brief introduction to the development of mobile communication
- Robot navigation
- 多线程CAS、synchronized锁原理 、JUC以及死锁
- Unity practical tips (updating)
- 数据库在终端的增删改查
- OSG environment construction (win10+vs2019)
- Li Kou daily question leetcode 513. find the value in the lower left corner of the tree
- 英语基础知识:修饰性的句子成分-上篇
- Wireshark packet modification -- IP address modification (I)
- The problem that tqdm cannot display in a single line
猜你喜欢
随机推荐
Summary of test basis
Summary of Internet simple protocol
正则表达式
jmeter简介
shell脚本之函数调用
英语基础知识: 并列结构
5G的前世今生---简述移动通信的发展
shell脚本循环
多线程CAS、synchronized锁原理 、JUC以及死锁
Comparison of communication mechanisms
软件测试基础概念篇
允许或者禁止同时连接到一个non-domain和一个domain网络
Three ways to get RPM packages using yum
Array and subscript index
接口测试概念及Postman工具简介使用
ROS workspace coverage
Linu性能调优:面对DDOS攻击,我们如何缓解局面?
Seven sorting details
DNS domain name resolution service
5g network identity - detailed explanation of 5g Guti









