讲稿12 CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL)
讲稿12 CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL)
准备篇:
1、配置防火墙,开启80端口、3306端口
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙
备注:不要把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,
正确的应该是添加到默认的22端口这条规则的下面
如下所示:
>>>>>>>>>>>## Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT诞怎么读?
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
>>>>>>>>>>>#
/
etc/init.d/iptables restart #重启防火墙使配置生效
2、关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq!#保存退出
shutdown -r now#重启系统
安装篇:
一、安装Apache
yum install httpd #根据提示,输入Y安装即可成功安装
/etc/init.d/httpd start#启动Apache
备注:Apache启动之后会提示错误:
正在启动httpd:httpd: Could not reliably determine the server's fully qualif domain name, u
sing ::1 for ServerName
解决办法:
vi /etc/httpd/f #编辑
到 #ServerName修改为ServerNamewww.aaaa:80 #这里设置为你自己的域名,如果没有域名,可以设置为localhost
:wq! #保存退出
chkconfighttpd on #设为开机启动
/etc/init.d/httpd restart #重启Apache
二、安装MySQL
1、安装MySQL
yum installmysqlmysql-server #询问是否要安装,输入Y即可自动安装,直到安装完成
/etc/init.d/mysqld start #启动MySQL
chkconfigmysqld on #设为开机启动
cp /usr/share/mysql/my-mediumf /etc/myf #拷贝配置文件(注意:如果/etc目录下面默认有一个myf,直接覆盖即可)
2、为root账户设置密码
mysql_secure_installation
回车,根据提示输入Y
输入2次密码,回车
根据提示一路输入Y
最后出现:Thanks for using MySQL!
mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQLSERVERS 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): <-- 输入系统root密码
OK, successfully used password,
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] <-- ENTER
New password: <-- 你的MySQL root密码
Re-enter new password: <-- 你的MySQL root密码
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
黑匣子拼音1. 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] <-- ENTER
... 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] <-- ENTER
... Success!
By default, MySQL comes with a database named 'test' that anyone can
1. 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] <-- ENTER
- Dropping
... Success!
- Removing privileges on
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <-- ENTER
... Success!
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!

MySql密码设置完成,重新启动 MySQL:
/etc/init.d/mysqld restart #重启
/etc/init.d/mysqld stop #停止
/etc/init.d/mysqld start #启动
三、安装PHP5
1、安装PHP5
yum install php #根据提示输入Y直到安装完成
2、安装PHP组件,使 PHP5 支持 MySQL
yum install php-mysqlphp-gdlibjpeg* php-imapphp-ldapphp-odbcphp-pear php-xml php-xmlrpcphp-mbstringphp-mcryptphp-bcmathphp-mhashlibmcrypt #这里选择以上安装包进行安装,根据提示输入Y回车
/etc/init.d/mysqld restart #重启MySql
/etc/init.d/httpd restart #重启Apche
注:以上操作可简化为:
1. 安装Apahce, PHP, MySQL以及php连接mysql库组件。
#yum -y install httpdphpmysqlmysql-server php-mysql
2. 安装apache扩展
#yum -y install httpd-manual mod_sslmod_perlmod_auth_mysql
3. 安装php的扩展
#yum -y install php-gdphp-xml php-mbstringphp-ldapphp-pear php-xmlrpc
4. 安装MySQL的扩展
#yum -y install mysql-connector-odbcmysql-devellibdbi-dbd-mysql
四、安装配置phpMyAdmin
安装好MySQL,Apache及PHP后,为了可视化的管理MySQL数据库,我们需要安装phpMyAdmin。
4.1 下载最新版本phpMyAdmin,下载地址:www.phpmyadmin/home_page/dow
nloads.php,选择最新版本,如phpMyAdmin-4.2.0-all-languages.tar.bz2
4.2 解压程序包
张敬轩 占中
tar -xvf phpMyAdmin-4.2.0-all-languages.tar.bz2
4.3 移动目录phpMyAdmin-4.2.0-all-languages到/usr/share/phpMyAdmin文件夹(建议手工操作,复制粘贴至/usr/share/目录下,后重命名文件名为phpMyAdmin,使用下面的命令行可能导致打开localhost/phpmyadmin时,提示403错误,暂时不知怎么回事- -!)
mv phpMyAdmin-4.2.0-all-languages /usr/share/phpMyAdmin八百彪兵奔北坡
4.4 进入phpMyAdmin目录
cd /usr/share/phpMyAdmin
4.5 拷贝样本配置文件到config.inc.php文件
cpconfig.sample.inc.phpconfig.inc.php
4.6 修改Apache配置
vi /etc/httpd/conf.d/phpmyadmin.conf
4.7 写入如下内容
火炬之光2灰烬法师加点
#
#  Web application to manage MySQL
#
#<Directory "/usr/share/phpMyAdmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>
Alias /phpmyadmin /usr/share/phpMyAdmin
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /mysqladmin /usr/share/phpMyAdmin
写入并退出
广告费扣除标准
:w
:q
4.8 重启Apache服务器
/etc/init.d/httpd restart
4.9 至此,打开页面localhost/phpmyadmin即可轻松管理你的mySQL数据库

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论