magento要求apache1.x或2.x,本文用2.2.9,下载httpd-2.2.9.tar.gz并放入opt目录下
安装过程如下:
[root@localhost opt]# tar zxvf httpd-2.2.9 [root@localhost opt]# cd httpd-2.2.9 [root@localhost httpd-2.2.9]# ./configure --prefix=/opt/apache2 \ --sysconfdir=/etc/httpd --with-z --with-included-apr --enable-so \ --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support [root@localhost httpd-2.2.9]# make && make install
安装完后通过如下指令启动和关闭
[root@localhost httpd-2.2.9]# /opt/apache2/bin/apachectl start
[root@localhost httpd-2.2.9]# /opt/apache2/bin/apachectl stop
在浏览器中输入:http://localhost/访问,可得到如下返回
为了方便,可以将apache服务设定为开机自动启动:
echo "/opt/apache2/bin/apachectl start" >> /etc/rc.d/rc.local
magento对mysql的要求:
[root@localhost httpd-2.2.9]# cd ..
[root@localhost op]# cd cd mysql-5.0.41 [root@localhost mysql-5.0.41]# groupadd mysql [root@localhost mysql-5.0.41]# useradd -g mysql mysql [root@localhost mysql-5.0.41]# ./configure --prefix=/opt/mysql --with-extra-charsets=all --with-charset=utf8 --with-plugins=all -with-pthread [root@localhost mysql-5.0.41]# make [root@localhost mysql-5.0.41]# make install
说明:
安装好后,需要进行一些设置
[root@localhost mysql-5.0.41]# cp support-files/my-medium.cnf /etc/my.cnf [root@localhost mysql-5.0.41]# cd /opt/mysql [root@localhost mysql]# bin/mysql_install_db --user=mysql [root@localhost mysql]# chown -R root . [root@localhost mysql]# chown -R mysql var [root@localhost mysql]# chgrp -R mysql .
上面的指令依次是:
考本配置文件
切换到mysql安装目录
创建授权表
将文件的所有属性改为root用户
将数据目录的所有属性改为mysql用户
将组属性改为mysql组
接下来就可以启动mysql了
[root@localhost mysql]# bin/mysqld_safe --user=mysql & [1] 31635 [root@localhost mysql]# Starting mysqld daemon with databases from /opt/mysql/var
简单测试一下:
[root@localhost mysql]# bin/mysqladmin version bin/mysqladmin Ver 8.41 Distrib 5.0.41, for pc-linux-gnu on i686
mysql安装好后的root是没有密码的,可以直接进入。所以现在需要进入root用户并为其创建密码
同时,mysql默认的用户还有127.0.0.1等,它们的密码也都为空,本文将这些非root用户全部删除,只留root,并这是密码为123456
登录mysql:
[root@localhost mysql]# bin/mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.0.41-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
设置用户
mysql> DELETE FROM mysql.user WHERE Host='localhost' AND User=''; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456'); Query OK, 0 rows affected (0.00 sec) mysql> exit Bye [root@localhost mysql]#
测试用户和密码
[root@localhost mysql]# bin/mysql -u root -h localhost -p Enter password:
输入123456后回车
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.0.41-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
最后可以关闭mysql,语法:
bin/mysqladmin -u root -p shutdown
magento对php的要求
本文选择php-5.2.6.tar.gz,除了magento要求的扩展以外,还添加了一些常用的扩展。
安装:
[root@localhost mysql]# cd /opt/
[root@localhost opt]# tar zxvf php-5.2.6.tar.gz
[root@localhost opt]# cd php-5.2.6
[root@localhost php-5.2.6]# ./configure --prefix=/opt/php --with-config-file-path=/opt/php/etc \
--with-apxs2=/opt/apache2/bin/apxs --with-mysql=/opt/mysql/ \
--with-gd --with-zlib=shared --with-sqlite=shared --with-mcrypt --with-curl --with-iconv \
--with-mhash=shared --with-mysqli=/opt/mysql/bin/mysql_config --enable-soap --enable-mbstring=all \
--enable-sockets --enable-ftp --enable-bcmath --with-pdo-mysql
[root@localhost php-5.2.6]# make && make install
[root@localhost php-5.2.6]# cp php.ini-dist /opt/php/etc/php.ini
[root@localhost php-5.2.6]# vi /etc/httpd/httpd.conf
[root@localhost php-5.2.6]# /opt/apache2/bin/apachectl stop
[root@localhost php-5.2.6]# /opt/apache2/bin/apachectl start
下面些个测试
[root@localhost php-5.2.6]# vi /opt/apache2/htdocs/test.php
写好后,在浏览器中输入:http://localhost/test.php
可以在浏览器中看到解析完后的php信息
到此,lamp已经搭建好了。下面安装一些辅助软件。
[root@localhost php-5.2.6]# cd /opt/
[root@localhost opt]# tar zxvf ZendOptimizer-3.2.6-linux-glibc21-i386.tar.gz
[root@localhost opt]# cd ZendOptimizer-3.2.6-linux-glibc21-i386
[root@localhost ZendOptimizer-3.2.6-linux-glibc21-i386]# ./install.sh
[root@localhost ZendOptimizer-3.2.6-linux-glibc21-i386]# cd /opt/
[root@localhost opt]# tar zxvf phpMyAdmin-3.0.0-rc1-all-languages.tar.gz
[root@localhost opt]# cp -a phpMyAdmin-3.0.0-rc1-all-languages /opt/apache2/htdocs/phpmyadmin
[root@localhost opt]# cd /opt/apache2/htdocs/phpmyadmin
[root@localhost phpmyadmin]# cp config.sample.inc.php config.inc.php
phpmyadmin有三种模式:http、cookie、config
这个可以在config.inc.php中进行配置
这里要强调的是,如果用cookie配置,则要注意在这个配置文件中的提示:
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
$cfg['blowfish_secret'] = '****'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
只有,输入http://localhost/phpmyadmin/index.php即可使用
也可以配置apache的配置文件
vi /etc/httpd/httpd.conf
将
DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html
以后输入http://localhost/phpmyadmin即可访问phpmyadmin。
在http://www.magentocommerce.com/download上下载 magento1.6
我下载的是tar.gz格式
在安装之前,还应该下载官方提供的测试数据,并创建一个数据库,将测试数据库的sql语句导入
本文创建的数据库为magento
mysql> create database magento;
Query OK, 1 row affected (0.00 sec)
mysql> use magento;
Database changed
mysql> source /opt/apache2/htdocs/magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql;
将下载的magento1.6压到apahce的发布目录下面,本文的是/opt/apache2/htdocs/,把样列的media文件夹也拷贝到magento的对应目录下。本文是/opt/apache2/htdocs/magento/media
设置magento的权限:
[root@localhost htdocs]# chmod -R 777 magento
输入http://127.0.0.1/magento,页面会自动跳转到安装界面,根据提示操作
遇到如下问题:
PHP Extensions "pdo_mysql" must be loaded.
这是之前装php网络添加--with-pdo-mysql ,即没有安装pdo-mysql扩展
没关系,php可以单独安张这些扩展:
本文还是采用源码包里面的程序来安装:
首先进入/opt/php-5.2.6/ext/pdo_mysql目录,进行如下操作(php-5.2.6是php源码的位置)
[root@localhost pdo_mysql]# /opt/php/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
[root@localhost pdo_mysql]# ./configure --with-php-config=/opt/php/bin/php-config --with-pdo-mysql=/opt/mysql/
[root@localhost pdo_mysql]# make
[root@localhost pdo_mysql]# make install
Installing shared extensions: /opt/php/lib/php/extensions/no-debug-non-zts-20060613/
生成的扩展放在/opt/php/lib/php/extensions/no-debug-non-zts-20060613/目录下
修改配置文件:
vi /opt/php/etc/php.ini
将:extension_dir = "./"
改为:extension_dir = "/opt/php/lib/php/extensions/no-debug-non-zts-20060613/"
并添加extension=pdo_mysql.so
重启服务后,继续安装即可
这里安装都采用模认设置。之后会继续讨论如何加入ssl