I. Overview
Project requirements: Today, the server running environment is installed and configured on the virtual machine based on Centos. The web service uses nginx, the database is stored in mysql (using MariaDB), and the dynamic scripting language is php.
Step 2
The homepage ensures that Centos7 has been installed and runs properly. If not installed, please download (http://www.centos.org/download ). I will not describe how to install it here. Next, we will introduce the installation and configuration of nginx, mysql, and php in five steps.
1. Step 1: install nginx
Add a centos yum source.
Sudo rpm-Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Install nginx
Sudo yum install nginx
Start the nginx service
Sudo systemctl start nginx. service
Access the IP address. If The Nginx welcome page appears, nginx is installed and running properly.
Set auto start Nginx upon startup
Sudo systemctl enable nginx. service
2. Step 2: install mysql (using MariaDB)
The MariaDB database management system is a branch of MySQL and is mainly maintained by the open-source community. The purpose of using GPL to authorize MariaDB is to be fully compatible with MySQL, including APIs and command lines, it can easily become a substitute for MySQL.
Install MariaDB
Sudo yum install mariadb-server mariadb
Enable MariaDB
Sudo systemctl start mariadb
After the MariaDB/MySQL service is successfully started, run the script in the MariaDB/MySQL service package. This operation provides some security enhancement measures for the database server, such as setting (not empty) the root password, deleting anonymous users, and locking remote access.
Sudo mysql_secure_installation
Next, the command line prompts you to set the mysql User name and password. Select yes for all.
Set automatic mysql restart upon startup
Sudo systemctl enable mariadb. service
3. Step 3: install PHP
Install Php and php extensions
Sudo yum install php-mysql php-fpm php-mbstring php-gd php-pear php-mcrypt php-mhash php-eaccelerator php-cli php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mssql php-snmp php-soap php-tidy php-common php-devel php-pecl-xdebug-y
Edit the php configuration file
Sudo vi/etc/php. ini
Cgi. fix_pathinfo = 0
Set the php-fpm configuration file
Sudo vi/etc/php-fpm.d/www. conf
Listen =/var/execute/php-fpm/php-fpm.sock
Start the php-fpm service
Sudo systemctl start php-fpm
Set to automatically restart php-fpm upon startup
Sudo systemctl enable php-fpm.service
4. Step 4: configure the nginx site
Edit site configuration file
Sudo vi/etc/nginx/conf. d/default. conf
Server {
Listen 80;
Server_name drupaluser.org;
Root/opt/data;
Index. php index.html index.htm;
Location /{
Try_files $ uri/= 404;
}
Error_page 404/404 .html;
Error_page 500 502 503 x.html;
Location =/50x.html {
Root/usr/share/nginx/html;
}
Location ~ \. Php $ {
Try_files $ uri = 404;
Fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}
}
Restart nginx
Sudo systemctl restart nginx
5. Step 5: Test the php script web service
Edit test file
Sudo vi/opt/data/info. php
Access the page. If you can see various php configuration information, the configuration is successful.
Http://drupaluser.org/info.php
Delete test file
Sudo rm/opt/data/info. php
In CentOS 7, nginx, mysql, and php installation and configuration are complete and can be used as the application environment of the web platform.