博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
lamp安装
阅读量:7206 次
发布时间:2019-06-29

本文共 8584 字,大约阅读时间需要 28 分钟。

1.安装apache

apache的特点

功能强大、配置简单、速度快、应用广泛、性能稳定可靠,并可做代理服务器或负载均衡来使用。

apache应用场景

1.1 解除依赖下载软件包

yum install -y zlib zlib-develcd /server/tools/wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.2.34.tar.gztar xf httpd-2.2.34.tar.gzcd httpd-2.2.34/

1.2 安装apache配置

 

./configure --prefix=/application/apache2.2.34 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite make && make install

 

1.3 参数解释

 

--prefix 指定安装目录--enable-deflate 压缩文件--enable-expires 设置浏览器缓存过期--enable-headers http的头--enable-modules=most 激活大多数模块--enable-so --with-mpm=worker mpm --enable-rewrite

1.4 apache 目录结构及配置文件

 

bin/ab 压力测试工具ab.exe -h 查看帮助手册apacheMonitor apache管理工具(windows),apachectl apache管理工具(linux)apxs 添加新的模块时使用(在linux中?)编译php里需要这里的命令htpasswd 为网站设置用户名密码httpd 网站开启的服务rotatelogs 日志切分工具httpd.conf 主配置文件重要extra 扩展目录vim /httd.conf搜索DirectoryIndex index.html #默认使用index.htmlServerRoot "/application/apache2.2.34" #软件安装位置Listen 80 #监听端口 默认监听本机所有IP
#模块的开头
#模块的开头User daemon #编译安装软件默认用户 daemonGroup daemon #编译安装软件默认用户组 daemon
ServerAdmin you@example.com #网站管理员邮箱DocumentRoot "/application/apache2.2.34/htdocs" #默认的站点目录
#权限控制 / 表示根目录 Options FollowSymLinks AllowOverride None Order deny,allow #允许 Deny from all #禁止
#新创建网站必须增加这些行 !!!!! Options Indexes FollowSymLinks # 它允许了没有首页情况下展示目录结构 需要去掉 Indexes 或 -Indexes,此时没有首页文件时会出现403 forbidden错误,所以一定要有首页文件 AllowOverride None # 此处与httpd-defaults.conf控制,如果值为None 则表示禁止使用.htaccess All 表示允许 Order allow,deny Allow from all
#首页文件 DirectoryIndex index.html
Order allow,deny Deny from all Satisfy All
ErrorLog "logs/error_log" #错误日志LogLevel warn #访问日志级别
#日志类型 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
CustomLog "logs/access_log" common
#此处内容极不常用,建议删除 ScriptAlias /cgi-bin/ "/application/apache2.2.34/cgi-bin/"
AllowOverride None Options None Order allow,deny Allow from all
DefaultType text/plain #缺省类型,普通文本
RequestHeader unset Proxy early #不设置代理
TypesConfig conf/mime.types # AddType application/x-compress .Z #压缩类型 AddType application/x-gzip .gz .tgz   

AddType application/x-httpd-php .php .php3 .phtml .inc #手动添加php解析文件

 

AddType application/x-httpd-php-source .phps

# ssl 模块加密SSLRandomSeed startup builtinSSLRandomSeed connect builtin
三个扩展的配置文件httpd-vhosts.confhttpd-mpm.confhttpd-default.confhttpd-vhosts.conf NameVirtualHost *:80 #基于域名的虚拟主机 * 代表本机所有IP地址
ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/application/apache2.2.34/docs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error_log" CustomLog "logs/dummy-host.example.com-access_log" common
ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/application/apache2.2.34/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ErrorLog "logs/dummy-host2.example.com-error_log" CustomLog "logs/dummy-host2.example.com-access_log" common
httpd-mpm.conf
#pid文件 PidFile "logs/httpd.pid"
#锁文件LockFile "logs/accept.lock"
#模式文件之prefork模式 默认为prefork模式 StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0
#模式文件之 worker模式 指定woker模式 即为worker模式,如果没指定默认为prefork模式 StartServers 2 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0
StartThreads 10 MaxClients 50 MaxRequestsPerThread 10000
ThreadStackSize 65536 StartThreads 250 MinSpareThreads 25 MaxSpareThreads 250 MaxThreads 1000 MaxRequestsPerChild 0 MaxMemFree 100
StartServers 2 MinSpareThreads 5 MaxSpareThreads 10 MaxRequestsPerChild 0
ThreadsPerChild 150 MaxRequestsPerChild 0
httpd-defaults.confTimeout 300 #超时时间KeepAlive On #保持长连接MaxKeepAliveRequests 100 #最大请求数KeepAliveTimeout 5 #保持连接超时时间UseCanonicalName Off AccessFileName .htaccess #rewrite重写ServerTokens Full #隐藏版本号ServerSignature On #HostnameLookups Off

 1.5问题解决

 

