没有不值得去解决的问题,也没有不值得去学习的技术!

How to Install an LNMP Stack with OneinStack on Alibaba Cloud ECS CentOS 7 and Run the Yii2 Advanced Template

Fileinfo extension is installed

1. For the first connection, select Yes, as shown in Figure 1:

First connection, select Yes
First connection, select Yes

2. Because the instance type is I/O-optimized and the disk type is SSD cloud disk, refer to this URL: https://help.aliyun.com/knowledge_detail/6689611.html

3. Copy the download link for the tool auto_fdisk_ssd.sh, as shown in Figure 2:

http://aliyun_portal_storage.oss-cn-hangzhou.aliyuncs.com/help%2Fecs%2Fauto_fdisk_ssd.zip?spm=5176.776689611.0.0.DmH9za&file=help%2Fecs%2Fauto_fdisk_ssd.zip

Copy the download link for the tool auto_fdisk_ssd.sh
Copy the download link for the tool auto_fdisk_ssd.sh

4. Download the tool auto_fdisk_ssd.sh. After pasting the download link, you need to modify it, as shown in Figure 3:

wget http://aliyun_portal_storage.oss-cn-hangzhou.aliyuncs.com/help/ecs/auto_fdisk_ssd.zip

Download the tool auto_fdisk_ssd.sh. After pasting the download link, you need to modify it
Download the tool auto_fdisk_ssd.sh. After pasting the download link, you need to modify it

5. Extract auto_fdisk_ssd.zip, as shown in Figure 4:

unzip auto_fdisk_ssd.zip

Extract auto_fdisk_ssd.zip
Extract auto_fdisk_ssd.zip

6. Automatically detect whether there is an unpartitioned data disk, format the new data disk, and mount it automatically. Execute the command, as shown in Figures 5 and 6:

bash auto_fdisk_ssd.sh

Automatically detect whether there is an unpartitioned data disk, format the new data disk, and mount it automatically
Automatically detect whether there is an unpartitioned data disk, format the new data disk, and mount it automatically
Formatting the new data disk and mounting it automatically succeeded
Formatting the new data disk and mounting it automatically succeeded

7. Execute the command. Refer to the URL: http://oneinstack.com/install/ , as shown in Figure 7:

yum -y install wget screen python #for CentOS/Redhat

yum -y install wget screen python   #for CentOS/Redhat
yum -y install wget screen python #for CentOS/Redhat

8. Execute the command, as shown in Figure 8:

wget http://aliyun-oss.linuxeye.com/oneinstack-full.tar.gz #Download for Alibaba Cloud users

wget http://aliyun-oss.linuxeye.com/oneinstack-full.tar.gz #Download for Alibaba Cloud users
wget http://aliyun-oss.linuxeye.com/oneinstack-full.tar.gz #Download for Alibaba Cloud users

9. Execute the command, as shown in Figure 9:

tar xzf oneinstack-full.tar.gz

Extract oneinstack-full.tar.gz
Extract oneinstack-full.tar.gz

10. Edit the options.conf file and replace all instances of /data/ with /alidata1/, as shown in Figure 10:

cd oneinstack #If you need to change the directory (installation, data storage, Nginx logs), please modify the options.conf file

vim options.conf

Edit the options.conf file and replace all instances of /data/ with /alidata1/
Edit the options.conf file and replace all instances of /data/ with /alidata1/

11. Execute the command and restart at the end, as shown in Figures 11 and 12:

./install.sh #Note: Do not execute it as sh install.sh or bash install.sh

./install.sh
./install.sh
./install.sh
./install.sh

12. Open the IP address, as shown in Figure 13:

Open the IP address
Open the IP address

13. Add a virtual host, as shown in Figure 14:

Add a virtual host
Add a virtual host

14. Edit the /usr/local/nginx/conf/vhost/service.ygt.cm.conf file, as shown in Figure 15:

Edit the /usr/local/nginx/conf/vhost/service.ygt.cm.conf file
Edit the /usr/local/nginx/conf/vhost/service.ygt.cm.conf file

15. Add an FTP account, as shown in Figure 16:

./pureftpd_vhost.sh

