Simple e-commerce website architecture based on LNMP

Source: Internet
Author: User

One: Experimental environment

CentOS 7 test machine

Chrome

Second: Experimental steps

※ Precautions

Before the experiment, check to see if Port 80 is occupied by the HTTPD service, if open, turn off the httpd service and make sure that port 80 is not turned on

1. Install the necessary software

Yum install mariadb mariadb-server php-fpm php php-mysql

2. Download the website source code, extract to/data/web/, and modify all the files in the directory of the owner and the group is nobody

Unzip-d/data/web/xiaomi.zip

Chown-r nobody.nobody/data/web/*

3. Modify PHP-FPM run users and groups to nobody, ensure security

Vim/etc/php-fpm.d/www.conf

user = Nobody

Group = Nobody

4. Modify Nginx configuration file && Restart Nginx service

①vim/etc/nginx/nginx.conf

User nobody; #全局配置

Error_log/var/log/nginx/error.log; # #错误日志文件

http{# #服务配置

Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" ' # #日志文件格式

' $status $body _bytes_sent ' $http _referer '

' "$http _user_agent" "$http _x_forwarded_for";

server{# #虚拟主机配置

root/data/web/; # #网页文件根目录

Access_log/var/log/nginx/host.access.log main; # #虚拟主机访问日志文件

Location/{

Index index.php index.html;

}

Location ~ \.php$ {

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Fastcgi_param script_filename $document _root$fastcgi_script_name;

Include Fastcgi_params;

}

}

}

②systemctl Restart Nginx
※ Friendly tips: If a service restart fails, use NGINX-T to debug the configuration file

5. Modify the PHP configuration file && and modify its operation permissions to the Nginx && restart service

①vim/etc/php.ini

Short_open_tag = On

Date.timezone = Asia/shanghai

②chown Nginx.nginx/etc/php.ini

② Restart Service

Systemctl Restart PHP-FPM

6. Create MySQL database Xiaomi

Mysql

MariaDB [(None)]> CREATE database Xiaomi;

7. Modify the database connection file

vim/data/web/data/config.php

Database Host 3306 is the default host port and needs to be modified if not by default

$db _host = "127.0.0.1:3306";

Database name

$db _name = "Xiaomi";

Database user Name

$db _user = "root";

Database Password

$db _pass = "";

※ Common errors: late database connection failed, can be: 3306 deleted and then try again


8. Confirm that mariadb, PHP-FPM and Nginx services are turned on


Here, the environment has been set up to enter the testing process


9. Test session (Test environment: Browser)

① Synchronizing databases

Enter http://192.168.116.77/ebak/ into the Background database management page to see if the database is connected properly (account: admin, Password: 123456)

② Entering the homepage

Enter http://192.168.116.77/to Enter the main page

③ into the store backend management system

input http://192.168.116.77/admin Modify Management order, website information, etc. (Account: admin password: admin888)

10. Lab FAQs

Note the permissions of each file

All files under/data/web/are Nobody.nobody

PHP.ini permission is Nginx.nginx

All files under/var/lib/nginx/are nobody.nobody (this file permission does not change, the store background management changes the information will be error)

Simple e-commerce website architecture based on LNMP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.