Installing PHP&PHP-FPM
First update the CENTOS7 system, the system software upgrade, here does not upgrade the kernel.
// with root permissions, note that this uses upgrade instead of update (it will upgrade the kernel, which we do not need here)Yum upgrade
I need to install the latest PHP, the default source installed PHP version is about 5.4, almost obsolete, here first install a new source.
// installation Source RPM-UVH https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm RPM-UVH https://mirror.webtatic.com/yum/el7/webtatic-release.rpm// Install PHP and php-fpmyum install php71w php71w-cli php71w-FPM / Install related extensions yum install php71w-mbstring php71w-Common yum install php71w-gd php71w-mcrypt yum install php71w -mysql php71w-xml yum install php71w-soap php71w-xmlrpc
Installing Nginx
Nginx is a popular web server software, it needs to provide Web service configuration site and so on. There are also Apache, LIGHTTPD, and other options available.
// Installing Nginx Yum install nginx // start Nginx systemctl start Nginx // use Systemctl to set up boot Systemctl enable Nginx
Depending on the network you have previously set up, you can visit the Mac browser directly to http://192.168.56.101:80
see if the Nginx has been started. I found that it was not possible to access the success, this is caused by CentOS7 's firewall, open port 80
Firewall-cmd--permanent--zone= public--add-service=http firewall-cmd--reload
Retry, Display Nginx Welcome page, Nginx set success.
Install MySQL
MySQL is a relational database software used to store data. Installing MySQL requires a simple instruction, the latest version is 5.7 so install the latest source first.
//install MySQL sourceYum Install https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm//install MySQLYum Install mysql-community-Server//start MySQLsystemctl start mysqld//Set boot upSystemctl Enable Mysqld//find a randomly generated passwordgrep ' temporary password '/var/log/mysqld.log//log in to MySQL(requires the above password)Mysql-uroot-p ' xxxx '
Change password, password requires capital letters, lowercase letters, and numbers and special symbols
Alter user ' root ' @ ' localhost ' identified by ' qw.123456 ';
MySQL installation is complete.
Setting Nginx and PHP-FPM
I have installed the need for the program, to the PHP request to be received by Nginx and forwarded to PHP-FPM again by the PHP interpreter to perform the returned results, but also need to do some configuration.
// start php-fpmsystemctl start php-FPM // set boot up systemctl enable PHP-FPM
Configure the Nginx site (test.com for your domain):
vi/etc/nginx/conf.d/test.com.conf//write the following contentServer {Listen the; server_name test.com; Root/usr/share/nginx/html; Index index.php index.html; Location/{try_files $uri $uri//index.php?$query _string; } Location~\.php$ {fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Include fastcgi.conf; Fastcgi_param script_filename $document _root$fastcgi_script_name; }}//re-start Nginxsystemctl Restart Nginx//in the/usr/share/nginx/htmladd phpinfo.php file to write the following content
<?php phpinfo ();
Open your Mac's browser input http://test.com/phpinfo.php
to see the PHP information. If the report is 403, stating that there is no permission, try to set the file path permissions chmod 777 -R
/usr/share/nginx/html.
If also reported is set after File not found
, it is possible to SELinux
restrict access, modify the related configuration to turn off SELinux.
vi/etc/sysconfig/selinux selinux=disabled // restart system reboot
Refresh the browser, PHP information page normal display. In this PHP environment to build OK.
Reference: CentOS 7 Installation PHP development environment
CentOS 7 Installation php7+nginx+mysql5.7 development environment