Yum Assembly nginx + mysql + php

Source: Internet
Author: User
Tags imap php mysql tidy
Yum install nginx + mysql + php command prepare to create directory mkdir directory name chmod777 directory name change permission add to boot startup Item service chkconfig -- addphp-fpmchkconfignginxon find file location often used to find various configuration files after yum Installation and the location where the Startup Program is located find | grepphp-fpm service starts servic

Yum install nginx + mysql + php command prepare to create directory mkdir directory name chmod 777 directory name change permission add startup Item service chkconfig -- add php-fpm chkconfig nginx on find file location often used to find yum find | grep php-fpm service start servic

Install nginx + mysql + php in yum
Command preparation

Create directory

Mkdir directory name

Chmod 777 permission for directory name change

Add startup Item Service

Chkconfig -- add php-fpm

Chkconfig nginx on

Searching for file locations is often used to find various configuration files and startup programs after yum is installed.

Find | grep php-fpm

Service Startup

Service nginx
Start | stop | restart | condrestart | try-restart | force-reload | upgrade | reload | status | help | configtest

Service nginx start

Service php-fpm start

View Processes

Ps-ef | grep java

View Processes

Kill-9 process id

1. Install Add nginx Source

Http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

Wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

Rpm-ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

Rpm-qa | grep nginx check whether nginx is added to the Source Path


Install php mysql nginx

Yum install mysql-server php-mysql php-fpm nginx


If you cannot find the source address for installing the php component library, find the third-party source Library updated in tips.

Yum install php-cli php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php- soap php-tidy php-common php-devel


