Build a development environment for Centos, PHP7 + Nginx1.12 + Mysql5.7, centosphp7

Source: Internet
Author: User
Tags install openssl mysql login

Build a development environment for Centos, PHP7 + Nginx1.12 + Mysql5.7, centosphp7

1. Update yum Source

yum -y update

 

2. Install epel-release

yum install epel-release -y

Check installation successful: yum search nginx results contain: nginx. x86_64: A high performance web server and reverse proxy server, indicating successful

There is a problem with CentOS series server systems, that is, the official source software is relatively old, and many software are not. Because their primary task is to ensure the stability of the server, rather than the pursuit of the latest. However, it is too conservative. In general, we will add an epel-release source to the server. This source contains the software we need, such as nginx, which is easy to use.

 

3. Install common server software

yum -y install vim*  

Vim is a well-known powerful and highly customizable Text Editor similar to Vi.

yum install wget

Wget is a free tool for automatically downloading files from the network. It supports downloading through HTTP, HTTPS, and FTP, and can use HTTP proxy.

yum -y install lrzsz

Lrzsz is a program that can be uploaded and downloaded over ftp in linux.

yum install zip unzip

Role: zip compression and unzip Decompression

 

4. Install Nginx

Some lib libraries on which nginx depends:

yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel 

Install Nginx

cd /usr/local

Open the local folder under usr

yum install nginx -y

Install Nginx. The installed package is already an updated source.

systemctl start nginx

Start nginx

systemctl enable nginx

Set nginx to boot

Complete the installation and access the Host ip address in the browser to see if it can be opened.

 

5. Install PHP7

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Install the PHP 7 rpm package

yum search php7

Query their php7 which version and extension library, such as: php70w, php71w, php72w, php70w-fpm, etc.

yum install php70w

Take your own package as the standard

yum install php70w-openssl php70w-common php70w-fpm php70w-mysql php70w-mysqld php70w-pdo 

Install PHP7 extension library version and PHP7 version corresponding, that is, php70w version corresponding to the same version of the extension library php70w-fpm and so on.

 

6. Install Mysql

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

Download the mysql source installation package

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

Install mysql Source

yum -y install mysql-server

Install mysql

Service mysqld start
Or
Systemctl start mysqld

Start the mysql server

systemctl status mysqld

View mysql status

systemctl enable mysqld
systemctl daemon-reload

Start

grep 'temporary password' /var/log/mysqld.log

After mysql is installed, a default password is generated for root in the/var/log/mysqld. log file. Find the Default root Password (followed by the password) in the above method, and then log on to mysql to modify it.

mysql -uroot -p

Press enter, enter the temporary password, and enter mysql to change the password.

set global validate_password_policy=0;

Mysql5.7 is installed with the password security check plug-in (validate_password) by default. The default password check policy requires that the password must contain uppercase and lowercase letters, numbers, and special characters, and the length cannot be less than 8 characters. Otherwise, an ERROR is reported.

Here the code is used to modify the password strength: 0 or LOW (the password is arbitrary, but the length is 8 or more characters ).

set global validate_password_length=4;

The password is set to less than 8 characters. Run the preceding command (at least 4 characters)

Set password for 'root' @ 'localhost' = password ('new password ');

Run this code to modify the mysql Login Password

GRANT ALL PRIVILEGES ON *.* TO 'yourname'@'%' IDENTIFIED BY 'YourPassword@123' WITH GRANT OPTION;

Add a remote logon user. By default, only the root account is allowed to log on locally. To connect to mysql on another machine, you must modify the root account to allow remote connection and execute the above Code.

 

7. Configure php and nginx

Configure php

vim /etc/php.ini

Modify php. ini to change the cgi. fix_pathinfo value to 0. If there is one before it, remove it in about 763 rows. Enter "763" after entering the file and locate it.

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

Modify www. cong

listen.owner = nobody

listen.group = nobody

Remove the front of the two rows.

user = apache
group = apache

Replace apache with nginx, save and exit (: wq)

systemctl start php-fpm

systemctl enable php-fpm

Start PHP and set it to boot.

 

Configure nginx

vim /etc/nginx/nginx.conf

Open the configuration file

server {
  listen 80;
  server_name 127.0.0.1:9000;
  root /www/;
  index index.php index.html index.htm

  # Load configuration files for the default server block.
  include /etc/nginx/default.d/*.conf;

  location ~ \.php$ {

  fastcgi_pass 127.0.0.1:9000;
  fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name;
  include fastcgi_params;
  }

  location / {
  }

  error_page 404 /404.html;
  location = /40x.html {
  }

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
  }
}

According to this format change, the listen listening port, server_name project URL (127.0.0.1: 9000 by default), root project path; index Server, in order to find the home page file, the previous does not look back, you can set the index in php. put php in front.

Change $ document_root in fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; to the Project address in localtion.

Write info. php under the project file path

<?php

echo phpinfo()

?>

After saving and exiting, enter the Internet ip Address/info. php of the host in the browser to check whether the host is successful.

 

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.