因为Centos6 yum源更新的很满,所以php还是5.4版本的,满足不了很多需求.特此说下配置方法
一、安装Apache
1、安装apache
yum -y install httpd
2、开机自动启动
chkconfig httpd on
3、启动http服务
service httpd start
4、安装apache一些扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
二、安装配置MySQL
1、安装MySQL
yum install -y mysql mysql-server
2、开机启动
chkconfig mysqld on
3、启动mysqld服务
service mysqld start
4.配置mysql(初始)
[root@server1 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):<–初次运行直接回车
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] <– 是否删除匿名用户,生产环境建议删除,所以直接回车
… Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
… Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] <– 是否删除test数据库,直接回车
- Dropping test database…
… Success!
- Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,直接回车
… Success!
Cleaning up…
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@server1 ~]#
5.这里说下mysqld服务的远程配置
1.修改/etc/mysql/my.conf
找到bind-address = 127.0.0.1这一行,改为bind-address = 0.0.0.0即可
2.为需要远程登录的用户赋予权限
//允许任何ip地址(%表示允许任何ip地址)的电脑用admin帐户和密(123456)来访问这个mysql server。注意admin账户不一定要存在。
grant all on *.* to admin@'%' identified by '123456' with grant option;
flush privileges;
//支持root用户允许远程连接mysql数据库
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
3.查看user表
mysql> select user,host from user;
出现如果表中的user项为你的用户名,host为%即为成功
user | host |
---|---|
toot | % |
4.配置防火墙
由于我用的是阿里云,直接在安全组哪里配置就行了我就不演示了,不会的可以百度一下
三、安装PHP(5.6)
1、配置yum源
追加CentOS 6.5的epel及remi源
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
顺带提一下CentOS 7.0的源
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
使用yum list命令查看可安装的包(Packege)。
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
2、安装PHP(5.6)
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-gd
3.配置php.ini
vi /etc/php.ini
把 date.timezone = PRC 改成 date.timezone = Asia/Shanghai,如果有分号记得去掉分号.
如果你需要Centos中apache的多站点配置你可以读读它.