查看CentOS的版本号:
cat /etc/centos-release
#CentOS release 6.10 (Final)
uname -a
#Linux VM_16_5_centos 2.6.32-754.10.1.el6.x86_64 #1 SMP Tue Jan 15 17:07:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
df -h #查看磁盘容量
官方文档 http://nginx.org/en/linux_packages.html
1.更新yum yum update -y
2.安装epel-release源 (大部分已经自动安装) yum install -y epel-release
3.设置Nginx安装源 vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
#直接拖文件夹上去
4.安装nginx yum install -y nginx
5.查看nginx版本,启动nginx,设置开机自启动
nginx -v
## nginx version: nginx/1.14.1
systemctl enable nginx
systemctl nginx start
6. 检查Nginx配置是否有误
nginx -t -c /etc/nginx/nginx.conf
编写nginx文件,放入/etc/init.d/
nginx文件内容如下 在工具里面直接编辑否则会报错,需要修改文件格式[直接拖文件]
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/sbin/nginx #nginx实际安装路径
nginx_config=/etc/nginx/nginx.conf #nginx实际安装路径
nginx_pid=/var/run/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
chkconfig --add /etc/init.d/nginx
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
如果想随系统启动就执行:
/sbin/chkconfig --level 345 nginx on
nginx启动、停止、无间断服务重启,可选 start | stop | restart | reload | status | help
service nginx start
service nginx stop
service nginx reload
#第一步 配置yum源:
#在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/
# 下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
#第二步 安装mysql源
shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
#安装 最新 mysql yum 源
centos 6 :rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el6-2.noarch.rpm
centos 7 :rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
###vi /etc/yum.repos.d/mysql-community.repo 选择版本(备选)
1.2 选择版本 开启
# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
#第二步 安装MySQL
yum install mysql-community-server
#检查mysql源是否安装成功
shell> yum repolist enabled | grep "mysql.*-community.*"
systemctl start mysqld
#查看MySQL的启动状态
systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2016-06-24 04:37:37 CST; 35min ago
Main PID: 2888 (mysqld)
CGroup: /system.slice/mysqld.service
└─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server...
6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.
systemctl enable mysqld
systemctl daemon-reload
mysql -uroot -p
use mysql;
#低版本 服务器直接运行 以下命令
/usr/bin/mysqladmin -u root password 1233242;
UPDATE user SET Password = password ('123435') WHERE User = 'root' ;
#5.5版本以上 mysql 运行 以下命令
ALTER USER 'root'@'localhost' IDENTIFIED BY '12313242234';
#添加远程登录账户
GRANT ALL PRIVILEGES ON *.* TO 'xueyang'@'%' IDENTIFIED BY '1232423' WITH GRANT OPTION;
#/etc/my.cnf 添加
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
explicit_defaults_for_timestamp=1
max_connections=3600
1.检查当前安装的PHP包
yum list installed | grep php
#如果有安装的PHP包,先删除他们
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
**2.Centos **
Centos 5.X:
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm CentOs
Centos 6.x :
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm CentOs
Centos 7.X :
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#如果想删除上面安装的包,重新安装
rpm -qa | grep webstatic rpm -e 上面搜索到的包即可
3.运行yum install
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 php55w-dom.x86_64 php55w-devel.x86_64 --skip-broken
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 php56w-dom.x86_64 php56w-devel.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 php56w-dom.x86_64 php70w-devel.x86_64
#注:如果想升级到5.6把上面的55w换成56w就可以了。
4.安装PHP FPM
yum install php55w-fpm
yum install php56w-fpm
yum install php70w-fpm
#yum安装基本库
yum -y install automake autoconf libtool make gcc gcc-c++ libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
yum install -y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel freetype freetype-devel
1 安装phpize
yum install php-devel --skip-broken
#报错Error: php55w-common conflicts with php-common-5.4.16-46.el7.x86_64
#You could try using --skip-broken to work around the problem
# You could try running: rpm -Va --nofiles --nodigest
执行 yum install php55w-devel
2 下载扩展源码包,直接用wget
#wget下载github上的文件
wget https://github.com/nicolasff/phpredis/archive/master.zip
or
3 如果没装unzip,需要先安装unzip
yum install unzip
4 解压master.zip
unzip master.zip
5 解压目录为phpredis-master,进入!!!该文件夹,开始编译php扩展
phpize
6 配置环境
./configure
7 编译
make && make install
编译完成后显示:
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/lib64/php/modules/
进入/usr/lib64/php/modules/文件夹,发现redis.so的扩展
8 使redis扩展生效
vim /etc/php.ini,添加下面的扩展
extension=redis.so
or
vim /etc/php.d/redis.ini
#内容:
;ble redis extension module
extension=redis.so
9 重启服务器
service php-fpm restart
1 前提需要安装:
yum install php55w-process
2 下载扩展源码包,直接用wget
#wget下载github上的文件
wget -c http://pecl.php.net/get/swoole-4.2.12.tgz
3 如果没装unzip,需要先安装unzip
yum install unzip
4 解压swoole-4.2.12.tgz
tar xzvf swoole-4.2.12.tgz
5 解压目录为swoole-4.2.12,进入该文件夹,开始编译php扩展
phpize
6 配置环境
./configure
7 编译
make && make install
编译完成后显示:
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/lib64/php/modules/
进入/usr/lib64/php/modules/文件夹,发现swoole.so的扩展
8 使swoole扩展生效
修改/etc/php.ini,添加下面的扩展
extension=swoole.so
or
vim /etc/php.d/swoole.ini
#内容:
;ble swoole extension module
extension=swoole.so
9 重启服务器
service php-fpm restart
php -m
查看:
ps -ef | grep lzm_*
后台运行:cd /home/www/ltzs/crontable/
php start.php -s start --worker --checktime false -m -d //218 实例
查看:
ps -ef | grep lzm_*
1.yum install subversion,通过yum安装svn服务
2.svnserve --version,查看是否安装成功
3.创建svn仓库目录和对应代码目录
mkdir -p /home/svn/game
mkdir -p /home/www/game
4.通过svn命令创建自己得svn同步库,并查看是否创建成功
svnadmin create /home/svn/game
5.分别修改三个配置文件
authz为访问权限配置,passwd为访问用户密码配置,svnserve.conf为该库得svn其他相关配置。
***注意:修改配置文件时,所有的元素需要顶格填写,不能出现空格,否则会出现连接不上等问题。
chmod -R 755 post-commit
6.启动svn:
svnserve -d -r /home/svn
7.关闭:
killall svnserve
资源路径 : svn://IP/game
第一次 同步 需要手动同步
svn co svn://IP/game /home/www/game
启动:
service redis restart
service nginx restart
service mysqld restart
service php-fpm restart
service svnserve restart
iptables 策略
方式一
iptables -I INPUT 5 -p tcp --dport 3690 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 6379 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 80 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 3306 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 9000 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 3690 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 443 -j ACCEPT
方式二
firewall-cmd --zone=public --add-port=3690/tcp --permanent
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=9000/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
开机启动:
chkconfig --list
chkconfig redis on systemctl enable redis.service
chkconfig nginx on 或者 systemctl enable nginx.service
chkconfig mysqld on systemctl enable mysqld.service
chkconfig php-fpm on systemctl enable php-fpm.service
chkconfig svnd on systemctl enable svnserve.service
注意事项:
一、关闭 sxlinux
注意 修改 nginx根目录出现不能访问的问题:
文件夹权限没有问题,关闭 setenforce 0
打开 selinux 配置文件
[root@localhost ~]# vim /etc/selinux/config
二、修改缓存目录权限
chmod -R 777 /var/lib/php/session 【必做】