当前位置:首页 » 编程软件 » apache安装脚本

apache安装脚本

发布时间: 2023-02-18 03:53:50

linux下编写自动安装mysql apache php脚本

1.1 编译安装

# groupadd mysql
# useradd -g mysql -d /usr/local/lib/mysql -s /sbin/nologin mysql

# tar zxvf mysql-x.x.x
# cd mysql-x.x.x
# ./configure --prefix=/usr/local/lib/mysql --localstatedir=/usr/local/lib/mysql/data --with-charset=utf8 --with-extra-charsets=all
# make
# make install

# cp support-files/my-medium.cnf /etc/my.cnf

# cd /usr/local/lib/mysql
# mkdir data
# bin/mysql_install_db --user=mysql
# chown -R root .
# chown -R mysql data
# chgrp -R mysql .

# echo "/usr/local/lib/mysql/bin/mysqld_safe &" >> /etc/rc.local
# /usr/local/lib/mysql/bin/mysqld_safe --user=mysql &

1.2 进入mysql的DBMS

# /usr/local/lib/mysql/bin/mysql -u root -p
enter password: <Enter>

*注:默认mysql的root用户口令为空

1.3 mysql数据在页面显示为中文乱码的问题

--with-extra-charsets=all是解决中文乱码的关键参数,它的作用是安装额外的字符集,其中即包括gbk等中文字符集。在创建数据库时手工指定字符集为gbk,这样就可以保证同样使用gbk字符集的HTML页面正常地显示中文了:
create database <db_name> default character set gbk collate gbk_chinese_ci;

2. 安装Apache
===============

2.1 编译安装

# tar zxvf httpd-x.x.x.tar.gz
# cd httpd-x.x.x
# ./configure --prefix=/usr/local/lib/apache --enable-so --enable-mods-shared=all --enable-rewrite=shared --enable-speling=shared
# make
# make install

2.2 apache启动停止命令

# /usr/local/lib/apache/bin/apachectl start
# /usr/local/lib/apache/bin/apachectl stop
# /usr/local/lib/apache/bin/apachectl restart

2.3 自动运行

# echo "/usr/local/lib/apache/bin/apachectl start" >> /etc/rc.local

2.4 apache启动时可能出现的错误

[Fri Dec 30 09:35:01 2005] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter

❷ apache服务器启动脚本apachectl无法完成

apache启动失败
1.
端口占用问题 这个问题比较常见,解决起来也很容易。通常是因为IE或安装的其它程序占用了80端口而导致Apache启动失败,在启动Apache之前将端口号修改为其它未占用的端口就可以了。 解决方法:我们的apache软件配置是在httpd.conf文件中配置,该文件在apache安装目录下conf 在httpd.conf文件中我们修改端口: Listen 81 注意修改完毕后,一定要重新启动apache。
2.
路径及文件名问题 解决了端口问题,还是启动失败,这是为什么呢?我们需要注意一个小细节,查看一下我们安装APMServ的路径,要确定安装路径的文件夹名称中不能出现中文或空格。毕竟这是个人作品,有些地方考虑的不是很周到,导致一些Bug。
3.
配置文件问题。

❸ 如何让apache支持cgi脚本

安装护卫神.apache大师,一键安装apache+php+mysql+jsp+ftp,PHP默认就是php-cgi模式运行

❹ 如何在 Apache 上部署 Let's Encrypt 证书 amp;amp;自动续期脚本

在Nginx上部署Let's Encrypt证书

下载Let's Encrypt客户端

首先我们要安装git
apt-get update

apt-get -y install git
复制代码
然后,检出Let's Encrypt的客户端源码
git clone https://github.com/letsencrypt/letsencrypt
复制代码
这样,我们就成功的下载了Let's Encrypt的客户端

签发证书

进入目录
cd letsencrypt
复制代码
使用 Let's Encrypt的Apache插件生成证书即可
./letsencrypt-auto --apache -d example.com
复制代码
如果只签一个域名,按照上面的命令就可以了
他会自动安装插件,然后你需要输入邮箱来用于证书的找回。同时还会要求你选择是否同时开启Http和https和是否开启强制https。
可以参照http://bbs.qcloud.com/thread-12059-1-1.html
如果是多个域名,就用下面的命令生成
./letsencrypt-auto --apache -d example.com -d www.example.com
复制代码

#!/bin/bash

#================================================================

# Let's Encrypt renewal script for Apache on Ubuntu/Debian

# @author Erika Heidi<[email protected]>

# Usage: ./le-renew.sh [base-domain-name]

#================================================================

domain=$1

