Use LAMP to build Typecho blog on ECs CentOS 7.6
In fact, LAMP is the initial letters of Linux, Apache, MySQL and PHP.
This demonstration uses the lightweight application server of Tencent cloud. Although you can choose what systems are pre installed in the cloud server during the purchase process, such as Baoxiang tower and LAMP, if you want to build them yourself, you are still recommended to try it.
2, ECS purchase
For the purchase of ECs, since they are all used for personal construction, you can choose freely in the configuration. Different suppliers may have different prices under the same configuration. There is no recommendation here. More comparison can see who is expensive and who is cheap. However, if it is an enterprise, it should focus on the load.
For example, the server I bought was purchased with a new account. I just rushed to Tencent cloud to engage in activities and won 80 yuan a year. The configuration is: cpu: 2 cores, memory: 8G, system disk: 80GB, traffic packet 1200G / month (bandwidth 8Mbps), which is still very fragrant.
3, ECS settings
1. Password setting
When you purchase the ECS, you will be asked to set a password. Don't forget this password. If you forget it, there will be an option to reset the password on the instance information page. Just click to reset it. Select the root user, enter the new password and confirm the password, and click Next. Generally, a verification message will be sent to your registered mobile phone number, Just enter the verification message.
2. Firewall settings
(1) Usually, when the ECS is purchased, the ECS manufacturer will open different ports by default according to the system type. By default, it seems that Alibaba cloud has only enabled SSH ports, and other ports are closed by default. Tencent cloud opens HTTP, HTTPS, SSH and Ping ICMP by default, which is not comprehensive. I may have opened these ports by default because I purchased a lightweight application server.
You can change different ports according to different needs, which is determined according to your own needs, but the SSH port must be turned on, otherwise you can't log in.
(2) Adding rules is also relatively simple. The application type can be set in advance by the cloud manufacturer or customized.
3. Snapshot settings
In fact, snapshots do not need too much explanation. Generally, those who have tossed about virtual machines know. Rollback is actually recovery. It seems that Tencent cloud calls rollback -. -. Deleting snapshots requires the verification code of the mobile phone number. After Tencent cloud binds the micro signal, it needs to be confirmed in the micro signal.
4. Monitoring settings
In fact, just look at the monitoring settings. There are not many visits and less resources. As for setting alarms, if you really want to build a large website for others to visit, you still need to set them, but many need money. If you play alone, you don't have to care too much.
For other configurations, wait until you have time to publish an article on ECs in the later stage! Let's get to the point.
4, Installing Apache services
##Installing Apache services [root@centos7 ~]# yum install -y httpd ##Set startup self startup [root@centos7 ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. ##Start Apache service [root@centos7 ~]# systemctl start httpd ##View Apache service status [root@centos7 ~]# systemctl status httpd ##In fact, it is not recommended to turn off the firewall for servers that are open to the outside world, but we will turn it off directly by making a demonstration here, and only use the firewall on the ECS for control. [root@centos7 ~]# systemctl stop firewalld
Open the browser, enter HTTP: / / ECS IP, and check whether the Apache service is running normally.
5, Install PHP services
##Install PHP [root@centos7 ~]# yum install -y php ##Install PHP driver [root@centos7 ~]# yum install -y php-mysql ##You can test whether the installation is successful [root@centos7 ~]# cd /var/www/html ##Go to the html directory first ##Make an info.php file first [root@centos7 html]# vim info.php <?php phpinfo(); ?> ##Restart Apache service [root@centos7 html]# systemctl restart httpd
Open the browser to access http: / / ECS ip/info.php
6, Install Maria DB database
Here's a reference. MySQL is slow and troublesome for the database used in an article about how to build a blog at the beginning.
```html ##Install Maria DB database [root@centos7 ~]yum install -y mariadb-server mariadb* ##Set database startup self startup [root@centos7 ~]# systemctl enable mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. ##Start database [root@centos7 ~]# systemctl start mariadb
```html ##Initialize Maria DB database and set root password ##Enter y in all places except the remarks! [root@centos7 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y #Select Y New password: #Input password Re-enter new password: #Confirm password Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
##Restart database [root@centos7 ~]# systemctl restart mariadb ##Log in to the database and create the database of typecho [root@centos7 ~]# mysql -uroot -p Enter password: ##Data password Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.68-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)]> grant all privileges on *.* to root@'%' identified by 'zxcvbnm'; #Set relevant permissions Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> create database typecho; #Create a library for typecho Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> flush privileges; #Reload related permissions Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> select User,Host,Password from mysql.user; +------+-----------+-------------------------------------------+ | User | Host | Password | +------+-----------+-------------------------------------------+ | root | localhost | *D1523220ED740182587AB4860EA1EF4ECEC0F0F5 | | root | 127.0.0.1 | *D1523220ED740182587AB4860EA1EF4ECEC0F0F5 | | root | ::1 | *D1523220ED740182587AB4860EA1EF4ECEC0F0F5 | | root | % | *7DE69B235B6AD96041172B949D90F88326B74612 | +------+-----------+-------------------------------------------+ 4 rows in set (0.00 sec) MariaDB [(none)]> exit #Exit database Bye
7, Installing typecho
Download:[typecho Download URL](http://typecho.org/download)
Upload the downloaded files to the ECS. I use xshell personal version to connect. You can try to enter rz first. If it shows that it is not installed, install it.
##Not installed [root@centos7 typecho]# rz -bash: rz: command not found ##Install lrzsz [root@centos7 typecho]# yum -y install lrzsz
After installation, you can enter rz again to open the interface of transferring files. Create a directory before transferring.
##Create typecho directory [root@centos7 ~]# mkdir typecho ##Switch to the typecho directory. Because uploading files will be uploaded to the current directory, it is best to use it in the newly created directory [root@centos7 ~]# cd typecho ##Upload the file and it will be displayed in the directory after uploading.
##Unzip the typecho installation package [root@centos7 typecho]# tar -xzvf 1.1-17.10.30-release.tar.gz ##After decompressing the input ls, you will see a build file. Cut this file to the root directory of the website / var/www/html [root@centos7 typecho]# cp -r build/* /var/www/html ##Delete the original info.php [root@centos7 html]# rm info.php
Open the browser and enter HTTP: / / ECS IP/install.php for subsequent installation.
After installation, you need to create a config.inc.php file
##Create the config.inc.php file and copy the contents into it. [root@centos7 ~]# cd /var/www/html [root@centos7 html]# vi config.inc.php
After setting, you can click to continue the installation, which is actually completed.
This completes the installation.
If you think the default theme is not very good-looking, you can go to Baidu to search for a good-looking theme.