错误:[root@VM_0_5_centos conf]# apachectl -tAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this messageSyntax OK解决问题:用记事本打开 httpd.conf#ServerName www.example.com:80 修改前ServerName localhost:80   修改后[root@VM_0_5_centos conf]# apachectl start[root@VM_0_5_centos conf]# ps -ef | grep httpdroot     29861     1  0 10:00 ?        00:00:00 /usr/sbin/httpd -DFOREGROUNDapache   29862 29861  0 10:00 ?        00:00:00 /usr/sbin/httpd -DFOREGROUNDapache   29863 29861  0 10:00 ?        00:00:00 /usr/sbin/httpd -DFOREGROUNDapache   29864 29861  0 10:00 ?        00:00:00 /usr/sbin/httpd -DFOREGROUNDapache   29865 29861  0 10:00 ?        00:00:00 /usr/sbin/httpd -DFOREGROUNDapache   29866 29861  0 10:00 ?        00:00:00 /usr/sbin/httpd -DFOREGROUNDroot     29885 24369  0 10:00 pts/2    00:00:00 grep --color=auto httpd[root@VM_0_5_centos conf]# ss -lnt | grep 8000LISTEN     0      511    127.0.0.1:8000                     *:*

 

 

2 安装php

apache以模块方式添加php下载phpwget http://cn2.php.net/distributions/php-7.1.1.tar.gz使用下载 libiconv rpm包使用链接:https://pan.baidu.com/s/1eR1LB8I 密码:rnr2rpm -ivh libiconv-1.14-1.x86_64.rpmtar xf php-7.1.1.tar.gzcd php-7.1.1

 

 

2.1安装依赖

 

yum install -y zlib-devel openssl-devel pcre-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libivonv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel bzip2-devel readline-devel recode recode-devel libtidy libtidy-devel libmcrypt-devel mhash mcrypt

2.2编译参数

./configure --prefix=/application/php-7.1.1 --with-apxs2=/application/apache/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex  --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --enable-ftp --enable-opcache=yes make && make install#授权useradd www -s /sbin/nologin -Mchown -R www.www /application/php-7.1.1/ln -s /application/php-7.1.1/ /application/php复制php配置文件cp /server/tools/php-7.1.1/php.ini-development  ./php.inicp /server/tools/php-7.1.1/php.ini-development /application/php/etc/修改apache httpd.confvim /application/apache/conf/httpd.confAddType application/x-httpd-php .php .php3 .phtml .incAddType application/x-httpd-php-source .phps重启服务/application/apache/bin/apachectl -k restart

3 二进制安装数据库

安装依赖包yum install -y libaio libaio-devel上传mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz,#二进制文件tar xf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz #时间会长一些mkdir -p /application/mysql5.6.34mv /server/tools/mysql-5.6.34-linux-glibc2.5-x86_64/* /application/mysql5.6.34/ln -s /application/mysql5.6.34/ /application/mysql useradd -s /sbin/nologin -M mysqlchown -R mysql.mysql /application/mysql/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysqlsed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /application/mysql/support-files/mysql.server\cp /application/mysql/support-files/my-default.cnf /etc/my.cnf\cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld/etc/init.d/mysqld start#设置密码/application/mysql/bin/mysqladmin -u root password 'new-password'/application/mysql/bin/mysqladmin -u root -h web02 password 'new-password'#添加到PATH路径sed -i '$aexport PATH=/application/mysql/bin:$PATH' /etc/profilesource /etc/profile#跳过授权表启动,在没有密码时,可以启动程序/application/mysql/bin/msyqld_safe --skip-grant-table &

 

转载于:https://www.cnblogs.com/anyux/p/8178091.html

你可能感兴趣的文章
SUSE LINUX系统文件句柄限制的修改
查看>>
贺双节,签名版限量特惠
查看>>
警惕“***性社工”现象
查看>>
Exchange 2013与OWA13集成
查看>>
有话请直说
查看>>
虚机不能启动的特例思考
查看>>
OSPF概述
查看>>
自动化部署操作系统-Kickstart+PXE自动部署
查看>>
Eclipse europa 更新时 Error retrieving "feature.xml". [error in opening zip file]的解决
查看>>
Hyper-V损坏数据恢复报告
查看>>
《从零开始学Swift》学习笔记(Day 16)——字典集合
查看>>
[转]配置nginx+apache 其中动态由apache处理,静态由nginx处理
查看>>
在Word中如何实现"后退"?
查看>>
简明 Vim 练级攻略 | 酷壳 - CoolShell.cn
查看>>
养成逻辑的习惯
查看>>
jQuery attributes(上)
查看>>
ISO8583报文协议(转)
查看>>
Android文本框实现搜索和清空效果
查看>>
Logic-算法-XX部队XX侦察队员
查看>>
海量数据(数据量比较大时)的处理分析
查看>>