centos7.2的网络配置: (已经配置可跳过)
vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
参考以下网络配置:
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=a90b6241-89da-450a-9742-d5b186a17084
DEVICE=eno16777736
ONBOOT=yes
IPADDR0=192.168.0.228
PREFIXO0=24
GATEWAY0=192.168.0.1
DNS1=192.168.0.1
配置完毕后,使用 systemctl restart network.service 重启网络,然后 ping www.linuxidc.com 测试是否网络连接通畅。
2. 配置防火墙,开启80、3306端口。CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
systemctl stop firewalld.service
systemctl disable firewalld.service
yum install iptables-services
vi /etc/sysconfig/iptables
加入红框的两行代码,请注意位置一定要对应。(防火墙开通80:3306端口可根据不同数据库或需求自己定义)
Firewall configuration written by system-config-firewall
Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT
Esc
:
wq!
#最后重启防火墙使配置生效
systemctl restart iptables.service
systemctl enable iptables.service
修改配置文件
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq!
setenforce 0
yum install httpd
**可能会用到的**
:
systemctl start httpd.service
#启动apache
systemctl stop httpd.service
#停止apache
systemctl restart httpd.service
#重启apache
systemctl enable httpd.service
#设置apache开机启动
systemctl restart httpd.service
CentOS 7.2 yum安装LAMP环境
由于yum源上没有mysql-server。所以必须去官网下载,这里 我们用wget命令,直接获取。
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,
systemctl restarat mysqld.service
初入安装 root用户没有密码:
[root@linuxidc-web linuxidc]#
mysql -u root
mysql>
set password for 'root'@'localhost' =password('123456');
mysql>
grant all privileges on *.* to root@'%'identified by '123456';
mysql>
flush privileges;
cat /etc/centos-release
yum remove php* php-common
CentOS/RHEL 7.x:
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
CentOS/RHEL 6.x:
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum install php70w php70w-opcache
php70w
php70w-bcmath
php70w-cli
php70w-common
php70w-dba
php70w-devel
php70w-embedded
php70w-enchant
php70w-fpm
php70w-gd
php70w-imap
php70w-interbase
php70w-intl
php70w-ldap
php70w-mbstring
php70w-mcrypt
php70w-mysql
php70w-mysqlnd
php70w-odbc
php70w-opcache
php70w-pdo
php70w-pdo_dblib
php70w-pear
php70w-pecl-apcu
php70w-pecl-imagick
php70w-pecl-xdebug
php70w-pgsql
php70w-phpdbg
php70w-process
php70w-pspell
php70w-recode
php70w-snmp
php70w-soap
php70w-tidy
php70w-xml
php70w-xmlrpc
service httpd restart
如果是Apache + PHP的话必须使用 PHPIniDir 指定php5的配置文件php.ini的路径
(下面代码块还未使用过,还在研究)
PHPINIDir /etc/php.ini
官网下载
: http://php.net/get/php-7.0.2.tar.gz/from/a/mirror
xshell 上传 (手动)
tar zxvf php-7.0.2.tar.gz
如果报错 可能是 tar 不支持 -z tar xvf php-7.0.2.tar.gz
进入文件
cd php-7.0.2
./configure --help
./configure 下载扩展 安装
./configure --prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
中途报错请参考 https://www.jb51.net/article/37487.htm
以下为部分代码:
错误:configure: error: libevent >= 1.4.11 could not be found
yum -y install libevent libevent-devel
错误:configure: error: Please reinstall the mysql distributio
yum -y install mysql-devel
错误:make: * [sapi/fpm/php-fpm] error 1
用make ZEND_EXTRA_LIBS='-liconv'编译
错误:configure: error: XML configuration could not be found
yum -y install libxml2 libxml2-devel
错误:configure: error: No curses/termcap library found
yum -y install ncurses ncurses-devel
错误:configure: error: xml2-config not found
yum -y install libxml2 libxml2-devel
错误:configure: error: Cannot find OpenSSL’s
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
yum -y install curl-devel
yum -y install libxslt-devel
make && make install
编译时报错 显示 编辑文件错误或者编译失败 请参考
网上下载,打入下面的命令(需要预装yum,不过一般发行版都整合yum的,自动下载安装软件仓库中最新的)
yum install gcc gcc-c++ autoconf automake
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
需要注意的是php7中www.conf这个配置文件配置phpfpm的端口号等信息,如果你修改默认的9000端口号需在这里改,再改nginx的配置
启动
/etc/init.d/php-fpm
vim /usr/local/php7/etc/php.ini
zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20141001/opcache.so
killall php-fpm
/etc/init.d/php-fpm
来自大佬的参考文章:
https://blog.csdn.net/21aspnet/article/details/47708763/