您的位置:首页 > 运维架构 > Linux

linux自学笔记--lamp简单配置

2017-09-12 12:48 513 查看
1.httpd配置

(1)基本设置
Listen 80 端口
DocumentRoot /var/www 根目录
DirectoryIndex index.html 主页
Alias /icon/ "/download/newicon" 路径别名
ErrorDocument 404 /missing.html 404文件
ExtendeStatus On 220行左右,状态页面,在920左右定义具体
(2)访问控制
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Indexes:若页面无法访问则提供结构列表,应注释掉
FollowSymLinks:若在根目录下的文件,链接到非此目录,默认为 失败,设置此项可让链接离开目录限制
AllowOverride:是否允许.htaccess功能覆盖
Order: allow,deny开放所有,拒绝特定条件。deny,allow拒绝所 有,开放特定条件
Allow|deny from x.x.x.x:允许或拒绝特定网址或网段
(3)持久连接
KeepAlive on|off
KeepAliveTimeout 15默认,不宜太高
MaxKeepAliveRequests 500 默认100,最大超时请求数量
优点:一次连接处理多个请求,无需每个小图片都建立一次tcp请求
缺点:大并发服务器,后续请求可能无法及时响应
(4)MPM
prefork: 多进程模型
worker: 多进程多线程模型
pstree | grep 'httpd' 能查看到具体区别
配置文件: centos6 /etc/sysconfig/httpd
centos7 /etc/httpd/conf.modules.d/00-mpm.conf
(5)虚拟主机 需要注释掉DocumentRoot
基于ip或端口区分不同网站
<VirtualHost 192.168.1.10:80>
ServerName www.mage.com
DocumentRoot '/www/mage.com/htdocs'

</VirtualHost>
-------------------------------------------------
基于主机名,需要设置DNS或hosts文件解析
NameVirtualHost 192.168.1.10:80 注意2.4不需要
<VirtualHost 192.168.1.10:80>
ServerName www.mage.com
Document '/www/mage.com/htdocs'

</VirtualHost>

<VirtualHost 192.168.1.10:80> ServerName www.niaoge.com Document '/www/niaoge.com/htdocs'
</VirtualHost>

2.mariadb
(1)admin密码: mysqladmin -uroot password 123
(2)修改admin密码: mysqladmin -uroot -p123 Password
(3)授权: grant all on dbname.tbname to 'user'@'ipaddr' identified by 'password';
使用任意数据:*.*
任意地址:%
(4)修改用户密码:

use mysql;
update user set Password=password('456') where User='root';
flush privileges;
(5)拒绝反解析 /etc/my.cnf
[mysqld]
skip_name_resolve=ON;
3.编译安装lamp
(1)httpd
./configure --prefix=/usr/local/httpd
--sysconfdir=/etc/httpd
--with-apr=/usr --with-apr-util=/usr
(2)mariadb
复制support-files下配置文件到/etc/mysql/my.cnf,复制 mysql.server到/etc/init.d/mysqld
chkconfig --add mysqld
初始化数据库,在/usr/local/mysql下使用scripts /mysql_install_db --user=mysql --datadir=/path
(3)php
./configure --prefix=/usr/local/php
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-config-file-path=/etc
--with-config-file-scan-dir=/etc/php.d
--with-apxs2=/usr/local/httpd/bin/apxs 将编译为模块使用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux