實驗之前最好把firewalld和selinux關(guān)閉了,避免對實驗造成影響.步驟就不詳細列出來了,下面開始正式安裝walle
操作系統(tǒng):centos 7.2 x86_64
1.安裝lnmp環(huán)境
建議使用centos7 yum安裝,需要先安裝php5.6版本,centos7默認yum倉庫的php版本是5.4的,walle安裝要求提供php5.5版本以上的夺脾,避免walle系統(tǒng)不兼容.walle安裝在LAMP/LNMP的linux機器上作為宿主機.
這里提供了centos6.5和centos7.0的安裝php5.6的方法.
配置yum源
追加CentOS 6.5的epel及remi源。
# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
以下是CentOS 7.0的源肉瓦。
# yum install epel-release
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
使用yum list命令查看可安裝的包(Packege)贞绵。
# yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
yum源配置好了屁魏,安裝LAMP/LNMP環(huán)境秆撮。
# yum install --enablerepo=remi --enablerepo=remi-php56 php \
php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd \
php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-bcmath \
php-fpm php-gd* php-json freetype freetype-devel php-mbstring \
php-mcrypt php-mysql php-opcache php-pdo php-pdo_dblib php-pgsql \
php-recode php-snmp php-soap php-xml hp-pecl-zip mhash libmcrypt \
libmcrypt-devel mariadb mariadb-server nginx
用PHP命令查看版本劳曹。
# php --version
顯示為5.6版本就ok了
2.創(chuàng)建walle的web目錄
這個web根目錄需要配置nginx指向為root,后面會詳述.這里先創(chuàng)建walle的文件路徑為 /data/www/walle-web
下載walle-web.zip并解壓(下載地址:https://github.com/meolu/walle-web)
新建目錄
mkdir -p /data/www/walle-web && cd /data/www/walle-web
因為下載的walle是在github上可以直接用git工具下載
yum -y install git
使用git工具下載
[root@localhost walle-web]# git clone https://github.com/meolu/walle-web
Cloning into 'walle-web'...
remote: Counting objects: 4685, done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 4685 (delta 18), reused 30 (delta 10), pack-reused 4627
Receiving objects: 100% (4685/4685), 14.13 MiB | 1.30 MiB/s, done.
Resolving deltas: 100% (2609/2609), done.
查看已經(jīng)下載并解壓好了
[root@localhost walle-web]# ls
walle-web
[root@localhost walle-web]# cd walle-web/
[root@localhost walle-web]# pwd
/data/www/walle-web/walle-web
[root@localhost walle-web]# ls
assets composer.json config controllers Dockerfile LICENSE messages models runtime vendor web yii
components composer.lock console docker docs mail migrations README.md tests views widgets
3.設(shè)置mariadb數(shù)據(jù)庫(mysql的操作一樣)
只需要創(chuàng)建數(shù)據(jù)庫捣辆,建表的操作交給walle的setup.php安裝程序.
先啟動mysql并初始化
[root@localhost walle-web]# systemctl start mariadb.service
[root@localhost walle-web]# mysql_secure_installation
#一定要初始化用戶名和密碼,要不初始化./yii walle/setup 會數(shù)據(jù)庫報錯
登陸mysql并創(chuàng)建庫與用戶密碼
[root@localhost walle-web]# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database walle charset=utf8mb4 collate utf8mb4_unicode_ci;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on walle.* to 'walleuser'@'%' identified by 'wallepass';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
修改walle的web連接 vim /data/www/walle-web/walle-web/config/local.php
return [
'components' => [
'db' => [
'dsn' => isset($_ENV['WALLE_DB_DSN']) ? $_ENV['WALLE_DB_DSN'] : 'mysql:host=127.0.0.1;dbname=walle', #庫名稱
'username' => isset($_ENV['WALLE_DB_USER']) ? $_ENV['WALLE_DB_USER'] : 'walleuser', #用戶名
'password' => isset($_ENV['WALLE_DB_PASS']) ? $_ENV['WALLE_DB_PASS'] : 'wallepass', #密碼
],
4.安裝composer
[root@localhost walle-web]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...
Composer (version 1.7.2) successfully installed to: /data/www/walle-web/walle-web/composer.phar
Use it: php composer.phar
[root@localhost walle-web]#
[root@localhost walle-web]# mv composer.phar /usr/local/bin/composer
5.安裝vendor
在walle根目錄下安裝
cd /data/www/walle-web/walle-web/
composer install --prefer-dist --no-dev --optimize-autoloader -vvvv
安裝速度慢或失敗蔬螟,可直接下載vendor解壓到項目根目錄
(即/data/www/walle-web/walle-web/目錄下)
6.初始化項目
cd /data/www/walle-web/walle-web
./yii walle/setup # 需要輸入yes
7.配置nginx
刷新頁面看到50x或者404均是nginx配置不當,需要查看nginx日志,這里放出nginx簡單配置在 vim /etc/nginx/nginx.conf
文件中修改添加如下配置.
server {
listen 80;
server_name 192.168.0.102; # 改你的host
root /data/www/walle-web/walle-web/web; # 根目錄為web
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
保存退出之后,重啟php-fpm和nginx服務(wù)
[root@localhost walle-web]# systemctl restart php-fpm nginx
8.訪問地址:http://192.168.0.102
管理員默認賬戶密碼都為:
admin
這樣centos7上的walle就算搭建成功了.