LNMP Environment Construction and instance operation

Source: Internet
Author: User
Tags apc

One: CentOS7.2 installation

1, a new virtual machine in VMware CentOS 64-bit, configured with a disk size of 30G, boot the virtual machine into the CentOS installation interface
Select Install CentOS 7

2, set the system language to Chinese, time zone selection Asia/shanghai
3. SECURITY Policy Select Default
4, software selection Select Gnome Desktop, install the GUI

5, set the network and hostname, and turn on the Internet connection (if you do not turn on the network, there will be Xshell is not connected to the CentOS problem)

6. Set Root PASSWORD
7. Create a new User: Xiao, and set the password
8, waiting for installation, restart CentOS, will appear: CENTOS7 License Not accepted problem
Enter 1 First, read the license information
Then enter 2, accept the agreements
Then enter Q,quit the conversition. Finally, enter Yes to restart
9. Create a system snapshot

Second: Installation Nginx environment

Nginx is not part of a CentOS base library. So install the Epel library to get Nginx:
1. Yum Install Epel-release
2. Yum Install Nginx

3. Create the system to start the Nginx link and start it:
Systemctl Enable Nginx.service
Systemctl Start Nginx.service
4. See if Netstat–tap is available | grep nginx

Installation Successful

Three: Install MARIADB environment

CentOS7 The version above uses mariadb instead of MySQL, so install mariadb.
1, install MARIADB service yum install mariadb mariadb-server mariadb-devel

2. Create the system to start the MARIADB link and start it:
Systemctl Enable Mariadb.service
Systemctl Start Mariadb.service
3. Check network activation now. Run Netstat-tap | grep MySQL
4. Set MARIADB access to prevent anyone from being able to access it.
Mysql_secure_installation
Set a new password

Four: Install PHP

1, install PHP5 related modules
Yum install php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pecl-memcache php-pear php-mbstring php-xml php -xmlrpc php-mbstring Php-snmp Php-soap

2. Installing APC
APC is a free and open PHP opcode to cache and optimize PHP's intermediate code.
The APC installed from the PHP pecl library. PECL requires the CentOS development tool beinstalled to compile the APC package.
Yum Install Php-devel
Yum Groupinstall ' development tools '//Install development Kit
Installing the Apc:pecl install APC

3 Configuring PHP.ini
Turn on APC extension extension=apc.so
Set time zone Date.timezone = "Asia/shanghai"

4. Create the php-fpm of the system startup link and start it:
Systemctl Enable Php-fpm.service
Systemctl Start Php-fpm.service

Problem encountered: Unable to bind listening socket for address ' 127.0.0.1:9000 ': Address already in use (98)
Workaround: Kill the process first, then restart
Netstat-lntup | grep 9000
Killall PHP-FPM
Systemctl Start Php-fpm.service

Five: Environmental testing

1, enter localhost in the browser window, the following page appears, the Nginx installation is successful

2, configure nginx.conf, parse PHP file

Then create a new index.php file under/usr/share/nginx/html

SIX: TP website deployment

1, Configuration nginx.conf

Change the root directory to a Web site Directory
and add the following configuration, so that nginx forward PHP request to PHP-FPM parsing.

Location ~. +\.php ($|/) {root/usr/share/nginx/html/website; Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php;includefastcgi.conf; Fastcgi_paramScript_filename/usr/share/nginx/html/website$fastcgi _script_name;includeFastcgi_params;} Set the cache configuration for images, CSS,JS and other resources. Location ~. *\. (gif|jpg|jpeg|png|bmp|flv|ico|swf)${Access_log off; Expires -H } location ~. *\. (htm|html)${Access_log off; Expires -H } location ~. *\. (JS|CSS)?${Access_log off; Expires -H;}

2. Turn off SELinux to avoid problems with permissions when configuring thinkphp projects
Temporary shutdown Selinux:setenforce 0
3, deploy thinkphp project.
Configure the project's ' Url_model ' to 3, compatibility mode, and avoid the need for Nginx to use PathInfo mode.

4. Enter in the browser: localhost//index.php


Run successfully

LNMP Environment Construction and instance operation

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.