le_path='/opt/letsencrypt'

le_conf='/etc/letsencrypt'

exp_limit=30;

get_domain_list(){

certdomain=$1

config_file="$le_conf/renewal/$certdomain.conf"

if [ ! -f $config_file ] ; then

echo "[ERROR] The config file for the certificate $certdomain was not found."

exit 1;

fi

domains=$(grep --only-matching --perl-regex "(?<=domains \= ).*" "${config_file}")

last_char=$(echo "${domains}" | awk '{print substr($0,length,1)}')

if [ "${last_char}" = "," ]; then

domains=$(echo "${domains}" |awk '{print substr($0, 1, length-1)}')

fi

echo $domains;

}

if [ -z "$domain" ] ; then

echo "[ERROR] you must provide the domain name for the certificate renewal."

exit 1;

fi

cert_file="/etc/letsencrypt/live/$domain/fullchain.pem"

if [ ! -f $cert_file ]; then

echo "[ERROR] certificate file not found for domain $domain."

exit 1;

fi

exp=$(date -d "`openssl x509 -in $cert_file -text -noout|grep "Not After"|cut -c 25-`" +%s)

datenow=$(date -d "now" +%s)

days_exp=$(echo \( $exp - $datenow \) / 86400 |bc)

echo "Checking expiration date for $domain..."

if [ "$days_exp" -gt "$exp_limit" ] ; then

echo "The certificate is up to date, no need for renewal ($days_exp days left)."

exit 0;

else

echo "The certificate for $domain is about to expire soon. Starting renewal request..."

domain_list=$( get_domain_list $domain )

"$le_path"/letsencrypt-auto certonly --apache --renew-by-default --domains "${domain_list}"

echo "Restarting Apache..."

/usr/sbin/service apache2 reload

echo "Renewal process finished for domain $domain"

exit 0;

fi
复制代码
将这个脚本加上可执行权限,再配置每个月或每两个月自动执行就可以保证你的证书不过期了

❺ apache服务器启动关闭脚本的编写

本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况
apahce启动命令:
推荐/usr/local/apache2/bin/apachectl start apaceh启动
apache停止命令
/usr/local/apache2/bin/apachectl stop 停止
apache重新启动命令:
/usr/local/apache2/bin/apachectl restart 重启
要在重启 Apache 服务器时不中断当前的连接,则应运行:
/usr/local/sbin/apachectl graceful
如果apache安装成为linux的服务的话,可以用以下命令操作:
service httpd start 启动
service httpd restart 重新启动

❻ 6.3 Apache脚本简介

1.服务类型 :系统V-launched服务

2.所需软件包 :httpd :Apache 2.0

httpd-devel

httpd-manual: Apache 2.0手册

3.守护进程 :httpd

4.脚本 :httpd

5.端口 :80/tcp(http)

443/tcp(https)

