CentOS使用yum源中自带的rpm包安装LAMP环境

1. 安装基础包(可选安装)
yum install -y wget zip unzip gzip
yum install -y python ruby perl
yum install -y gc gcc gcc-c++

2. 安装php及其相关组件
yum install -y php php-gd
yum install -y php-mbstring php-mcrypt php-mysql php-pdo

3. 启动httpd服务器
service httpd start
chkconfig httpd on 设置开机自动启动
服务器www目录地址/var/www/html/

4. 安装mysql
yum install -y mysql mysql-server
[root@localhost html]# service mysqld start

5. 配置mysql
根据提示运行
/usr/bin/mysql_secure_installation
按照提示对mysql进行配置,包括root密码设置等等。
chkconfig mysqld on 设置开机自动启动

6. 安装phpmyadmin
下载phpmyadmin相应版本 https://www.phpmyadmin.net/files/
将zip包copy到/var/www/html/目录,并解压缩重命名为phpmyadmin
例如:
wget https://files.phpmyadmin.net/phpMyAdmin/3.5.8.2/phpMyAdmin-3.5.8.2-all-languages.zip
unzip phpMyAdmin-3.5.8.2-all-languages.zip -d /var/www/html/
mv /var/www/html/phpMyAdmin-3.5.8.2-all-languages /var/www/html/phpmyadmin
访问 http://youripaddress/phpmyadmin/ 就可以根据 5. 配置mysql 中设置的root密码登录

7. 防火墙问题
购买的服务器一般镜像安装后都会默认开启22,80等常用端口。
自己安装centos到特定机器或vmware虚拟机安装的时候可能出现iptables没有配置导致80端口无法访问的问题。
临时禁用iptables的方法(重启机器后失效),使用命令 service iptables stop
千万不要在生产环境中这么做!

---------------------------------------------------
初次运行 service mysqld start 会有下面的提示,此处做好记录以备以后查看,
对数据库问题修复有至关重要的作用!!
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

[  OK  ]
Starting mysqld:  [  OK  ]

下面关于LAMP相关的内容你可能也喜欢

猜你喜欢

转载自www.linuxidc.com/Linux/2015-08/121753.htm
今日推荐