Install nginx
-
1
which nginx # to see if there is nginx
-
2
yum list nginx # listed nginx
install nginx yum install nginx #
Occurs is this ok [Y / N] Period: Enter y
# Saw {Complete!} Installed successfully.
-
3
which nginx # to see if there is nginx
service nginx start # start nginx process method [1]
/etc/init.d/nginx start # start nginx process method [2]
The method [1] or [2] may be optionally substituted, in the process of starting the service may be given
Starting nginx: nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) [FAILED]
Solution: Modify the nginx configuration
cd /etc/nginx/conf.d/
vi default.conf
I carried out by keyboard editing state, the [::]: 80 in front of this line add "#" indicates a comment that line, and then press the Esc key keyboard, and finally enter: wq (save and exit)
Restart nginx process (method [1] or [2])
ps -ef | grep nginx # View nginx process
-
4
curl members.3322.org/dyndns/getip # View external IP
Enter the IP you see in the browser can display the welcome page represent nginx nginx has been successfully installed
If it does not appear likely that the firewall is not open port 80
Solution:
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart
You can also turn off the firewall: service iptables stop
Under normal circumstances just rent a server firewalls are closed
END
Install php
-
1
yum -y install php php-fpm # install php and php-fpm package
# Saw {Complete!} Installed successfully.
-
2
Start php-fpm:
/etc/init.d/php-fpm start #1
service php-fpm start #2
-
3
Nginx modify PHP configuration file so that the request is forwarded to the php-fpm bound ip and port:
we /etc/nginx/conf.d/default.conf
The bottom of which an input; the server {}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Enter: wq to save and exit
-
4
[Emphasis] to restart nginx:
service nginx restart
--------------------------------------------------
Verify that PHP file to process the request:
we /usr/share/nginx/html/info.php
<?php
phpinfo();
---------------------------------------------------
Access IP address:
http: // extranet IP / info.php
END
Install mysql
-
yum -y install mysql mysql-server # does not need to be prompted to install
# Saw {Complete!} Installed successfully.
-
service mysqld start # start mysql server
mysqladmin -u root password 123456 # 123456 into the password you want to set
Log mysql test
mysql -u root -p Enter password: (set your own password) which is followed by the user name -u, -p asked for a password, enter the password to enter the password at the Enter.
Ctrl-C -! Exit # exit the terminal
-
Php extension mounting operation to mysql
yum -y install php-mysql # php-mysql mounting extension
service php-fpm restart # restart php-fpm process
-
Check if you can operate by php mysql database:
we /usr/share/nginx/html/dbConnect.php
<?php
@mysqli_connect ( "localhost", "root", "mysql password you set", "mysql") or die ( "connect mysql failed \ n");
echo "connect ok\n";
http: // extranet IP / dbConnect.php # executes in the browser
-