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!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software