在安装服务器时做了相应的笔记,这个方法是亲身经验成功的,随着版本的不断更新,也许会有一些地方不同,但是基本原理都是一样的。

1.安装CentOS 6 ,可以选择最小安装,也可以安装桌面

2.升级系统

yum update
3.安装mysql,并设置mysql开机自启动,同时启动mysql

yum install mysql
yum install mysql-server
chkconfig --levels 35 mysqld on
service mysqld start

4.配置mysql的root密码

mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;

设置mysql密码还可以用:mysql_secure_installation 命令

mysql_secure_installation

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: (123456)
Re-enter new password: (123456)
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]

(是否移出数据库的默认帐户,如果移出,那么在终端中直接输入mysql是会提示连接错误的)Y

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
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
Reload privilege tables now? [Y/n] Y

**后来设置是否允许远程登录
mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
完成后就能用mysql-front远程管理mysql了。
设为开机启动
chkconfig mysqld on

5.安装apache,并设置开机启动

yum install httpd
chkconfig --levels 35 httpd on
service httpd start
这时候可以测试apache是否正常工作

直接浏览器访问localhost应该没问题,但是如果别的机子访问不了的话,是因为防火墙的关系,配置防火墙

(后面的ssl还会有这个问题的)

6.安装php

如果安装php53以下的版本的话,可能会导致项目放在这个环境中不能运行的情况,当时装的是php5.2结果发

现项目根本运行不起来,找了好久的原因才发现是php版本太低了(在这之前一直是以为json的原因,因为

php5.2没有json扩展),所以在安装前一定要看好版本在安装,否则以后项目出现问题不好找出原因。

yum install php53

yum install php53-mysql php53-gd php53-imap php53-ldap php53-odbc php53-pear php53-xml php53-

xmlrpc
这个时候php就安装完成拉,写个脚本测试一下

vi /var/www/html/info.php
输入

<?php
phpinfo();?>
访问localhost/info.php即可~

7.安装phpMyAdmin

首先先给系统安装epel 和rpmfushion两个软件大仓库

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/6/i386/rpmfusion-free-release-

6-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/6/i386/rpmfusion-

nonfree-release-6-0.1.noarch.rpm
如果是centos 5 的话执行下面

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/5/i386/rpmfusion-free-release-

5-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/5/i386/rpmfusion-

nonfree-release-5-0.1.noarch.rpm
接着安装起来就很方便拉,~根本不需要去下载就可以获得最新的版本

yum install phpmyadmin
安装完成后还需要配置一下访问权限,使得出了本机外,其他机子也能访问phpMyAdmin

vi /etc/httpd/conf.d/phpMyAdmin.conf
找到两个directory的权限设置,Allow from 改成All

<Directory /usr/share/phpMyAdmin/>
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from All
</Directory>
<Directory /usr/share/phpMyAdmin/setup/>
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from All
</Directory>

重启服务器

service httpd restart
测试localhost/phpMyAdmin

用户名密码:root 123456

OK~ LAMP搭建完毕,

8.搭建SSL,让apache支持https

yum install mod_ssl
其实安装完这个模块后,重启完apache 就可以用https://localhost测试了,因为他创建了默认的证书

在/etc/pki/tls下

当然我们也可以用openssl创建自己的证书

yum install openssl
生成证书文件
创建一个rsa私钥,文件名为server.key

openssl genrsa -out server.key 1024

Generating RSA private key, 1024 bit long modulus
............++++++
............++++++
e is 65537 (0x10001)

用 server.key 生成证书签署请求 CSR

openssl req -new -key server.key -out server.csr
Country Name:两个字母的国家代号
State or Province Name:省份名称
Locality Name:城市名称
Organization Name:公司名称
Organizational Unit Name:部门名称
Common Name:你的姓名
Email Address:地址
至于 'extra' attributes 不用输入.直接回车

生成证书CRT文件server.crt。

openssl x509 -days 365 -req -in server.csr -signkey server.key -out server.crt
修改ssl.conf指定我们自己生成的证书

vi /etc/httpd/conf.d/ssl.conf
找到如下位置,修改路径

# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill -HUP will prompt again. A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/localhost.crt

# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

OK

service httpd restart

yum install vsftpd

2.启动/重启/关闭vsftpd服务器
/sbin/service vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]
OK表示重启成功了.
启动和关闭分别把restart改为start/stop即可.
如果是源码安装的,到安装文件夹下找到start.sh和shutdown.sh文件,执行它们就可以了.

根据下面修改

vi /etc/vsftpd/vsftpd.conf

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO

# if your users expect that (022 is used by most other ftpd's)
local_umask=022
local_root=/

vi /etc/vsftpd/ftpusers

# Users that are not allowed to login via ftp
#root

vi /etc/vsftpd/user_list

# for users that are denied.
#root

防火墙配置 
a.添加.允许访问端口{80: http}. 
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
b.关闭防火墙{不推荐}. 
service iptables stop 
c.重置加载防火墙 
service iptables restart

