centos6下配置apache+php+mysql
1、打开putty,连接服务器,设置服务器的IP和Port,默认是root,
login as: root
passwd: 你的密码
1、连接入服务器后,先安装apache
sudo yum update
sudo yum install httpd
2、编译一下httpd
vim /etc/httpd/conf/httpd.conf
KeepAlive Off
<IfModule prefork.c>
StartServers 4
MinSpareServers 20
MaxSpareServers 40
MaxClients 200
MaxRequestsPerChild 4500
</IfModule>
3、设置apache虚拟服务器
vim /etc/httpd/conf.d/vhost.conf
<VirtualHost *:80>
ServerAdmin admin@example.org #联系E-MAIL
ServerName example.org #域名
ServerAlias www.example.org #关联域名www
DocumentRoot /var/www/html/ #设置网页路径
ErrorLog /var/www/logs/error.log #错误日志
CustomLog /var/www/logs/access.log combined #登陆日志
</VirtualHost>
4、建立网页路径目录和日志目录
sudo mkdir -p /var/www/html/
sudo mkdir -p /var/www/logs/
1、安装mysql数据库
sudo yum install mysql-server
2、设置mysql密码
sudo /usr/bin/mysql_secure_installation
Enter current password for root (enter for none): #键入你的密码
然后出现
OK, successfully used password, moving on...
按照下面提示键入y
By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y ... Success!
Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y
... Success!By default, MySQL comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y
- Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y
... Success!Cleaning up...All done! If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!
3、配置mysql
vim /etc/my.cnf
修改以下几行提高效率
max_connections = 3000 #数据库最大连接数
max_connect_errors = 6000 #数据库最大错误连接数
thread_cache_size = 300 #进程缓存
query_cache_size = 64M #MyISAM引擎优化中缓存
query_cache_limit = 4M #指定单个查询能够使用的缓冲区大小
tmp_table_size = 256M #临时表大小
key_buffer_size = 1024M #索引缓存大小
read_rnd_buffer_size = 16M #随机读取缓存
bulk_insert_buffer_size = 64M #插入缓存
myisam_sort_buffer_size = 128M #MyISAM引擎排序缓存
myisam_max_sort_file_size = 10G #重建索引最大允许的临时文件大小
innodb_additional_mem_pool_size = 16M #InnoDB 存储的数据目录信息和其它内部数据结构的内存池大小
innodb_buffer_pool_size = 1024M #InnoDB 存储缓存区大小
4、开启mysql服务器
sudo service mysqld start
设置apache服务器为开机自启动
sudo chkconfig mysql on
1、安装php
sudo yum install php php-mysql
重启apache服务器
sudo service httpd restart
2、新建一个php文件,检查一下服务器是否安装完成?
sudo nano /var/www/html/index.php
添加以下几行
<?phpphpinfo();?>
然后再浏览器里打卡页面http://你的域名