Porting Recommand

Porting PHP Service

GCE是Google Cloud Platform上提供虛擬主機服務的一員,承襲了Google的強大,提供了無限量的環境與相當快速的網路,Management Portal的操作設計也相當便捷,這邊有機會做一個PHP專案的Porting,順手針對Porting GCE上面的PHP程式做了個記錄,目標是Porting到一台CentOS主機,記錄的幾點注意事項,給大家參考:

  • Install LAMP
    $ sudo yum  -y  install  httpd  php  php-mysql  mysql  mysql-server
    $ sudo yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
  • FW configure (GCE default enabled the iptables)
    $ sudo vi /etc/sysconfig/iptables
    ⇒ Add your port… link 80, 443...
  • SELinux setting (GCE default enable the SELinux)
    $ sudo vi /etc/sysconfig/selinux
    ⇒ SELINUX=disabled
  • Create persistence disk (GCE default root disk is only 10GB)

$ df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda1       9.9G  9.9G     0 100% /
tmpfs           1.8G     0  1.8G   0% /dev/shm
$ sudo mkdir -p /mnt/pd0
$ ls -l /dev/disk/by-id/google-*
lrwxrwxrwx. 1 root root  9 2013-12-23 06:55 /dev/disk/by-id/google-php-server -> ../../sda
lrwxrwxrwx. 1 root root  9 2013-12-23 11:22 /dev/disk/by-id/google-php-server-data-disk1 -> ../../sdb
lrwxrwxrwx. 1 root root 10 2013-12-23 06:55 /dev/disk/by-id/google-php-server-part1 -> ../../sda1
$ sudo /usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" /dev/disk/by-id/google-php-server-data-disk1 /mnt/pd0
safe_format_and_mount: Running: fsck.ext4 -a /dev/disk/by-id/google-php-server-data-disk1
safe_format_and_mount: fsck.ext4: Bad magic number in super-block while trying to open /dev/disk/by-id/google-php-server-data-disk1
safe_format_and_mount: /dev/disk/by-id/google-php-server-data-disk1:
safe_format_and_mount: The superblock could not be read or does not describe a correct ext2
safe_format_and_mount: ....
safe_format_and_mount: This filesystem will be automatically checked every 21 mounts or
safe_format_and_mount: 180 days, whichever comes first.  Use tune2fs -c or -i to override.
safe_format_and_mount: Running: mount -o defaults /dev/disk/by-id/google-php-server-data-disk1 /mnt/pd0
$ sudo mount -o defaults /dev/disk/by-id/google-php-server-data-disk1 /mnt/pd0
mount: /dev/sdb already mounted or /mnt/pd0 busy
mount: according to mtab, /dev/sdb is already mounted on /mnt/pd0

    • Mount persistence disk when boot

    $ sudo vi /etc/fstab
    UUID=a8cf...aaf98 / ext4    defaults,barrier=0 1 1
    tmpfs         /dev/shm      tmpfs   defaults        0 0
    devpts        /dev/pts      devpts  gid=5,mode=620  0 0
    sysfs         /sys          sysfs   defaults        0 0
    proc          /proc         proc    defaults        0 0
    /dev/sdb /mnt/pd0 ext4 defaults 1 1

    • Setup boot level services

    $ sudo chkconfig --level 23456 mysqld on
    $ sudo chkconfig --level 23456 httpd on

    • 設定file limit可以參考: