In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to install and configure nginx and PHP under CentOS7, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Installation and configuration of nginx and PHP under CentOS7
Download Nginx
1. Create a new folder / home/soft/ on the server
2.cd / home/soft/ = > execute the command to download Nginx wget http://nginx.org/download/nginx-1.7.4.tar.gz
3. Extract the downloaded 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 a browser to access the IP of this machine, if the browser appears Welcome to nginx! Indicates that Nginx is installed and running 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
two。 Decompress 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. Install the dependencies required by php first:
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 for 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
* note that the configuration file www.conf in php7 configures the port number of phpfpm. If you change the default port number of 9000, you need to change it here, and then change the configuration of nginx.
Ngin parses php:
1. Change the configuration file of nginx = > vim / usr/local/nginx/etc/nginx/nginx.conf
Location ~\ .php$ {
Root / usr/share/nginx/html; # specifies the root directory of php
Fastcgi_pass 127.0.0.1 fastcgi_pass 9000; the default port for # php-fpm is 9000
Fastcgi_index index.php
Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # path
Include fastcgi_params
}
2.php configuration Boot self-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
Thank you for reading this article carefully. I hope the article "how to install and configure nginx and PHP under CentOS7" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.