How to install php7.0 under the centos7.3 system

Source: Internet
Author: User
Requirement: Build LNMP environment under Centos7.3

1. Turn off the firewall and SELinux

Open File SELinux

Vim  /etc/sysconfig/selinux

Change the selinux=enforcing in the file to Disabled, and then execute the Setenforce 0″ to turn off SELinux without rebooting.

Selinux=disabled

Close the fire wall systemctl stop Firewalld.service

2. Installing the Software

2.1.MYSQL Installation

Download repo source for MySQL

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

Installing the MYSQL-COMMUNITY-RELEASE-EL7-5.NOARCH.RPM Package

RPM-IVH mysql-community-release-el7-5.noarch.rpm

Install MySQL

sudo yum install-y  mysql-server

To change MySQL user rights:

sudo chown-r root:root/var/lib/mysql

Restart Service:

Systemctl Restart Mysql.service

Log in and change the password:

Mysql-u root mysql > use MySQL; MySQL > Update user set Password=password (' 123456 ') where user= ' root '; MySQL > exit;

2.2nginx installation Download the Nginx package corresponding to the current system version

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Set up Nginx's Yum repository (default yum is no nginx)

RPM-IVH nginx-release-centos-7-0.el7.ngx.noarch.rpm

Download and install Nginx yum install-y nginx

Nginx Boot

Systemctl Start Nginx.service

2.3 Installing PHP

RPM installation PHP7 the corresponding Yum source

RPM-UVH HTTPS://MIRROR.WEBTATIC.COM/YUM/EL7/EPEL-RELEASE.RPMRPM-UVH https://mirror.webtatic.com/yum/el7/ webtatic-release.rpm

Installing php7.0

Yum Install-y php70w

Installing PHP Extensions

Yum install-y  php70w-mysql.x86_64   php70w-gd.x86_64   php70w-ldap.x86_64   php70w-mbstring.x86_64  php70w-mcrypt.x86_64

Install PHP FPM

Yum Install-y php70w-fpm

3. Modify the configuration file

3.1 Modifying Nginx configuration files

Nginx Configuration file Location:

(/etc/nginx/conf.d/default.conf)  vim/etc/nginx/conf.d/default.conf

To modify the root directory, you can customize:

Root   /forest/nginxdir/html;

To configure PHP parsing, modify the black bold part of the following code:

Location ~.php$ {  root   /forest/nginxdir/html;  Fastcgi_pass 127.0.0.1:9000;  Fastcgi_index index.php;  Fastcgi_param script_filename $document _root$fastcgi_script_name;  Include    Fastcgi_params;}

3.2 Modifying the PHP-FPM configuration file

PHP-FPM Configuration file Location: (/etc/php-fpm.d/www.conf)

Modify

User =nginx
Group=nginx

4. Put the test file

Cd/forest/nginxdir/htmlecho ' Hello Eric ' >index.php

5. Start the service

5.1 Start Nginx Service:

Systemctl Start Nginx.service

To view the startup status:

Systemctl status Nginx

See the following words to indicate the success of the launch!

Active:active (running) since six 2016-11-19 13:40:04 CST; 50min ago

5.2. Start PHP-FPM:

Systemctl Start Php-fpm.service

To view the startup status:

Systemctl Status Php-fpm.service

See the following words to indicate the success of the launch!

Active:active (running) since six 2016-11-19 14:14:33 CST; 18min ago

6. Testing

Open in the browser 192.168.44.129:80/index.php see Hello Eric is done ~

Setting up the boot-up service

Systemctl Enable Php-fpm.servicesystemctl Enable Nginx.service

If the project framework is Lavarel, then the configuration file can be used as follows:

server {listen 80;   server_name learn.laravel5.com;   Root/var/www/html/learnlaravel5/public;   Index index.html index.php;    Location/{try_files $uri $uri//index.php$is_args$query_string;        } location ~ \.php$ {try_files $uri = 404;        Fastcgi_pass 127.0.0.1:9000;        Fastcgi_index index.php;        Fastcgi_param script_filename $document _root$fastcgi_script_name;    Include Fastcgi_params; }}
Related Article

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.