The Centos6.4+nginx+mysql+php+phpmyadmin integration process is described in the example. Share to everyone for your reference, specific as follows:
Installed a lot of machines, do a lot of repetitive work, finally, summed up the following CentOS experience:
Note: Many problems are not the problem, first the SELinux off! Setenforce 0, or you're going to die badly!
1. Update the source first
Enable domestic Source: 163 or Sohu
163:http://mirrors.163.com/.help/centos.html
If you want to use the new software, it is recommended that you use the REPL and Remi sources
#remi的源
rpm-ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm--IMPORT/ETC/PKI/RPM-GPG
source Rpm-ivh http://download.fedoraproject.org/pub/epel/6/x86_64/of/rpm-gpg-key-epel-6 #Fedora repl
epel-release-6-8.noarch.rpm
rpm--import/etc/pki/rpm-gpg/rpm-gpg-key-remi
Then Yum update upgrade system
The following is the installation of the software we need, such as NGINX+PHP+PHP-FPM+MYSQL+VSFTPD, etc.
The following starts the configuration:
1. Set system time
Cp/usr/share/zoneinfo/asia/hong_kong/etc/localtime Date #查看系统时间 */30 * * * * *
/usr/sbin/ntpdate time.nist.gov< C3/>crontab-e
Join this line: */30 * * * */usr/sbin/ntpdate time.nist.gov
2. Update system
3. Install Nginx:
Niginx official update source added: Vim/etc/yum.repos.d/nginx.repo
Add the following content
[Nginx]
Name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
Yum Install Nginx
Optimize Nginx configuration:
#根据CPU核心processes而定
worker_processes 6;
Worker_cpu_affinity 000001 000010 000100 001000 010000 100000;<br><br>
#启用epoll
worker_rlimit_ Nofile 51200;
Events {
worker_connections 51200;
Use Epoll;
}
#参数调整
sendfile on;
Tcp_nopush on;
Tcp_nodelay on;
Server_tokens off;
Keepalive_timeout;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32k;
Large_client_header_buffers 4 32k;
Client_max_body_size 50m;
#fastcgi优化
fastcgi_connect_timeout;
Fastcgi_send_timeout;
Fastcgi_read_timeout;
Fastcgi_buffer_size 64k;
Fastcgi_buffers 4 64k;
Fastcgi_busy_buffers_size 128k;
Fastcgi_temp_file_write_size 256k;
#开启gzip并优化
gzip on;
Gzip_min_length 1k;
Gzip_buffers 4 16k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_vary on;
To set the boot boot:
Service Nginx start
chkconfig nginx
on #安装php, php-fpm
yum install php php-fpm php-bcmatch Php-mbstring Php-mcrypt Php-mysql
To configure the PHP script to run:
cp/etc/nginx/conf.d/default.conf Etc/nginx/conf.d/default.confbak
vim/etc/nginx/conf.d/default.conf
Set the default directory for your Web site: #这里php-fpm is the way to listen to the port, the same machine is best to adopt a UNIX socket
#去除下面这段内容的注释
Location ~ \.php$ {
root/home/www;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
#注意其中fastcgi_param行的参数, change to $document_root$fastcgi_script_name, or use absolute path
4. VSFTPD Configuration
First configure iptables, vi/etc/sysconfig/iptables, copy--dport 22 line, paste into 21 port. Save, restart service iptables restart.
Yum install vsftpd FTP touch/var/log/vsftpd.log service vsftpd start chkconfig vsftpd on vim/e tc/vsftpd/vsftpd.conf #修改相关参数如下: #设定不允许匿名访问 anonymous_enable=no #设定本地用户可以访问.
Note: If you use a virtual host user, all virtual users will not be able to access the project if it is set to No. Local_enable=yes #使用户不能离开主目录 and make documents Chroot_list_enable=yes Chroot_list_file=/etc/vsftpd/chroot_list # Set the VSFTPD Service log save path. Note that the file does not exist by default. You have to touch it manually, and the previous steps have created Xferlog_file=/var/log/vsftpd.log #允许使用ASCII模式上传和下载 ascii_upload_enable=yes ascii_download_ Enable=yes #PAM认证文件名. Pam will be certified according to/ETC/PAM.D/VSFTPD PAM_SERVICE_NAME=VSFTPD #以下这些是关于Vsftpd虚拟用户支持的重要CentOS FTP service configuration project.
These settings are not included in the default vsftpd.conf and you will need to manually add the Rhel/centos FTP service configuration yourself.
#设定启用虚拟用户功能. Guest_enable=yes #指定虚拟用户的宿主用户. There is already a built-in FTP user in the-rhel/centos guest_username=ftp #设定虚拟用户个人vsftp的RHEL/centos FTP service file storage path. CentOS FTP Service file (profile name = Virtual user name) for storing the virtual user's personality user_config_dir=/etc/vsftpd/vuser_conf touch/etc/vsftpd/chroot_list echo FTP >>/etc/vsftpd/chroot_list Yum Install DB4 db4-utils vim/etc/vsftpd/vuser_passwd.txt
Add the appropriate user information, where the odd behavior you add the user's account number, even password, can not have spaces
UserName1
Password1
UserName2
Password2
Save file exit, generate user authenticated db file
Db_load-t-T hash-f/etc/vsftpd/vuser_passwd.txt/etc/vsftpd/vuser_passwd.db
VIM/ETC/PAM.D/VSFTPD
Use # to annotate all the content, and then add the following two lines:
Auth Required pam_userdb.so db=/etc/vsftpd/vuser_passwd account required pam_userdb.so Db=/etc/vsftpd/vuser_
passwd
Save exit. Then create the FTP Service folder for the virtual user, as well as the profile of the account user added in the previous article
mkdir/etc/vsftpd/vuser_conf/
vim/etc/vsftpd/vuser_conf/username1
Fill in the following content:
#username1用户的根目录 (own decision)
local_root=/home/www/ftp
write_enable=yes
anon_umask=0
anon_world_ Readable_only=no
anon_upload_enable=yes
anon_mkdir_write_enable=yes
anon_other_write_enable=yes
Save the content and exit. To create and set permissions for the user root that is set in the above configuration file
Mkdir/home/www/ftp
chmod 777/home/www/ftp
service vsftpd restart
Ok
#有时候会出现, you can connect FTP, but not the directory, this is the iptable port problem. Open PASV, vim/etc/vsftpd/vsftpd.conf
Pasv_enable=yes
pasv_min_port=9000
pasv_max_port=9020
Then in the iptables inside add these two ports, or the front said, Yy line 22, and then P, the 22 to 9,000:9,020;
And it could be the shutdown of the SELinux,
modprobe ip_nat_ftp
Service iptables Restart && service vsftpd restart
5. Install Mysql5.6
Yum Update
#数据库服务器的安装, please find the latest RPM RPM-UVH in MySQL official
http://dev.mysql.com/get/ mysql-community-release-el6-5.noarch.rpm
Yum Install Mysql-server
Remember to run when the installation is complete
Mysql_security_installation
Remote connection, but also to join the mysql3306 Port iptables, the same use of the previous method, copy a sentence of 22, changed to 3306, restart iptables can be.
Configuring a MySQL Remote connection: command line using root login
mysql-uroot-p use
mysql;
Update user Set host = '% ' where user = ' root ';
Other possible works:
Install phpMyAdmin
Google phpMyAdmin find the address in SourceForge, and then wget down in the root directory of the site.
Extract, rename directory, enter directory,
CP config.sample.inc.php config.inc.php
Restart Nginx
Note that there is a change in the browser to enter the phpMyAdmin address, the following error may occur:
Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PH P installation properly.
The owner of the/var/lib/php/session needs to be changed to Nginx
Chown-r nginx:nginx/var/lib/php/session
Should now be able to access the ...
Configuring a MySQL remote connection
Because of management needs, we need to remotely connect MySQL for management. After installing the phpMyAdmin, the user can choose to create a new user, set the host to need to connect the host IP or any host can
To mount the hard drive automatically:
Because of an external hard drive, you have to configure the power-on mount automatically. Vim/etc/fstab Add:
/dev/sdc/mnt/data Auto Defaults 0 0
CentOS Network configuration:
IP Settings:/etc/sysconfig/network-scripts/ifcfg-eth0
Gateway Settings:/etc/sysconfig/network
DNS settings:/etc/resolv.conf
Restart Network:
Close Seliinux
In the later work, found that many places inconvenient, such as FTP can not upload problems, SSH remote can not connect, and so on, so close SELinux, run the following command:
#/usr/sbin/setenforce 0
#echo "Usr/sbin/setenforce 0" >>/etc/rc.local
This will turn off the SELinux to join the boot up.
I hope this article will help you with your CentOS server configuration.