centOs下的php+mysql+apache+ftp配置的更多相关文章

  1. CentOS下通过yum安装svn及配置

    CentOS下通过yum安装svn及配置 1.环境centos5.5 2.安装svnyum -y install subversion 3.配置 建立版本库目录mkdir /www/svndata s ...

  2. CentOS下使用yum安装Apache极为方便,只需要在终端键入以下命令即可

    CentOS下使用yum安装Apache极为方便,只需要在终端键入以下命令即可 1.安装Apache yum install httpd 2.设置服务器开机自动启动Apache systemctl e ...

  3. 在CentOS下自动备份mysql

    在CentOS下自动备份mysql数据库,并差异同步到其它网络主机上 1.在/root/mysql_backup/下添加backup.sh:vim /root/mysql_backup/backup. ...

  4. CentOS下Samba文件服务器的安装与配置

    CentOS下Samba文件服务器的安装与配置 http://blog.csdn.net/limingzhong198/article/details/22064801 一.安装配置 1. 安装sam ...

  5. centos下彻底删除mysql的方法

    本文记录了CentOS下MySQL的彻底卸载,供大家参考,具体内容如下: 1.查看MySQL是否安装 方式1: [root@localhost usr]# yum list installed mys ...

  6. Centos下MongoDB数据库的安装以及配置开机自启动(三)

    最近写了一个用node来操作MongoDB完成增.删.改.查.排序.分页功能的示例,并且已经放在了服务器上地址:http://39.105.32.180:3333. 在服务器上完全可以用yum来安装管 ...

  7. CentOS下nginx php mysql 环境搭建

    CentOS下搭建PHP运行环境. 首先是在虚拟机上装好一个命令行的CentOS,如果只是弄服务器的话,不要装图形界面,会比较卡. 一.安装编译工具及库文件 yum -y install make z ...

  8. CentOS 下编译安装MySQL

    CnetOS 下编译安装 MySql 查看是否存在旧版本: rpm -qa | grep mysql 卸载旧版本: rpm -e mysql   #普通删除模式 rpm -e --nodeps mys ...

  9. Linux (centos )下Nginx+PHP+MySQL配置——自己的lnmp配置

    说明:所有软件都是从官网上下载最新版的stable版本 ##################### 获取最新源码包###################### #建立独立的webserver#mkdi ...

随机推荐

  1. Xcode中插件的安装以及Xcode升级后插件实效的解决方法

    插件的安装 下载好插件,直接运行,然后将Xcode关闭,再次打开Xcode会弹出一个提醒框. 这时候选择 Load Bundle 即可,这时候插件就安装到了Xcode上. Xcode所有的插件都安装在 ...

  2. HDU 2458 - Kindergarten

    有一堆男孩和女孩,男孩和男孩之间,女孩和女孩之间互相认识,给出一堆男孩女孩之间认识的关系, 问一个组里最多多少人相互都认识 那么 二分图里 将不认识的连线 那么 相互认识的人最多 就为 最大独立点集 ...

  3. Mysql自定义变量的使用

    用户自定义变量是一个容易被遗忘的MySQL特性,但是如果能用的好,发挥其潜力,在某些场景可以写出非常高效的查询语句.在查询中混合使用过程化和关系化逻辑的时候,自定义变量可能会非常有用.单纯的关系查询将 ...

  4. oracle使用口令文件验证和os验证

    一.Oracle安装之后默认情况下是启用了OS认证的,这里提到的os认证是指服务器端os认证.OS认证的意思把登录数据库的用户和口令校验放在了操作系统一级.如果以安装Oracle时的用户登录OS,那么 ...

  5. 数据库 count和sum区别

    最近备考软考,复习数据库时候,发现count和sum,貌似差不错.就仔细查了查. 表 人 id name number 1 贱人 3 2 好人 4 select count(number) from ...

  6. knockout简单实用教程2

    在上一篇文章中简单了介绍了下什么ko(后文中都已ko来代替knockout.js)和一些简单的ko的使用方法下面我将介绍在实际的项目中常用到的几种绑定方式和方法. 在开始之前先拿一个dome来回顾下k ...

  7. .Net MVC4 加.html后缀报404问题

    一.配置方法: routes.MapRoute( name: "User_Default1", url: "user/{action}.html", defau ...

  8. MYSQL 查看表定义的 4 种方法

    方法 1. show create table table_name;可以用这个看表的代码. show create table Strings; 方法 2. show full columns fr ...

  9. 关于listener

    View.OnKeyListener |_____onKey(View v, int keyCode, KeyEvent event) View.OnTouchListener |_____onTou ...

  10. js的数组操作

    用 js有很久了,但都没有深究过js的数组形式.偶尔用用也就是简单的string.split(char).这段时间做的一个项目,用到数组的地方很多,自以为js高手的自己居然无从下手,一下狠心,我学!呵 ...