6.配置文件: /etc/httpd/*

/var/www/*

7.相关的 :redhat-config-httpd

mod-ssl

⑴ 设置标准的web服务器参数,规则的虚拟主机和模块。

⑵ 定义文件名和mime类型

访问控制

希望你从顶部到底部读取配置文件,尤其是一些重要的指示,命令。最好在头脑中记住分析的语法。

备用服务器进程的数量通过MPM的prefork(预派生)方式提供,MPM能被紧密地控制在Apache中。设置备用服务器的最小和最大数量允许在高请求准备和低内存应用之间的一个平衡。

日志文件由几个不同的原理组成,几乎发送或来自一个wed服务器的每件事都能被记录。所有日志文件元素的一个完整列表,参考:

http://httpd.apache.org/docs-2.0 /mod/mod_log_config.html

主机名查询默认被关闭。当打开时,客户端的主机名将被记录,不仅仅记录他们的IP。总之,希望保持主机名查询关闭,除非你感兴趣想知道他们在一个连续不断的基础上的结果以外。

Apache模块文件在/etc/httpd/moles中,详细信息在含有和通常可得到的模块上,涉及官方的Apache模块注册在http://moles.apache.org.中。

Apache支持以名称和多IP为基础的虚拟主机。

Apache也作为一个特别的用户和组打开虚拟主机去运行相关的CGI进程。

❼ 求教高人,有没有在redhat linux下实现apache,mysql和php自动安装的脚本。

当然有,安装是很方便的. 搜索LAMP自动安装脚本,结果有很多.
#! /bin/bash

apache_prefix=/usr/local/apache
php_prefix=/usr/local/php

is_root=`id | awk '{print $1}' | awk -F '[=(]' '{print $2}'`
if [ `whoami` != "root" ] && [ $is_root != 0 ]; then
echo "Please use root install this LAMP."
exit 1
fi

# check os
OS=`uname`
if [ "$OS" != "Linux" ]; then
echo "This is not linux os, Please use linux os. Thank you."
exit 2;
fi

# install apache
if [ ! -d "$apache_prefix" ]; then
tar zxvf httpd-2.2.19.tar.gz
cd httpd-2.2.19
./configure --prefix=$apache_prefix --enable-so --enable-rewrite --with-mpm=worker
make
make install

cd ..

if [ ! -f "$apache_prefix/htdocs/test.php" ]; then
echo "<?php phpinfo(); ?>" > $apache_prefix/htdocs
fi

rm -rf httpd-2.2.19
echo "apache install is OK."

sleep 2
fi

# install mysql
is_install_mysql=`find /usr/local/bin -name mysql | wc -l`
if [ "$is_install_mysql" = 0 ]; then
tar zxvf mysql-5.5.3-m3.tar.gz
cd mysql-5.5.3-m3
./configure --without-server --with-extra-charsets=gbk,gb2312,utf8 --enable-thread-safe-client
make
make install

cd ..
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig

rm -rf mysql-5.5.3-m3
echo "mysql intall is OK."

sleep 2
fi

# install freetype
if [ ! -d /usr/local/freetype ]; then
tar zxvf freetype-2.3.10.tar.gz
cd freetype-2.3.10
./configure --prefix=/usr/local/freetype
make
make install

cd ..
rm -rf freetype-2.3.10
echo "freetype install is OK."

sleep 2
fi

# install jpeg
if [ ! -d /usr/local/jpeg ]; then
tar zxvf jpegsrc.v8c.tar.gz
cd jpeg-8c
./configure --prefix=/usr/local/jpeg
make
make install

cd ..
rm -rf jpeg-8c
echo "jpeg install is OK."

sleep 2
fi

# install libpng
if [ ! -d /usr/local/libpng ]; then
tar zxvf libpng-1.2.41.tar.gz
cd libpng-1.2.41
./configure --prefix=/usr/local/libpng
make
make install

cd ..
rm -rf libpng-1.2.4
echo "libpng install is OK."

sleep 2
fi

if [ ! -f /usr/include/pngconf.h ]; then
ln -s /usr/local/libpng/include/pngconf.h /usr/include
fi

if [ ! -f /usr/include/png.h ]; then
ln -s /usr/local/libpng/include/png.h /usr/include
fi

# install gd2
if [ ! -d /usr/local/gd2 ]; then
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/gd2 --with-freetype-dir=/usr/local/freetype --with-png=/usr/local/libpng --with-jpeg=/usr/local/jpeg
make
make install

cd ..
rm -rf gd-2.0.35
echo "gd2 intall is OK."

sleep 2
fi

# install php
if [ ! -d "$php_prefix" ]; then
tar zxvf php-5.2.13.tar.gz
cd php-5.2.13
./configure --prefix=$php_prefix \
--with-gd=/usr/local/gd2 \
--with-apxs2=$apache_prefix/bin/apxs \
--enable-mbregex \
--enable-bcmath \
--with-mysql \
--with-zlib-dir \
--enable-mbstring=all \
--with-pdo-mysql \
--with-freetype-dir=/usr/local/freetype
make
make install

cp php.ini-dist $php_prefix/lib/php.ini
cd ..
rm -rf php-5.2.13
echo "php install is OK."

sleep 2
fi

sed -f httpd.sed $apache_prefix/conf/httpd.conf > $apache_prefix/conf/httpd.conf.tmp

cd $apache_prefix/conf
mv httpd.conf httpd.conf.bak
cat httpd.conf.tmp > httpd.conf

$apache_prefix/bin/apachectl -t

cd
echo "LAMP install is OK."

❽ 如何在Linux下设定Apache的脚本支持

Apache脚本……我知道有个编译安装的命令./configure --prefix=/usr/local/apache --enable-mole=so --enable-mole=rewrite --enable-shared=max --htdocsdir=/var/www &&make &&make install建议看看 http://lamp.linux.gov.cn/Apache/ApacheMenu/index.htmlApache HTTP Server 版本2.2的中文手册非常详细的介绍包括你没见过的一些命令什么的

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:748
制作脚本网站 发布:2025-10-20 08:17:34 浏览:1012
python中的init方法 发布:2025-10-20 08:17:33 浏览:718
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:878
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:774
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1127
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:351
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:229
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:911
python股票数据获取 发布:2025-10-20 07:39:44 浏览:875