How to install and configure nginx mysql php
nginx mysql php installation and configuration method: 1. Download Nginx and install and start nginx; 2. Unzip "php-7.2.25.tar.gz" and install the dependencies required for php; 3. Change nginx Configuration file; 4. Install mysql and start the service.
The operating environment of this article: centos7 system, php version 7.2.25, DELL G3 computer
How to install and configure nginx mysql php?
Installation and configuration of nginx and PHP mysql under CentOS7:
Download Nginx
First Installed dependency packages:
gcc automake autoconf libtool make gcc gcc-c openssl openssl-devel
wget http://zlib.net /zlib-1.2.11.tar.gz
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
1. Create a new folder on the server /home/soft/ ;
2.cd /home/soft/ => Execute the command to download Nginx wget http://nginx.org /download/nginx-1.7.4.tar.gz ;
wget http://cn2.php.net/distributions/php-7.0.0.tar.gz
3. Unzip the downloaded compressed package to /opt/software/ => tar -zvxf nginx-1.7.4.tar.gz -C /opt/software/ ;
4.cd / opt/software/nginx-1.7.4/ => ./configure --prefix=/usr/local/nginx/ ;
5.make && make install ;
6.Start nginx => /usr/local/nginx/sbin/nginx
7. Open the browser to access the IP of this machine. If the browser displays Welcome to nginx!, it means that Nginx has been installed. and runs successfully.
8. Restart: /usr/local/nginx/sbin/nginx –s reload
Stop: /usr/local/nginx/sbin/nginx –s stop
Test whether the configuration file is normal: /usr/local/nginx/sbin/nginx –t
Force shutdown: pkill nginx
Download php
1. cd /home/soft/ Download php: wget https://www.php.net/distributions/php-7.2.25.tar.gz;
2. Unzip php-7.2.25.tar.gz => tar -zvxf php-7.2.25.tar.gz -C /opt/software/ ;
3. cd /opt/software/php-7.2 .25/;
4. First install the dependencies required for php:
yum update yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel yum -y install curl-devel yum -y install libxslt-devel yum install openssl openssl-devel
5.
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
6. make && make install
7. PHP configuration information:
cp /opt/software/php-7.2.25/php.ini-development /usr/local/php/lib/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp -R /opt/software/php-7.2.25/sapi/fpm/php-fpm /etc/init.d/php-fpm * 需要注意的是php7中www.conf这个配置文件配置phpfpm的端口号等信息,如果你修改默认的9000端口号需在这里改,再改nginx的配置
Ngin parses PHP:
1. Change the nginx configuration file => vim /usr/local/nginx/etc/nginx/ nginx.conf
location ~ \.php$ { root /usr/share/nginx/html; #指定php的根目录 fastcgi_pass 127.0.0.1:9000; #php-fpm的默认端口是9000 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #路径 include fastcgi_params; }
2.php configuration to start automatically at boot:
vim /usr/lib/systemd/system/php-fpm.service [Unit] Description=php After=network.target [Service] Type=forking ExecStart=/usr/local/php/sbin/php-fpm ExecStop=/bin/pkill -9 php-fpm PrivateTmp=true [Install] WantedBy=multi-user.target
3. killall /etc/init.d/php-fpm
4. Start php
systemctl restart php-fpm.service systemctl enable php-fpm.service
Install mysql
Add yum source
First download the source installation package, enter wget http://dev.mysql.com/get /mysql57-community-release-el7-11.noarch.rpm
Next, enter yum localinstall mysql57-community-release-el7-11.noarch.rpm. After execution, check whether the installation is successful
yum installs and starts the service
Okay, the next step is yum -y install mysql-community -server
Enter systemctl start mysqld to start the service
Finally, enter systemctl enable mysqld to add automatic startup at boot. At this point, MySQL has been installed successfully.
Change the default password
Use grep 'temporary password' /var/log/mysqld.log to view the default password. Then mysql -u root -p enter the found default password to log in to MySQL
Enter ALTER USER 'root'@'localhost' IDENTIFIED BY 'youPassword'; to change the password. Note that MySQL 5.7 requires passwords to contain uppercase and lowercase letters, numbers, and special characters.
Open remote connection
Enter GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; in MySQL. After adding it, open the port
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to install and configure nginx mysql php. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

Wordpress site file access is restricted: troubleshooting the reason why .txt file cannot be accessed recently. Some users encountered a problem when configuring the mini program business domain name: �...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Arrays are linear data structures used to process data in programming. Sometimes when we are processing arrays we need to add new elements to the existing array. In this article, we will discuss several ways to add elements to the end of an array in PHP, with code examples, output, and time and space complexity analysis for each method. Here are the different ways to add elements to an array: Use square brackets [] In PHP, the way to add elements to the end of an array is to use square brackets []. This syntax only works in cases where we want to add only a single element. The following is the syntax: $array[] = value; Example

Running multiple PHP versions simultaneously in the same system is a common requirement, especially when different projects depend on different versions of PHP. How to be on the same...

PHP...