Add an FTP account
Add an FTP account

16. Use FlashFXP to connect to FTP and finish uploading the program, as shown in Figure 17:

Use FlashFXP to connect to FTP and finish uploading the program
Use FlashFXP to connect to FTP and finish uploading the program
17

17. Edit the /usr/local/nginx/conf/vhost/service.ygt.cm.conf file, as shown in Figure 18:

service nginx restart

service php-rpm restart

Edit the /usr/local/nginx/conf/vhost/service.ygt.cm.conf file
Edit the /usr/local/nginx/conf/vhost/service.ygt.cm.conf file

18. Open the URL: http://service.ygt.cm , as shown in Figure 19:

Open the URL: http://service.ygt.cm
Open the URL: http://service.ygt.cm

19. Edit service.ygt.cm/www/config/main-local.php to enable URL optimization, as shown in Figure 20:

Edit service.ygt.cm/www/config/main-local.php to enable URL optimization
Edit service.ygt.cm/www/config/main-local.php to enable URL optimization

20. Open the URL: http://service.ygt.cm/site/about , which returns a 404 Not Found, as shown in Figure 21:

Open the URL: http://service.ygt.cm/site/about , which returns a 404 Not Found
Open the URL: http://service.ygt.cm/site/about , which returns a 404 Not Found

21. Edit the /usr/local/nginx/conf/rewrite/other.conf file, as shown in Figure 22:

Reference URL: http://www.yiiframework.com/doc-2.0/guide-start-installation.html

vim other.conf

location / {
# If a real existing file cannot be found, dispatch the request to index.php
try_files $uri $uri/ /index.php?$args;
}

If a real existing file cannot be found, dispatch the request to index.php
If a real existing file cannot be found, dispatch the request to index.php

22. Open the URL: http://service.ygt.cm/site/about , as shown in Figure 23:

Open the URL: http://service.ygt.cm/site/about
Open the URL: http://service.ygt.cm/site/about

23. Check whether the current PHP environment meets the most basic requirements of Yii. Copy requirements.php to service.ygt.cm/www/web/requirements.php and edit it, as shown in Figure 24:

$frameworkPath = dirname(__FILE__) . ‘/../../vendor/yiisoft/yii2’;

Check whether the current PHP environment meets the most basic requirements of Yii
Check whether the current PHP environment meets the most basic requirements of Yii

24. Open the URL: http://service.ygt.cm/requirements.php and find that the Fileinfo extension is not installed, as shown in Figure 25:

Open the URL: http://service.ygt.cm/requirements.php and find that the Fileinfo extension is not installed
Open the URL: http://service.ygt.cm/requirements.php and find that the Fileinfo extension is not installed

25. Refer to the URL: http://oneinstack.com/question/oneinstack-how-to-support-the-fileinfo/ to compile and install fileinfo, as shown in Figure 26:

Compile and install fileinfo
Compile and install fileinfo

26. Open the URL: http://service.ygt.cm/requirements.php and find that the Fileinfo extension is now installed, as shown in Figure 27:

Fileinfo extension is installed
Fileinfo extension is installed

27. Install the redis extension, as shown in Figure 28:

cd /usr/local/php/bin/
./pecl install redis

# Load fileinfo
echo ‘extension=redis.so’ > /usr/local/php/etc/php.d/ext-redis.ini

service php-fpm restart

Install the redis extension
Install the redis extension

28. Check phpinfo() and find that the redis extension is installed, as shown in Figure 29:

Check phpinfo() and find that the redis extension is installed
Check phpinfo() and find that the redis extension is installed

29. Configure php.ini to make session storage support redis, as shown in Figure 30:

vim /usr/local/php/etc/php.ini

; session.save_handler = files
session.save_handler = redis

; session.hash_function = 0
session.hash_function = “sha512”

session.save_path = “”

Finally, restart the ECS;

Configure php.ini to make session storage support redis
Configure php.ini to make session storage support redis

30. For security settings, rename or delete all files under /alidata1/wwwroot/default, as shown in Figure 31:

For security settings, rename or delete all files under /alidata1/wwwroot/default
For security settings, rename or delete all files under /alidata1/wwwroot/default

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系