RHEL6/CentOS6部署安装LAMP环境(yum)
1.安装软件
yum install httpd mysql mysql-server php php-mysql php-devel
httpd (提供 Apache 主程序)
mysql (MySQL 客戶端)
mysql-server (MySQL 服务器程序)
php (PHP 主程序,内含 apache 使用的模块)
php-devel (PHP 的开发工具相关,这个与 PHP 外挂的加速软件有关)
php-mysql (提供给 PHP 程序读取 MySQL 数据库的模块)
2.Apache基本设定
[root@node1 ~]# vi /etc/hosts
192.168.1.200 node1 node1.localdomain
[root@node1 ~]# vi /etc/httpd/conf/httpd.conf
ServerName localhost
3.PHP基本设定
vi /etc/php.ini
register_globals = Off # 请确定为 Off (默认为 Off),因为设定为 On 时, # 虽然程序比较不容易出问题,但是很容易不小心就被攻击。 log_errors = On ignore_repeated_errors = On ignore_repeated_source = On # 这三个参数可以決定是否要将 PHP 程序的错误记录下来, # 建议重复的错误资料忽略掉,否则在很忙碌的系统上, # 这些错误资料会造成日志文档暴增,导致性能下降 (或当机) display_errors = Off display_startup_errors = Off # 当程序出现问题时,是否要在浏览器上显示相关错误信息 (包括部分程式代码) # 生产环境中强烈建议设为 Off # 程序开发时为了方便debug可以暂时设为On post_max_size = 20M file_uploads = On upload_max_filesize = 16M memory_limit = 128M
4.mysql基本设定
1) 先启动:service mysqld start
2) root登录mysql:mysql -u root
3) 修改密码
4) 刷新权限:flush privileges;
5) 性能调优
vi /etc/my.cnf
[mysqld] default-storage-engine=innodb # 编码设定 default-character-set = utf8 port = 3306 skip-locking # 关于软件缓冲区设定,注意,缓冲区的简单计算方式为: # key_buffer + (sort_buffer + read_buffer ) * max_connection # 但缓冲区不能大于总物理内存 # 128 + (2+2)*150 = 728MB key_buffer = 128M sort_buffer_size = 2M read_buffer_size = 2M join_buffer_size = 2M max_connections = 150 max_connect_errors = 10 read_rnd_buffer_size = 4M max_allowed_packet = 4M table_cache = 1024 myisam_sort_buffer_size = 32M thread_cache = 16 query_cache_size = 16M tmp_table_size = 64M # 连接超时时间,原本是 28800 (sec) ,约 8 小时,我改为 20 分钟!! wait_timeout = 1200 thread_concurrency = 8 innodb_data_file_path = ibdata1:10M:autoextend innodb_buffer_pool_size = 128M innodb_additional_mem_pool_size = 32M innodb_thread_concurrency = 16 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
除非注明,戊辰人博客文章均为原创,转载请以链接形式标明本文地址