2. Configuration2.1 nginx configuration file location if no relevant accessories are found, find the file location command
/Etc/nginx. conf
/Etc/nginx/conf. d/*. conf

Multiple Sites are placed in the conf. d directory and included in nginx. conf using the include syntax
Include/etc/nginx/conf. d/*. conf;


Default. conf Modification

Server {listen 80; server_name localhost; # custom domain name configuration # charset koi8-r; # access_log/var/log/nginx/log/host. access. log main; location/{root/home/www; # SET index index.html index.htm index in the Custom directory. php ;}# error_page 404/404 .html; # redirect server error pages to the static page/50x.html # error page processing error_page 500 502 503 x.html; location =/50x.html {root/home/www;} # proxy the PHP scripts to Apac He listening on 127.0.0.1: 80 # location ~ \. Php $ {# proxy_pass http://127.0.0.1 #}# Pass the PHP scripts to FastCGI server listening on 127.0.0.1: 9000 # location ~ \. Php $ {# root/home/www; # fastcgi_pass 127.0.0.1: 9000; fastcgi_pass unix:/tmp/php-cgi.sock; # This mode heard that performance improvement more fastcgi_index index. php; fastcgi_param SCRIPT_FILENAME/home/www $ fastcgi_script_name; include fastcgi_params;} # deny access. htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\. Ht {# deny all ;#}}

Similar

Other *. conf values can be customized.

server{listen       80;server_name wx.vtz.cc;index index.html index.htm index.php;root  /home/wwwroot/weixin;location ~ .*\.(php|php5)?${try_files $uri =404;fastcgi_pass  unix:/tmp/php-cgi.sock;fastcgi_index index.php;include fcgi.conf;}location /status {stub_status on;access_log   off;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires      30d;}location ~ .*\.(js|css)?${expires      12h;}access_log  /home/wwwlogs/weixin_access.log  access;}

2.2Php-fpm.conf configuration include =/etc/php-fpm.d/*. conf // because it contains other files,/etc/php-fpm.d found www. conf Modification
[Www] # Set listener modification items
#listen = 127.0.0.1:9000listen = /tmp/php-cgi.sock


3. Add a service to start the nginx Service
chkconfig --add nginx chkconfig nginx onservice nginx start

Php-fpm
chkconfig --add php-fpm chkconfig php-fpm onservice php-fpm start

Mysql
chkconfig --add mysqld chkconfig mysqld onservice mysqld start

Empty root password by default: 1. php error prompt
vim /etc/php5/fpm/php.ini

Open error prompt

display_errors = On

Because the four fpm used with nginx, so also need to modify the php-fpm.conf File

vim /etc/php5/fpm/php-fpm.conf

Finally, it is possible to add www. conf in this configuration file.

php_flag[display_errors] = on

Enable nginx configuration to be read again

sudo service nginx reload
2. Other installation references
  1. Configure a third-party yum source for CentOS 6.0 (no nginx software package exists in the default standard source for CentOS)
    1 yum install wget
    2 wget http://www.atomicorp.com/installers/atomic
    3 sh ./atomic
    4 yum update
  2. Install the development kit and library files
    1 yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng
    2 libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel
    3 gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2
    4 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
  3. Uninstall installed apache, mysql, and php
    1 yum remove httpd
    2 yum remove mysql
    3 yum remove php

  4. Install nginx
    1 yum install nginx
    2 service nginx start
    3 chkconfig --levels 235 nginx on
  5. Install mysql
    1 yum install mysql mysql-server mysql-devel
    2 service mysqld start
    3 chkconfig --levels 235 mysqld on
    4 mysqladmin -u root password "Password" service mysqld restart
  6. Install php
    1 yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap
    2 php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap
    3 php-tidy php-common php-devel php-fpm
    4
    5 service php-fpm start
    6
    7 chkconfig --levels 235 php-fpm on
  7. Configure nginx to support php
    1 mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
    2 cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
    3 vi /etc/nginx/nginx.conf
    Add
    1 location ~ \.php$ {
    2 root /usr/share/nginx/html;
    3 fastcgi_pass 127.0.0.1:9000;
    4 fastcgi_index index.php;
    5 fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
    6 include fastcgi_params;
    7 }
  8. Restart nginx php-fpm
    View sourceprint?
    1 service nginx restart
    2 service php-fpm restart
3. Server Status php function component Probe
4. Create an Internet access for mysql user
Insert into mysql. user (Host, User, Password) values ("%", "admin", password ("1234"); update mysql. user set password = password ('new password') where User = "phplamp" and Host = "localhost"; grant all privileges on *. * to 'yourname' @ '%' identified by 'youpasswd'; // The password is required. flush privileges;

5. Build a version library in linux svn. 1. # yum install subversion
2. Create a directory to store all SVN files.
# Mkdir/home/svn
3. Create a version repository for project project_1 in the folder created above.
# Svnadmin create/home/svn/project_1
After this step is completed, the project_1 folder will exist in/home/svn. The configuration of this project is in/home/svn/project_1/conf.

4. Configure permissions for the project
(1) svnserve. conf is the main configuration file.
# Vi/home/svn/project_1/conf/svnserve. conf
Anon-access = read # anonymous readable
Auth-access = write # verify that the user can read and write
Password-db = passwd # point to the data file passwd that verifies the user name and password. See the following configuration
Auth-db = authz # points to the authentication user's permission configuration file authz. See the following configuration
Note: No space exists in front of each line; otherwise, the Option expected error will occur!
(2) passwd user name and password configuration file
# Vi/home/svn/project_1/conf/passwd
[Users]
Manager1 = 123456 # each line is in the "username = password" Format
Manager 2 = 123123
Manager3 = 888888
(3) authz user permission configuration file
# Vi/home/svn/project_1/conf/authz
[Groups]
Managers = manager1, manager2 # define a group. managers includes two users: manager1 and manager2.
[/]
@ Managers = rw # define group managers with Read and Write Permissions
Manager3 = r # define that manager3 has read permission
* = # Users not defined above do not have any Permissions
4. Start and Stop the SVN Service
Start the SVN service:
[Root @ svn ~] # Svnserve-d-r/data/svndata/
-D Indicates running in the background
-R specifies that the root directory is/data/svndata/
Stop SVN service:
Ps-aux | grep svn

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.