lamp组合
L: Linux, A: apache (httpd), M: MySQL (MariaDB), P (php, python, perl, ruby)
下面是基于rpm包的格式来实现lamp的。
- php-5.3.3-46.el6_6.x86_64
- httpd-2.2.15-47.el6.centos.x86_64
- mysql-5.1.73-5.el6_6.x86_64
先在centso6.6上安装以上程序包。
1.php的相关文件,它和httpd的结合是模块化的。php只是一个模块,所以无需启动服务
[[email protected] htdocs]# rpm -ql php
/etc/httpd/conf.d/php.conf
/usr/lib64/httpd/modules/libphp5.so
/var/lib/php/session
/var/www/icons/php.gif
2.启动httpd,查看php模块
[[email protected] ~]# /usr/sbin/httpd -M
Loaded Modules:
core_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
auth_basic_module (shared)
auth_digest_module (shared)
authn_file_module (shared)
authn_alias_module (shared)
authn_anon_module (shared)
authn_dbm_module (shared)
authn_default_module (shared)
authz_host_module (shared)
authz_user_module (shared)
authz_owner_module (shared)
authz_groupfile_module (shared)
authz_dbm_module (shared)
authz_default_module (shared)
ldap_module (shared)
authnz_ldap_module (shared)
include_module (shared)
log_config_module (shared)
logio_module (shared)
env_module (shared)
ext_filter_module (shared)
mime_magic_module (shared)
expires_module (shared)
deflate_module (shared)
headers_module (shared)
usertrack_module (shared)
setenvif_module (shared)
mime_module (shared)
dav_module (shared)
status_module (shared)
autoindex_module (shared)
info_module (shared)
dav_fs_module (shared)
vhost_alias_module (shared)
negotiation_module (shared)
dir_module (shared)
actions_module (shared)
speling_module (shared)
userdir_module (shared)
alias_module (shared)
substitute_module (shared)
rewrite_module (shared)
proxy_module (shared)
proxy_balancer_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_ajp_module (shared)
proxy_connect_module (shared)
cache_module (shared)
suexec_module (shared)
disk_cache_module (shared)
cgi_module (shared)
version_module (shared)
php5_module (shared) php的模块已加载了
ssl_module (shared)
3.在httpd的根目录下新建一个已php结尾的文件。即在/vhosts/a.com/htdocs,新建index.php
[[email protected] htdocs]# cat index.php
<h1>www.a.com</h1>
<?php
phpinfo();
?>
4.在浏览器打开测试index.php
出现这个界面说明php模块已加载在httpd中了。
5.接下来就要安装mysql,要想php能连接mysql,必须先安装php-mysql这个程序包。
6.yum install php-mysql -y
[[email protected] htdocs]# yum info php-mysql
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirror.neu.edu.cn
* updates: mirror.neu.edu.cn
Installed Packages
Name : php-mysql
Arch : x86_64
Version : 5.3.3
Release : 46.el6_6
Size : 216 k
Repo : installed
From repo : updates
Summary : A module for PHP applications that use MySQL databases
URL : http://www.php.net/
License : PHP
Description : The php-mysql package contains a dynamic shared object that will add
: MySQL database support to PHP. MySQL is an object-relational database
: management system. PHP is an HTML-embeddable scripting language. If
: you need MySQL support for PHP applications, you will need to install
: this package and the php package.
7.安装完成php-mysql后,重新加载一下httpd,看phpinfo页面中是否有了mysql相关的说明。如果有说明连接数据库成功了。
8.现在安装mysql,因为我们需要连接的是mysql服务器,所以这里我们需要安装是mysql-server-5.1.73-5.el6_6.x86_64。mysql-5.1.73-5.el6_6.x86_64这是客户端。启动服务,并查看端口。
通过上面的步骤,我们的lamp环境已然搭建完毕。接下来我们在lamp中部署WordPress和phpmyadmin。
- 下载程序包
wordpress-4.3.1-zh_CN.zip
phpMyAdmin-4.4.15-all-languages.zip
分别解压到httpd的根目录下
tar xf wordpress-4.3.1-zh_CN.zip
[[email protected] htdocs]# cd wordpress
[[email protected] wordpress]# ll
total 176
-rw-r--r-- 1 root root 418 Sep 3 11:33 index.php
-rw-r--r-- 1 root root 19930 Sep 3 11:33 license.txt
-rw-r--r-- 1 root root 6789 Sep 16 22:38 readme.html
-rw-r--r-- 1 root root 4951 Sep 3 11:33 wp-activate.php
drwxr-xr-x 9 root root 4096 Sep 16 22:38 wp-admin
-rw-r--r-- 1 root root 271 Sep 3 11:33 wp-blog-header.php
-rw-r--r-- 1 root root 5007 Sep 3 11:33 wp-comments-post.php
-rw-r--r-- 1 root root 2930 Sep 16 22:38 wp-config-sample.php
drwxr-xr-x 5 root root 4096 Sep 16 22:38 wp-content
-rw-r--r-- 1 root root 3286 Sep 3 11:33 wp-cron.php
drwxr-xr-x 12 root root 4096 Sep 16 22:38 wp-includes
-rw-r--r-- 1 root root 2380 Sep 3 11:33 wp-links-opml.php
-rw-r--r-- 1 root root 3123 Sep 3 11:33 wp-load.php
-rw-r--r-- 1 root root 34669 Sep 3 11:33 wp-login.php
-rw-r--r-- 1 root root 8252 Sep 3 11:33 wp-mail.php
-rw-r--r-- 1 root root 11062 Sep 3 11:33 wp-settings.php
-rw-r--r-- 1 root root 25124 Sep 3 11:33 wp-signup.php
-rw-r--r-- 1 root root 4035 Sep 3 11:33 wp-trackback.php
-rw-r--r-- 1 root root 3055 Sep 3 11:33 xmlrpc.php
我们编辑一下wp-config-sample.php,
cp wp-config-sample.php wp-config.php
vim wp-config.php 只需编辑以下3个地方,其他暂时不管
define(‘DB_NAME‘, ‘wpdb‘);
define(‘DB_USER‘, ‘wpuser‘);
define(‘DB_USER‘, ‘wpuser‘);
然后创建wpdb数据库,并授权用户可以访问这个数据库
mysql> CREATE DATABASE wpdb;
GRANT ALL ON wpdb.* TO ‘wpuser‘@‘127.0.0.1‘ IDENTIFIED BY ‘wppass‘
GRANT ALL ON wpdb.* TO ‘wpuser‘@‘localhost‘ IDENTIFIED BY ‘wppass‘
mysql>FLUSH PRIVILEGES;
输入用户名和密码即可登录。
至于https的认证,这里简单介绍一下,由于之前已做了基于虚拟主机www.a.com的https认证,所以这里只需要把wordpress放入到/vhosts/a.com/htdocs路径下,就可基于https协议访问了。
tar xf phpMyAdmin-4.4.15-all-languages.zip
cd phpMyAdmin-4.4.15-all-languages
如果直接在浏览器中访问http://192.168.108.6/phpMyAdmin-4.4.15-all-languages/会报错,提示mbstring么有安装,所以必须要安装php-mbstring程序包。
yum install php-mbstring -y
[[email protected] htdocs]# service httpd reload
在这里输入用户名和密码即可登录成功。