首先 运行环境安装LAMP(Linux+Apache+Mysql+php):
第一步:更新系统内核(如果不想更新可以跳过本步)。
首先更新系统内核到最新,因为最新版的CentOS 6.3的php版本为 5.3,早起版本的CentOS的php版本也比较低。
执行命令:
yum -y update
注意:如果执行失败报错,可以执行修复命令:
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*
第二步: 安装Apahce、Mysql、PHP 及其基础扩展。
执行命令:
yum -y install httpd php php-mysql mysql mysql-server
第三步:安装PHP的其他常用扩展
执行命名:
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
第四步:安装Apache的扩展
执行命令:
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
执行完这四步软件就安装完成了,接下来要做一些常规的设置。
第五步:设置apache/mysql-server环境开机自动启动
执行命令:
# 设置apache为开机自启动 /sbin/chkconfig httpd on # 添加mysql服务 /sbin/chkconfig --add mysqld # 设置mysql为开机自启动 /sbin/chkconfig mysqld on
第六步:启动apache与msyql
分别执行命令:
service httpd start service mysqld start
如果开启httpd时显示Could not reliably determine the server`s fully qualified domain name
vi /etc/httpd/conf/httpd.conf 加入一句 ServerName localhost:80
如果还遇到 Permission denied: make_sock: could not bind to address.....
解决方案:
增加selinux中http的端口
semanage port -l|grep http #查看SELinux下http相关端口
semanage port -a -t http_port_t -p tcp 888 #增加这个非标准端口即可
第七步:设置mysql数据库root帐号密码
mysqladmin -u root password 'mysql的管理员密码'
其次 为wordpress创建数据库
1
mysql -u root -p
2
CREATE DATABASE gudianbook; Query OK, 1 row affected (0.00 sec)
3
CREATE USER gudianbookUser@localhost; Query OK, 0 rows affected (0.00 sec)
4
SET PASSWORD FOR gudianbookUser@localhost= PASSWORD("password"); Query OK, 0 rows affected (0.00 sec)
5
GRANT ALL PRIVILEGES ON gudianbook.* TO gudianbookUser@localhost IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec)
6
FLUSH PRIVILEGES;
7
exit
最后安装wordpress
1
cd /var/www
2
wget http://cn.wordpress.org/wordpress-4.0-zh_CN.zip
3
unzip wordpress-4.0-zh_CN.zip
4
cp -rf wordpress/* /var/www/html/
5
chmod -R 777 html
6
cd html
7
mv wp-config-sample.php wp-config.php
8 vi wp-config.php
/** MySQL数据库名 */ define(‘DB_NAME', ‘wordpress'); /** MySQL数据库用户名 */ define(‘DB_USER', ‘root'); /** MySQL数据库密码 */ define(‘DB_PASSWORD', ‘password') /** MySQL主机(不用修改) */ define(‘DB_HOST', ‘localhost');
并在最后加上
if(is_admin()) { add_filter('filesystem_method', create_function('$a','return "direct";' )); define('FS_CHMOD_DIR', 0751); } esp :wq VI退出 是先按esp 然后按: 最后是wq 很多资料都不说这个:,导致小白在这一步怎么也退不出。
9
service httpd restart