CentOS 7
  • 5,250 views,
  • 2016-04-23,
  • 上傳者: 洪國恩,
  •  0
4fd31af67be517e629b92df628fccee6.png
安裝及設定 CentOS 7 ( 分別有 php5.6 與 php7 的安裝說明)
步驟
1.
安裝 PHP7.2
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 php72w php72w-opcache php72w-cli php72w-common php72w-devel php72w-fpm php72w-gd php72w-imap php72w-mbstring php72w-mcrypt php72w-opcache php72w-pdo php72w-xml php72w-snmp php72w-soap php72w-tidy php72w-mysql php-getid3 php72w-bcmath
2.
安裝 PHP7.1
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 php71w php71w-opcache php71w-cli php71w-common php71w-devel php71w-fpm php71w-gd php71w-imap php71w-mbstring php71w-mcrypt php71w-opcache php71w-pdo php71w-xml php71w-snmp php71w-soap php71w-tidy php71w-mysql php-getid3 php71w-bcmath
3.
安裝 PHP7
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 apache mariadb-server mariadb
yum install php71w php71w-opcache
yum install php71w-cli php71w-common php71w-devel php71w-fpm php71w-gd php71w-imap php71w-mbstring php71w-mcrypt php71w-opcache php71w-pdo php71w-xml php71w-snmp php71w-soap php71w-tidy php71w-mysql
yum install libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
 
4.
安裝 php5.6
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 apache mariadb-server mariadb
yum install php56w php56w-opcache 
yum install php56w-cli php56w-common php56w-devel php56w-fpm php56w-gd php56w-imap php56w-mbstring php56w-mcrypt php56w-opcache php56w-pdo php56w-xml php56w-snmp php56w-soap php56w-tidy php56w-mysql
yum install libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
其他設定
5.
安裝其他相關的套件
yum install telnet ntpdate sntp unzip wget mlocate net-tools mailx iftop id3lib libid3tag
6.
關閉 SELinux
vi /etc/selinux/config
vi /etc/selinux/config
把 SELINUX=permissive
改為
SELINUX=disabled
7.
Samba
安裝 yum install samba
[global]
unix charset = UTF8
guest account = apache
load printers = no
printing = bsd
usershare allow guests = Yes
max protocol = SMB2

security = user
map to guest = Bad User

strict locking = no

[www]
comment = Web Directory
path = /var/www
public = yes
writable = yes
browseable = yes
printable = no
guest ok = yes
write list = +staff
create mode    = 0777
directory mode = 0777

create mask = 0777
force create mode = 0777

directory mask = 0777
force directory mode = 0777

force user = apache
force group = apache

acl check permissions = False
8.
Apache (multiple vhost)
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog "logs/access_log" vcommon

UseCanonicalName off

<VirtualHost *:80>
ServerAlias *
VirtualDocumentRoot /var/www/cloud/%0/

CustomLog logs/cloud-access_log vcombined
ErrorLog logs/cloud-error_log

<Directory "/var/www/cloud/*/">
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
/etc/httpd/conf.d/vhosts.conf
9.
設定防火牆
# 加入 80/443 port (永久)
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=443/tcp --permanent

# 允許某個 ip 才能連線
firewall-cmd --add-rich-rule="rule family="ipv4" source address="192.168.1.1" accept" --permanent

# 允許某個區段的 IP 才能連線
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='192.168.1.0/24' accept"

# 設定好後需要執行 reload
firewall-cmd --reload

# 也可以執行以下指令顯示目前的設定
firewall-cmd --list-all


# 如果要刪除的話,就改成 remove-port 即可
firewall-cmd --remove-port=8080/tcp --permanent
你也可以直接修改 /etc/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="dhcpv6-client"/>
  <service name="ssh"/>
  <port protocol="tcp" port="443"/>
  <port protocol="tcp" port="80"/>
  <rule family="ipv4">
    <source address="192.168.1.1"/>
    <accept/>
  </rule>
  <rule family="ipv4">
    <source address="192.168.1.2"/>
    <accept/>
  </rule>
</zone>

</zone>
10.
PHP 設定
以下為參考設定,其餘的就看應用設定囉,並不是開越大越好喔!!
memory_limit = 1024M
max_execution_time = 300
post_max_size = 1024M
upload_max_filesize = 1024M
max_input_time = 600
always_populate_raw_post_data = -1
11.
啟用相關服務
systemctl enable firewalld; systemctl restart firewalld;
systemctl enable httpd; systemctl restart httpd;
systemctl enable mariadb; systemctl restart mariadb;
Facebook 討論區載入中...
資料夾 :
發表時間 :
2016-04-23 14:44:00
觀看數 :
5,250
發表人 :
洪國恩
部門 :
老洪的 IT 學習系統
QR Code :