1. Installing MYSQL5
Yum install MySQL mysql-serverchkconfig--levels 235 mysqld on
Start
/etc/init.d/mysqld start
Whether the query starts
Netstat-tap | grep MySQL
When MySQL cannot start
Vi/etc/my.cnf
#skip Networking
Restart MySQL
/etc/init.d/mysqld restart
To set the MySQL password:
Method One:
Mysqladmin-uroot Password
Method Two (set root user password) (recommended):
Mysql_secure_installation
system automatically starts MySQL
Method One (recommended, Fedora New to Management Service commands):
Systemctl Enable Mysqld.servicesystemctl start Mysqld.service
Method Two:
Chkconfig--levels 235 mysqld on
2. Installing Nginx
Yum Install Nginx
Set boot up
Method One:
Chkconfig--levels 235 Nginx On/etc/init.d/nginx Start
Method Two:
Systemctl Enable Nginx.servicesystemctl start Nginx.service
3. Install PHP
Method One: fastcgi mode
Yum install lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc Php-eaccelera Tor Php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
Method Two: PHP-FPM mode (recommended)
Yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-m Agickwand php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
Configure PHP
Vi/etc/php.ini
Cgi.fix_pathinfo = 0 (recommended setting is 0, default is 1, 1 is a security vulnerability)
Viewing the native time zone
Cat/etc/sysconfig/clock
Modify Configuration
Date.timezone= "Asia/shanghai"
Start PHP
One: Start with spawn-fcgi mode
spawn-fcgi--help
/usr/bin/spawn-fcgi-a 127.0.0.1-p 9000-u nginx-g nginx-f/usr/bin/php-cgi-p/var/run/fastcgi-php.pid
Set boot up:
Vi/etc/rc.local Join
/usr/bin/spawn-fcgi-a 127.0.0.1-p 9000-u nginx-g nginx-f/usr/bin/php-cgi-p/var/run/fastcgi-php.pid
Second: Start with the PHP-FPM mode
Systemctl Enable Php-fpm.servicesystemctl start Php-fpm.service
Note that this place will encounter this error:
Systemctl start Php-fpm.servicejob failed. See System Journal and ' systemctl status ' for details.
Search for a long time, did not search, at first thought did not change the Php-rpm.conf.default to Php-rpm.conf, and later found that the file already exists.
Later through the Systemctl status Php-fpm.service in the log finally found the reason:
The original is not configured well php-rpm.conf and it contains to file/etc/php-fpm.d/www.conf
In this file
Default user = Apache
Default to group = Apache
Because is installed Nginx, so all changed to Nginx, finally can start php-fpm.
4. Configure Nginx
Vi/etc/nginx/nginx.conf
Worker_processes 5;keepalive_timeout 2;server {Listen 80; server_name localhost; # must be set here, or not support PHP #charset koi8-r; #access_log Logs/host.access.log Main; Location/{root/usr/share/nginx/html; Index index.php index.html index.htm; } error_page 404/404.html; Location =/404.html {root/usr/share/nginx/html; } # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.ht ml Location =/50x.html {root/usr/share/nginx/html; } # Proxy The PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ {# Pro Xy_pass http://127.0.0.1; #} # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root HTML; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param Script_filename/usr/share/nginx/html$fastcgi_script_name; Include Fastcgi_params; } # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # lo cation ~/\.ht {deny all; } }
Re-start Nginx
Systemctl Reload Nginx.service
5. Write a PHP test file