注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

过☆客

一颗迷茫的心在3D世界中飘荡...

 
 
 

日志

 
 
关于我

爱宁静,不爱喧闹, 爱奋斗,也爱自由, 爱顺其自然,爱独来独往, 没高学历,不算成功, 没车也没房,但我真诚, 走进你的世界,却不留痕迹, 我是过客,不只是过客...

网易考拉推荐

CentOS 6.5系统安装配置Apache+PHP5+MySQL  

2015-12-18 22:52:04|  分类: 日积月累-Linux |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
这里讲用yum来安装配置Apache+PHP5+MySQL,而Centos手动安装的流程与ubuntu下Apache+PHP+MySQL安装配置类似。
1. 安装Apache

yum install httpd # 根据提示,输入y就可以安装成功了

/etc/init.d/httpd start#启动Apache

chkconfig httpd on #设为开机启动
/etc/init.d/httpd restart #重启Apache

2. 安装MySQL

yum install mysql mysql-server #询问是否要安装,输入Y即可自动安装,直到安装完成
/etc/init.d/mysqld start #启动MySQL
chkconfig mysqld on #设为开机启动
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)

为root账户设置密码

mysql_secure_installation

原始密码为空,直接回车,根据提示输入y,然后输入2次密码,然后根据提示回车和输入y
最后出现: Thanks for using MySQL!

/etc/init.d/mysqld restart #重启

/etc/init.d/mysqld stop #停止
/etc/init.d/mysqld start #启动

操作步骤如下:

[root@localhost home]# 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] y
New password:
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] y
... 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] y
... 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] y
- 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] y
... 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!

3. 安装PHP5

yum install php #根据提示输入Y直到安装完成

安装PHP组件,使PHP5支持MySQL及其他

yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt #这里选择以上安装包进行安装,根据提示输入Y回车
/etc/init.d/mysqld restart #重启MySql
/etc/init.d/httpd restart #重启Apche

4.Apache配置

vi /etc/httpd/conf/httpd.conf #编辑文件
ServerTokens OS  #在44行 修改为:ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称)
ServerSignature On  #在536行 修改为:ServerSignature Off (在错误页中不显示Apache的版本)
Options Indexes FollowSymLinks  #在331行 修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi #在796行 修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None  #在338行 修改为:AllowOverride All (允许.htaccess)
AddDefaultCharset UTF-8 #在759行 修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)
  Options Indexes MultiViews FollowSymLinks #在554行 修改为 Options MultiViews FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html index.html.var #在402行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var (设置默认首页文件,增加index.php)
KeepAlive Off #在76行 修改为:KeepAlive On (允许程序性联机)
MaxKeepAliveRequests 100 #在83行 修改为:MaxKeepAliveRequests 1000 (增加同时连接数)
:wq! #保存退出
/etc/init.d/httpd restart#重启
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #删除默认测试页

5. PHP配置

vi /etc/php.ini #编辑
date.timezone = PRC #在946行 把前面的分号去掉,改为date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#在386行 列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off #在432行 禁止显示php版本的信息
magic_quotes_gpc = On #在745行 打开magic_quotes_gpc来防止SQL注入
short_open_tag = ON #在229行支持php短标签
open_basedir = .:/tmp/ #在380行 设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题,可以注销此行,或者直接写上程序的目录/data/www.osyunwei.com/:/tmp/
:wq! #保存退出
/etc/init.d/mysqld restart #重启MySql
/etc/init.d/httpd restart #重启Apche

6. MySQL 允许远程登录

mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;



  评论这张
 
阅读(252)| 评论(1)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017