02-nginx+mysql+php7

Source: Internet
Author: User
Tags curl fpm openssl openldap

"Install Nginx" #先安装如下包yum install gcc gcc-c++ kernel-Develyum-y install pcre-devel OpenSSL openssl-devel# Decompression Nginx-1.12.0The . tar.gz then enters the directory./configure--prefix=/usr/local/nginx--with-Http_stub_status_modulemake&&Make install "Installing MySQL" #先安装如下包: Yum-y install make gcc-c++ cmake bison-devel ncurses-devel# decompression MySQL-5.6. -. tar.gz then enter the directory CMake-dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/mysql/data-dsysconfdir=/etc-dwith_myisam_ Storage_engine=1-dwith_innobase_storage_engine=1-dwith_memory_storage_engine=1-dwith_readline=1-dmysql_unix_addr=/var/lib/mysql/mysql.sock-dmysql_tcp_port=3306-denabled_local_infile=1-dwith_partition_storage_engine=1-dextra_charsets=all-ddefault_charset=utf8-ddefault_collation=Utf8_general_cimake&&Make install "Installing PHP" #先安装如下包: Yum Install-y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel li BXML2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl Curl-devel e2fsprogs E2fsprogs-devel krb5 krb5-devel OpenSSL openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers# extracting PHP-7.1.6The . tar.gz then enters the directory./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php--enable-mbstring--enable-ftp--WITH-GD- -WITH-JPEG-DIR=/USR--with-png-dir=/usr--with-mysql=mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd-- With-pear--enable-sockets--with-freetype-dir=/usr--enable-gd-native-ttf--with-zlib--with-libxml-dir=/usr-- With-xmlrpc--enable-zip--enable-fpm--enable-xml--enable-sockets--with-gd--with-zlib--with-iconv--enable-zip-- with-freetype-dir=/usr/lib/--enable-soap--enable-pcntl--enable-cli--with-Curlmake&& make Install

Description: Nginx, MySQL, PHP7 compiled installation commands refer to the Command.txt in the installation package, all operations need to be performed under the root user. "After compiling the installation Nginx"   
$/usr/local/server/nginx/sbin/nginx              /usr/local/server/nginx/sbin/nginx-s stop      /usr/ Local/server/nginx/sbin/nginx-s reload    -ef | grep nginx  or ps-a | grep-

[Configure Nginx support PHP] to enter/usr/local/nginx/conf, copy the nginx.conf to a spare, and then modify the nginx.conf:
(1) index index.html index.htm; instead: index index.html index.htm index.php; (2) #location ~\.php$ {# root HTML; # Fastcgi_pass127.0.0.1:9000;        # Fastcgi_index index.php; # Fastcgi_param Script_filename/Scripts$fastcgi_script_name; # include fastcgi_params;#} instead: location~\.php$ {# root HTML; Fastcgi_pass127.0.0.1:9000;        Fastcgi_index index.php;        Fastcgi_param script_filename $document _root$fastcgi_script_name; Include Fastcgi_params;}
[Configuration Nginx support thinkphp]------not verified under Nginx with thinkphp do development, each input similar to/test/tp/index.php/index/index URI, the hint did not find the page originally Nginx does not support PathInfo mode, you need to configure it yourself. In the server block of the configuration file, add the following:
location/qgzs_apiv2/app/{index index.php; if(!-e $request _filename) {Rewrite^/qgzs_apiv2/app/(. *) $/qgzs_apiv2/app/index.php/$1Last ;  Break; }} Location~. +\.php ($|/) {     Set$script $uri; Set$path _info"/"; if($uri ~"^ (. +\.php) (/.+)") {         Set$script $1; Set$path _info $2; } Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php? If_rewrite=1;     Include Fastcgi_params;     Fastcgi_param path_info $path _info; Fastcgi_param script_filename $document _root/$script; Fastcgi_param Script_name $script; }   

Where/qgzs_apiv2/app/is the path of the project, after saving the configuration, restart Nginx, the configuration is successful. Pseudo-static mode similar to/index.html is directly supported. "After compiling and installing MySQL"It takes approximately 30 minutes to compile the installation, followed by the following configuration:  [set permissions] Use the following command to see if there are MySQL users and user groups $ cat/etc/passwd    #查看用户列表 $ cat/etc/group     #查看用户组列表   If not, create $ groupadd mysql$ useradd-g mysql mysql  modify/usr/local/mysql permissions $ chown-r mysql: mysql/usr/local/mysql [initialization Configuration] Enter the installation path, execute the initialization configuration script, create the system's own database and table: $ cd/usr/local/mysql$ scripts/mysql_install_db-- Basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql  If the installation fails, the can ' t locate data/dumper.pm in @INC (@INC contains: ..., fix the following: $ yum install ' Perl (Data::D umper) '   Note: rename/etc/my.cnf to/etc/ My.cnf.bak, then copy the service script to the INIT.D directory and set the boot up: $ cp support-files/mysql.server/etc/init.d/mysql$ chkconfig MySQL on$ service MySQL start    #启动MySQL  [Configuration user] You need to set the PATH first, or you can't call MySQL directly. Modify the/etc/profile file and add it at the end of the file: path=/usr/local/ Mysql/bin: $PATHexport path  Close the file, run the following command, and let the configuration take effect immediately: $ source/etc/profile  Now, enter MySQL directly into the terminal: $ mysql- urootmysql> Set PASSWORD = PASSWORD (' 123456 ');  to set the root user to remotely access, execute mysql> GRANT all privileges On * * to ' root ' @ ' 172.16.% ' identified by ' 123456 ' with GRANT option; [Configuration firewall] The 3306 port of the firewall is not enabled by default, and this port needs to be opened for remote access. Open/etc/sysconfig/iptables: Under "-A input–m State--state new–m tcp–p–dport 22–j ACCEPT", add:-A input-m State--state NEW -M tcp-p-dport 3306-j Accept then save and close the file, run the following command in the terminal, refresh the firewall configuration: $ service iptables Restart  ok, everything is configured, Then you can access MySQL!     "After compiling the installation PHP7"It takes approximately 20 minutes to compile the installation, and then in the previously compiled source package, locate the php.ini-production:$ CP Php.ini-production/usr/local/php/php.ini [copy startup script]$ CP./sapi/ fpm/init.d.php-fpm/etc/init.d/php-fpm$ chmod +x/etc/init.d/php-fpm [modify PHP-FPM profile]
$ cd/usr/local/php/etc$ cp php-fpm.conf. default php-fpm.conf Then, vim php-= run/php-fpm.pid in front of the semicolon ② Modify user and group users for the current user ③   5             
Then save the exit. [Start php-fpm]$/etc/init.d/php-fpm start #php-fpm Start command $/etc/init.d/php-fpm stop #php-FPM Exit command $ PS-EF | grep php or Ps-a | Grep-i PHP #查看是否已经成功启动PHP

02-nginx+mysql+php7

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.