【MySql 5.6】:
[php]
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
成功安装之后重启mysql服务
service mysqld restart
初次安装mysql是root账户是没有密码的
设置密码的方法
mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password(‘mypasswd’);
mysql> exit
[/php]
【nginx】
[php]
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl–devel
wget http://nginx.org/download/nginx-1.7.4.tar.gz
tar -zxvf nginx-1.7.4.tar.gz
cd nginx-1.7.4
./configure \
–prefix=/usr/local/nginx \
–with-http_realip_module \
–with-http_sub_module \
–with-http_gzip_static_module \
–with-http_stub_status_module \
–with-pcre
make
make install
[/php]
【php】:
[php]
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64
yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64
yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
yum install php55w-fpm
yum install php56w-fpm
yum install php70w-fpm
[/php]
【php-fpm配置】
[php]
groupadd www-data
useradd -g www-data www-data
编辑/etc/php-fpm.d/www.conf
listen.owner = www-data
listen.group = www-data www-data
listen.mode = 0666
[/php]
【配置nginx脚本】
[php]
[Unit]
Description=nginx – high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
放到/usr/lib/systemd/system/nginx.service
执行
systemctl daemon-reload
添加自启动
systemctl enable nginx.service
systemctl enable mysqld.service
systemctl enable php-fpm.service
[/php]
【禁用IPv6】
[php]
编辑文件
vi /etc/default/grub
在第5行加入:ipv6.disable=1
修改后如下
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
执行命令
grub2-mkconfig -o /boot/grub2/grub.cfg
验证
可以再次运行ifconfig
[/php]
【nginx基本 带thinkphp rewirte】
[php]
#worker_processes 1;
user www-data;
worker_processes 8;
error_log /usr/local/nginx/logs/nginx_error.log crit;
worker_rlimit_nofile 65535;
pid /run/nginx.pid;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6].(?!.*SV1)";
server_tokens off;
#limit_zone limit $binary_remote_addr 10m;
log_format access ‘$remote_addr – $remote_user [$time_local] "$http_host $request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" $http_x_forwarded_for’;
server {
listen 80;
server_name localhost;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
root html;
index index.html index.htmi index.php;
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?s=$1 last;
rewrite ^/$ /index.php last;
break;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)\??([\=a-z0-9]+)?$
{
access_log off;
expires 30d;
}
location ~ .*\.(js|css)\??([\=a-z0-9]+)?$
{
access_log off;
expires 30d;
}
location ~ /\.ht
{
deny all;
}
}
}
[/php]
【VSFTP】
[php]
yum install vsftpd pam* db4* -y
useradd ftpuser -s /sbin/nologin
vi /etc/vsftpd/vsftpd.conf
[/php]
[php]
anonymous_enable=YES –> anonymous_enable=NO //不允许匿名用户访问,默认是允许。
#chroot_list_enable=YES –> chroot_list_enable=YES //不允许FTP用户离开自己主目录,默认是被注释掉的。
#chroot_list_file=/etc/vsftpd/chroot_list –> chroot_list_file=/etc/vsftpd/chroot_list
vi /etc/vsftpd/chroot_list 直接wq
local_enable=YES //允许本地用户访问,默认就是YES,不用改
write_enable=YES //允许写入,默认是YES,不用改
local_umask=022 //上传后文件的权限掩码,不用改
dirmessage_enable=YES //开启目录标语,默认是YES,开不开无所谓,我是默认就行
xferlog_enable=YES //开启日志,默认是YES,不用改
connect_from_port_20=YES //设定连接端口20,不用改
xferlog_std_format=YES //设定vsftpd的服务日志保存路径,不用改
(这步后面要有几个操作才能运行,也就是touch这个文件(见第五步),因为它本身不存在,而且还要给文件写入的权限)
#idle_session_timeout=600 –> idle_session_timeout=600 //会话超时,客户端连接到ftp但未操作,默认被注释掉,可根据个人情况修改
#async_abor_enable=YES –> async_abor_enable=YES //支持异步传输功能,默认是注释掉的,去掉注释
#ascii_upload_enable=YES –> ascii_upload_enable=YES //支持ASCII模式的下载功能,默认是注释掉的,去掉注释
#ascii_download_enable=YES –> ascii_download_enable=YES //支持ASCII模式的上传功能,默认是注释掉的,去掉注释
#ftpd_banner=Welcome to blah FTP service //FTP的登录欢迎语,本身是被注释掉的,去不去都行
#chroot_local_user=YES –> chroot_local_user=YES //禁止本地用户登出自己的FTP主目录,本身被注释掉,去掉注释
pam_service_name=vsftpd //设定pam服务下vsftpdd的验证配置文件名,不用改
userlist_enable=YES //拒绝登录用户名单,不用改
TCP_wrappers=YES //限制主机对VSFTP服务器的访问,不用改(通过/etc/hosts.deny和/etc/hosts.allow这两个文件来配置)
//添加
pam_service_name=vsftpd
userlist_file=/etc/vsftpd/vsftpd/user_list
tcp_wrappers=YES
guest_enable=YES
guest_username=ftpuser
virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd/vconf
[/php]
[php]
touch /var/log/vsftpd.log //日志文件
chown vsftpdadmin.vsftpdadmin /var/log/vsftpd.log //属于vsftpdadmin这个宿主
mkdir /etc/vsftpd/vconf/
touch /etc/vsftpd/vconf/vir_user
vi /etc/vsftpd/vconf/vir_user
virtualuser //用户名
12345678 //密码
注意:第一行用户名,第二行是上一行用户名的密码,其他人的以此类推
db_load -T -t hash -f /etc/vsftpd/vconf/vir_user /etc/vsftpd/vconf/vir_user.db
chmod 600 /etc/vsftpd/vconf/vir_user.db
chmod 600 /etc/vsftpd/vconf/vir_user
清空/etc/pam.d/vsftpd
echo "auth required pam_userdb.so db=/etc/vsftpd/vconf/vir_user" >> /etc/pam.d/vsftpd
echo "account required pam_userdb.so db=/etc/vsftpd/vconf/vir_user" >> /etc/pam.d/vsftpd
[/php]
[php]
touch /etc/vsftpd/vconf/virtualuser
vim /etc/vsftpd/vconf/virtualuser
输入:
local_root=/home/virtualuser //虚拟用户的个人目录路径
anonymous_enable=NO
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
idle_session_timeout=600
data_connection_timeout=120
max_clients=10
max_per_ip=5
local_max_rate=1048576 //本地用户的最大传输速度,单位是Byts/s,我设定的是10M
[/php]
[php]
chmod a-w 目录地址
禁止chroot根目录的写权限vsftp 2.3.5强制安全策略
[/php]