Preface With the popularity of cloud computing, server prices are constantly decreasing. Therefore, this article is written to help those who are interested in IT or want to make themselves unique build their own personal website more conveniently. Show your uniqueness on your own website! 1. Introduction 1. Server This time we use UCloud's server (cloud host UHost), and the IP uses UCloud's elastic IP (if you are using other servers or cloud hosts from other friendly companies, the experimental steps in this article remain the same). 2. Backend The backend configuration is collectively referred to as LNMP, LNMP=Linux+Nginx+MySQL+PHP (that is, Nginx, MySQL, and PHP5 services are built in the Linux system). Nginx: Nginx (pronounced the same as engine x) is a web server that can reverse proxy HTTP, HTTPS, SMTP, POP3, IMAP protocol links, as well as a load balancer and an HTTP cache. MySQL: A relational database management system PHP: A scripting language that is executed on the server and embedded in HTML documents The Linux system is centos 6.5, and other services are installed using yum using the atomic package. 3. Frontend The front-end configuration is WordPress, which is a blogging platform developed using the PHP language. Users can build their own websites on servers that support PHP and MySQL databases. WordPress can also be used as a content management system (CMS). WordPress is configured as the latest configuration. (The package is latest.tar.gz) 4. Service comparison Generally, website services are built using LAMP or LNMP (A stands for Apache, N stands for Nginx).
Use environment:
2. Backend Configuration 1. Preparation (1) Tools: It is recommended to use xshell for remote operation. If you are using a cloud host, you need to log in to the console to operate when you encounter commands to turn on, off, or restart the machine (such as reboot). (2) Quickly locate the line number in Linux Enter the number of rows after the colon and press enter. Figure 1: Row number positioning (3) Linux quickly locates the character Enter the / character after the colon and press the enter key (to find the next one, press N) Figure 2: Character positioning (4) Enable iptables (open ports 80 and 3306) Note: Port 80 is open for http protocol (i.e. web pages); port 3306 is open for MySQL database 1) Add two iptables rules to enable it.
Figure 3: Modify iptables rules (put after 22) 2) Restart iptables
Figure 4: Restarting the firewall (5) Disable SELinux 1) Modify two SELinux rules
Figure 5: Modifying SELinux rules 2) Restart the server
(6) Install a third-party yum repository 1) Download the wget tool
Figure 6: Downloading the wget tool 2) Download the atmoic package Note: Atomic repositories support YUM package management for Fedora, RHEL, and CentOS
http://www.atomicorp.com/installers/atomic Figure 7: Downloading the atomic package 3) Install the atomic package
Figure 8: Installing the atomic package 4) Update the yum source
Figure 9: Updating the atomic package 2. Install backend services (1) Install Nginx 1) Delete the system's own software package
2) Install Nginx using yum
Figure 10: Installing Nginx 3) Set Nginx to start at boot
4) Start Nginx
Figure 11: Starting Nginx (2) Install MySQL 1) Install MySQL using yum
Note: yum install package name – y: automatically install all in the package, y means yes Figure 12: Installing MySQL 2) Start MySQL
Figure 13: Starting MySQL 3) Set MySQL to start at boot
4) Copy the my-medium.cnf configuration file
Note: If there is a my.cnf file in the /etc directory by default, you can directly overwrite it. Figure 14: Copying the my-medium.cnf configuration file 5) Set the MySQL root password
Figure 15: Click enter Figure 16: Enter Y to create a root password Figure 17: Enter password twice Figure 18: Remove anonymous user, enter Y Figure 19: Do not allow remote login with root privileges, enter Y Figure 20: Remove the test library and access it, enter Y Figure 21: Reload the privilege table, enter Y 6) Restart MySQL service
Figure 22: Restarting the MySQL service (3) Install PHP5 1) Install PHP with yum
Figure 23: Restarting the MySQL service 2) Install PHP components (PHP5 supports MySQL)
Figure 24: Install PHP component, select yes Figure 25: Final result of installing PHP components 3) Set php-fpm to start at boot
4) Start php-fpm
Figure 26: Starting php-fpm 3. Configure backend services (1) Nginx supports PHP 1) Back up the nginx.conf configuration file
Figure 27: Back up the nginx.conf configuration file 2) Edit the nginx.conf configuration file
user nginx nginx; The user name of the user added to the Nginx group is nginx Figure 28: Editing the nginx.conf configuration file 3) Back up the default.conf configuration file
Figure 29: Back up the default.conf configuration file 4) Edit the default.conf configuration file
Add in location
Figure 30: Adding index format in location Add a
Figure 31: Add a php rule 5) Restart Nginx
Figure 32: Restarting Nginx (2) Configure PHP 1) Edit configuration
Line 211: Change to short_open_tag=ON Figure 33: Modify line 211 Line 375: Change to expose_php = off Figure 34: Modify line 375 Line 878: Change to date.timezone = PRC Figure 35: Modify line 878 (3) Configure php-fpm 1) Back up the php-fpm configuration file
2) Edit the configuration
Change apache to nginx
Figure 36: Original www.conf diagram Figure 37: Current www.conf diagram (4) Testing 1) Enter HTML
4.2) Edit the index.php file
Editing content:
Note: The parameters of the mysql_connect() function are: mysql server name or IP, mysql user name, and mysql user password. Figure 38: Edit index.php content 3) Set permissions
4) Restart nginx
Figure 39: Restart Nginx 5) Restart php-fpm
Figure 40: Restart php-fpm Log in to the website using a personal computer: Figure 41: MySQL connection successful Prove that MySQL connection is successful! 6) Modify the index.php file
Modifications:
Figure 42: index.php content 7) Restart nginx
Figure 43: Restarting Nginx 8) Restart php-fpm
Figure 44: Restart php-fpm 9) Enter the server IP address to access the web page UCloud cloud host:
Figure 45: Cloud host searches for the eip address Log in to the website using a personal computer: Figure 46: Personal computer browser login web page Prove that LNMP's backend test was successful! [This article is an original article by 51CTO columnist "Big U's Technology Classroom". For reprinting, please contact the author through the WeChat public account (ucloud2012)] Click here to read more articles by this author |
<<: Thanks to China, Apple finally allows the "reward" function
>>: When it comes to dealing with tricky bugs, what’s the difference between novices and experts?
Apple recently released the official iOS 11 syste...
The Chinese names of plants are like refined code...
During the 2018 Tokyo Tuning Show, Honda official...
Osteoarthritis: a growing global disease burden O...
Author: Cui Xiaobing background Apple's Objec...
Yesterday, after the road test spy photos of Chan...
As the saying goes, "Sugarcane during Qingmi...
The traffic rankings of major information flow pl...
At present, global climate change, especially glo...
In this article, the author will describe Douyin’...
Produced by: Science Popularization China Author:...
On Youth Day, I saw a trending search on the topi...
...
When it comes to Tencent's fight against comm...
There are still two days until New Year’s Eve! Re...