防火墙
将firewalld修改为iptables
代码语言:javascript复制systemctl stop firewalld
systemctl disable firewalld
yum -y install iptables-services
systemctl enable iptables
systemctl start iptables
vim /etc/sysconfig/iptables
service iptables restart
centos7以下为
代码语言:javascript复制chkconfig iptables off
管理 SELinux 策略
代码语言:javascript复制yum provides /usr/sbin/semanage
yum -y install policycoreutils-python
[root@localhost sbin]# semanage port -l|grep ssh
ssh_port_t tcp 22
#semanage port -a -t ssh_port_t -p tcp 10010
成功
存在的问题
代码语言:javascript复制[root@localhost ~]# semanage port -a -t http_port_t -p tcp 1220
ValueError: 没有管理 SELinux 策略或者无法访问存储。
如果出现这个情况的话,博主目前还没有发现怎么解决,就关闭吧
代码语言:javascript复制#vim /etc/sysconfig/selinux
代码语言:javascript复制SELINUX=disabled
修改ssh端口
代码语言:javascript复制vim /etc/ssh/sshd_config
service sshd restart
安装nginx
代码语言:javascript复制yum -u remove httpd
代码语言:javascript复制yum install gcc-c
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
wget https://nginx.org/download/nginx-1.17.9.tar.gz
tar zxvf nginx-1.17.9.tar.gz
cd nginx-1.17.9
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
注意:centos6./configre
的时候,报错:
需要安装
代码语言:javascript复制yum -y install pcre-devel
然后:
代码语言:javascript复制yum -y install zlib-devel
安装php7
代码语言:javascript复制#centos7
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
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 php70w-fpm php70w-opcache
vim /etc/php-fpm.d/
systemctl start php-fpm
systemctl enable php-fpm
systemctl daemon-reload
#centos6
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
#若无法yum则:
vim /etc/yum.repos.d/epel.repo
#文件第3行注释去掉,把第四行注释掉
yum install mod_php71w php71w-opcache
yum install php71w-cli php71w-mysql php71w-bcmath php71w-gd php71w-mcrypt php71w-mbstring php71w-odbc php71w-xml
#修改php配置文件
# 时区修改
date.timezone = PRC
# 上传文件大小修改
upload_max_filesize = 20M
# 提交文件大小
post_max_size = 20M
# 隐藏 HTTP Header 中的php信息
expose_php = Off
# 打开php错误提示
display_errors = On
#修改ngixn配置文件server中:
location ~ .php$ {
root /mnt/phpwww; #指定php的根目录
fastcgi_pass 127.0.0.1:9000; #php-fpm的默认端口是9000
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#默认ip无法访问问题
nginx.conf
server { listen 80 default; server_name _; return 500; }
#若页面无法写入权限,需要修改vim /etc/php-fpm.d/www.conf 用的group:user与root目录一直
#root运行php-fpm的话需要php-fpm -R
vi /etc/php-fpm.d/www.conf
#修改后如下:
[...]
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock
#这样nginx就可以使用php-fpm.sock了
安装mysql
代码语言:javascript复制#mysql5.7
yum install
yum install https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
#更多见http://www.heanny.cn/post-354.html
安装python3
安装依赖
代码语言:javascript复制yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum -y install gcc kernel-devel kenel-headers make bzip2
yum -y install gcc gcc-c zlib zlib-devel libffi-devel
wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz
tar -zxvf Python-3.7.6.tgz
cd Python-3.7.6
./configure
make && make install