Thứ Năm, 11 tháng 5, 2017

Adding an existing project to GitHub using the command line

My answer is not different but I am adding more information because those that are new could benefit from filling in the gaps in information.

After you create the repo on github they have instructions. You can follow those. But here are some additional tips because I know how frustrating it is to get started with git.
Let's say that you have already started your project locally. How much you have does not matter. But let's pretend that you have a php project. Let's say that you have the index.php, contact.php and an assets folder with images, css, and fonts. You can do it this way (easy), but there are many options:

Option 1

Login to your github account and create the repo.

enter image description here
In the following screen you can copy it down where you need it if you click the button (right side of screen) to "clone in desktop". 
enter image description here
You can (or do it another way) then copy the contents from your existing project into your new repo. Using the github app, you can just commit from there using their GUI (that means that you just click the buttons in the application). Of course you enter your notes for the commit.

Option 2

  • Create your repo on github as mentioned above.
  • On your computer, go to your directory using the terminal. using the linux command line you would cd into the directory. From here you run the following commands to "connect" your existing project to your repo on github. (This is assuming that you created your repo on github and it is currently empty)
first do this to initialize git (version control).
git init
then do this to add all your files to be "monitored." If you have files that you want ignored, you need to add a .gitignore but for the sake of simplicity, just use this example to learn.
git add .
Then you commit and add a note in between the "" like "first commit" etc.
 git commit -m "Initial Commit"
Now, here is where you add your existing repo
git remote add github <project url>
But do not literally type <project url>, but your own project URL. How do you get that? Go to the link where your repo is on github, then copy the link. In my case, one of my repos is https://github.com/JGallardo/urbanhistorical so my resulting url for this command would just add .git after that. So here it would be
git remote add github https://github.com/JGallardo/urbanhistorical.git
Test to see that it worked by doing
git remote -v
You should see what your repo is linked to.
enter image description here
Then you can push your changes to github
git push github master
or
git push origin master
If you get an error, try
git push -f origin master

Thứ Năm, 30 tháng 3, 2017

Cho mượn tiền mà có nguy cơ bị QUỴT, hãy nói với “con nợ” của bạn những điều này

Việc cho mượn tiền rồi mất cả tiền lẫn bạn không còn quá lạ lẫm trong cuộc sống này, nhưng hãy nghe vị cao tăng này bày cho bạn cách mượn tiền không mất còn lời.Trong cuộc sống này, dù muốn dù không thì cũng đôi lần bạn sẽ được hỏi mượn tiền. Và từ chối là việc vô cùng khó khăn, nhưng có những người dù bạn biết rằng cho mượn sẽ mất thì cũng không cam lòng tí nào. Vậy làm sao để cho người mượn tiền tự giác trả nợ?

Việc cho mượn tiền rồi mất cả tiền lẫn bạn không còn quá lạ lẫm trong cuộc sống này, nhưng hãy nghe vị cao tăng này bày cho bạn cách mượn tiền không mất còn lời.Trong cuộc sống này, dù muốn dù không thì cũng đôi lần bạn sẽ được hỏi mượn tiền. Và từ chối là việc vô cùng khó khăn, nhưng có những người dù bạn biết rằng cho mượn sẽ mất thì cũng không cam lòng tí nào. Vậy làm sao để cho người mượn tiền tự giác trả nợ?
Theo lời dạy của một bậc cao nhân, có cách để bạn có thể từ chối được việc cho vay tiền mà vẫn không làm mất lòng người mượn. Đó là hãy nói với họ những điều này:
Trong cuộc sống này việc khó nhất chính là vay nợ
Bạn hãy đứng ở vị trí người đi vay và nhớ lấy điều này: Người cho bạn vay nợ hay giúp đỡkhi bạn gặp khó khăn là người vô cùng đáng quý, nhất là ở xã hội bây giờ, con người ta chỉ biết sống cho mình. Vì vậy, gặp người sẵn sàng giúp đỡ mình lúc khó khăn thì phải luôn ghi nhớ, trân trọng cả đời.
Người cho bạn mượn tiền khi cần chưa hẳn là người ta dư dả, nhưng vì tình nghĩa, người ta sẵn lòng giúp đỡ thí chủ vào lúc khốn đốn.

Vật mà bạn mượn không đơn giản là tiền, nó là sự tin tưởng, là tấm lòng trân quý của người cho mượn đến bạn. Hãy lấy đó là động lực để đầu tư đúng đắn vào tương lai, đừng nghĩ người ta giàu có cho mình vay vài đồng thì có xá gì mà tiêu hoang phí, không tính toán.
Một lần bất tín vạn lần bất tin, đừng bao giờ quỵt tiền nợ dù bạn có khó khăn đến nhường nào đi nữa. Vì như vậy không những đánh mất mối lương duyên tốt đẹp mà còn tự đạp giá trị bản thân xuống vũng bùn. Tình cảm bạn bè là thứ quý giá, tìm được người sẵn lòng giúp đỡ ta khi khó khăn lại càng đáng phải trân quý hơn.
Không những chỉ trân trọng những người cho ta mượn tiền, hay giúp đỡ ta khi khốn khó, mà trong cuộc đời này bạn hãy ghi nhớ những điều sau:
– Khi gặp chuyện xích mích dẫn đến tranh cãi đôi bên, người xin lỗi trước chưa hẳn đã sai mà do họ coi trọng mối quan hệ hơn cái tôi cá nhân của mình.
– Người luôn dành phần khó trong công việc tập thể chưa hẳn là muốn thể hiện để tiến thủ hay ngu ngốc chọn việc nặng mà là họ rất có trách nhiệm với tập thể, muốn giảm gánh nặng cho mọi người.
– Bạn làm ăn chung khi nhường phần lợi hơn cho ta, chưa hẳn họ ngốc không biết tính toán mà đó chính là con người biết sẻ chia.
– Người hay chủ động thanh toán cho các bữa hẹn chưa hẳn họ rủng rỉnh tiền bạc, mà bởi họ xem trọng chân tình dành cho thí chủ cao hơn tiền bạc.
– Người luôn sẵn tay giúp đỡ ta khi khó khăn đó là do họ yêu thương và tin tưởng ta, đừng nghĩ họ mang nợ hay là bổn phận của họ mà coi nhẹ.

Thứ Ba, 21 tháng 2, 2017

Calculating start and end dates of a week.

"How do I calculate start (monday) and end (sunday) dates from a given week number for a specified year?" Instead of having to come up with your own algorithm you can simply do the following in PHP 5.1 and higher:

<?php
// Monday
echo date(
    datetime::ISO8601,
    strtotime("2006W37"));

// Sunday
echo date(
    datetime::ISO8601,
    strtotime("2006W377"));
?>

The format is " year 'W' weeknr ( daynr )?" where the default daynr is 1 being the Monday of that week. The daynr can be in the range 0 to 7. The weeknr is the ISO week number . Please note that the " year '-W' weeknr ( '-' daynr )?" format is only supported in PHP 5.2 and higher.

Thứ Sáu, 18 tháng 11, 2016

Roundcube: connection to storage server failed

1) If you've recently updated your version of dovecot, and if you get this error in RoundCube:
connection to storage server failed
it may be that the dovecot index files are for an older version of dovecot, and don't work full with the new version.
To resolve that issue, simply delete all dovecot index files, and dovecot will re-create them when it notices they're missing.

You should test this on one User first, before doing it on all Users.
Also, backup the dovecot* files of the test User first (shouldn't be required, but not a bad thing to do)
cd /home
/etc/init.d/dovecot stop
rm -f */imap/*/*/Maildir/dovecot*
rm -f */imap/*/*/Maildir/.*/dovecot*
rm -f */Maildir/dovecot*
rm -f */Maildir/.*/dovecot*
/etc/init.d/dovecot restart
Dovecot will recreate the dovecot* files once the User logs in.




2) Causing number 2 would be if dovecot has hit the per-IP limit.  If that's the case, you'd see something like this in your /var/log/maillog:
imap-login: Maximum number of connections from user+IP exceeded (mail_max_userip_connections=10)
The solution for that is to add the following to the very bottom of your /etc/dovecot/dovecot.conf file:
mail_max_userip_connections = 15
remote 127.0.0.1 {
       mail_max_userip_connections = 40
}
where the "remote 127.0.0.1" refers to the local limit (connections from roundcube and squirrelmail), and the limit of 15, just above it, is the per-IP limit for external IP addresses.  There are a couple other ways of going about it (can be done in the "protocol imap" section, but the method metioned here also covers pop without any extra code.




3) Another error:
master: Warning: service(imap-login): process_limit (100) reached, client connections are being dropped
The solution for this is to increase the process_limit for imap.  Edit the /etc/dovecot.conf, find the "service imap-login {" section, and set a higher limit, eg:
service imap-login {
       process_limit = 800
       process_min_avail = 16
       user = dovecot
}





4) Beyond that, check your apache logs for possible clues:
cd /var/log/httpd
tail -n 20 error_log
tail -n 20 domains/domain.com.log
tail -n 20 domains/domain.com.error.log
and the dovecot logs:
tail -n 20 /var/log/maillog


5) Check:
/etc/hosts

to ensure you see:
127.0.0.1   localhost
and that localhost does not exist under other IPs.

6) The error can also showed up when the /etc/virtual/domain.compasswd file is not in the correct format.
It should have 7 columns, separated by colons.  If you only see 2 columns, (1 colon), then run the ./build todovecot command.

Thứ Ba, 15 tháng 11, 2016

Cách khắc phục lỗi chữ bị răng cưa trong Photoshop

Nhiều bạn thắc mắc là tại sao chữ trong Photoshop lại bị răng cưa? mà không được mịn ở đường viền xung quanh chữ như hình dưới:



Nếu bạn cũng gặp trường hợp như vậy thì hãy làm theo các bước dưới đây.
B1. Chọn Text (T) để vào chữ viết bình thường.
B2. Chọn Sharp

Lý do bị răng cưa là bạn để chế độ None


Chủ Nhật, 16 tháng 10, 2016

Hướng dẫn mở và khóa port trên Linux

Trong quá trình sử dụng hoặc quản lý server linux, tùy theo mục đích và yêu cầu công việc mà bạn cần thực hiện mở hoặc khóa một cổng (port) trên server để phục vụ cho tính an toàn và bảo mật.
Bài viết sẽ hướng dẫn cách cơ bản để có thể mở hoặc khóa các port.
Một số port phổ biến thường được sử dụng:
TCP port 80 – HTTP Server
TCP port 443 – HTTPS Server
TCP port 25 – Mail Server
TCP port 22 – OpenSSH (remote) secure shell server
TCP port 110 – POP3 (Post Office Protocol v3) server
TCP port 143 – Internet Message Access Protocol (IMAP) - Management of email messages
TCP / UDP port 53 – Domain Name System (DNS)
Bạn có thể sử dụng lênh nano /etc/services (vi /etc/services) để xem danh sách các port

Mở port 80 Firewall trên Centos

Enable Firewall port 80 Centos – Mở port cho phép truy cập web trừ internet
Mặc định Centos/RedHat… chặn port 80 truy cập từ internet vào server của bạn. Vì vậy bạn cần phải mở Firewall port 80 cho truy cập vào web từ bên ngoài

# /sbin/iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT

# service iptables save

1.     Khóa cổng vào (Block Incoming Port)
 
/sbin/iptables -A INPUT -p tcp --destination-port {PORT-NUMBER-HERE} -j DROP
 
### interface section use eth1 ###
/sbin/iptables -A INPUT -i eth1 -p tcp --destination-port {PORT-NUMBER-HERE} -j DROP
 
### only drop port for given IP or Subnet ##
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port {PORT-NUMBER-HERE} -s {IP-ADDRESS-HERE} -j DROP
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port {PORT-NUMBER-HERE} -s {IP/SUBNET-HERE} -j DROP
Ví dụ: Để khóa imcoming port 80 (HTTP server), ta sử dụng lệnh sau:
 
/sbin/iptables -A INPUT -p tcp --destination-port 80 -j DROP
/sbin/service iptables save
Để khóa port 80 với tất cả IP, chỉ cho duy nhất IP có địa chỉ 10.7.3.2 truy cập
 
/sbin/iptables -A INPUT -p tcp -i eth1 -s ! 10.7.3.2 --dport 80 -j DROP

2.     Khóa cổng ra (Block Outgoing Port)
 
/sbin/iptables -A OUTPUT -p tcp --dport {PORT-NUMBER-HERE} -j DROP
 
### interface section use eth1 ###
/sbin/iptables -A OUTPUT -i eth1 -p tcp --dport {PORT-NUMBER-HERE} -j DROP
 
### only drop port for given IP or Subnet ##
/sbin/iptables -A OUTPUT -i eth0 -p tcp --destination-port {PORT-NUMBER-HERE} -s {IP-ADDRESS-HERE} -j DROP
/sbin/iptables -A OUTPUT -i eth0 -p tcp --destination-port {PORT-NUMBER-HERE} -s {IP/SUBNET-HERE} -j DROP
Ví dụ: Để khóa outgoing port 25, ta sử dụng lệnh sau:
 
/sbin/iptables -A OUTPUT -p tcp --dport 25 -j DROP
/sbin/service iptables save
Để khóa outgoing port 279 đối với IP 10.7.3.5, sử dụng lệnh sau:
 
/sbin/iptables -A OUTPUT -p tcp -d 10.7.3.5 --dport 279 -j DROP
/sbin/service iptables save
Chúc các bạn thành công!

Thứ Sáu, 14 tháng 10, 2016

Backup plesk và restore trên linux, restore sang server mới

1. Backup plesk
đăng nhập plesk với quyền admin
chọn: Tools & settings > Backup manager để tạo backup
sau khi backup xong bạn có thể tải file backup về hoặc vào thư mục lưu file backup để xem.
thư mục lưu file backup: /var/lib/psa/dumps

nếu tải file backup về và đưa sang máy khác khi đó file sẽ ở dạng .tar khi đưa sang server khác bạn phải bung file này ra thư mục /var/lib/psa/dumps. ví dụ backup_info_1610111447.xml.tar

Sau khi bung file backup ra thì vào mục Tools & settings > Backup manager sẽ thấy được file backup.

2. Restore plesk
Thư mục để chạy lệnh restore plesk thường là: /usr/local/psa/bin/pleskrestore
Chạy lệnh sau để restore:

[root@localhost ~]# /usr/local/psa/bin/pleskrestore --restore /var/lib/psa/dumps/backup_file_name.tar -level server

ví dụ: [root@localhost ~]# /usr/local/psa/bin/pleskrestore --restore /var/lib/psa/dumps/backup_info_1610111447.xml.tar -level server

To restore entire server:
pleskrestore restore <backup repository root>/<server>.xml -level server

Note: When the whole server backup is restored, license keys are not restored by default. To restore license keys along with other server content, use the -license option in your restore command.

To restore entire server with license keys:
pleskrestore --restore <backup repository root>/<server>.xml -level server -license


To restore all domains belonging to a reseller:
pleskrestore --restore <backup repository root>/resellers/<reseller ID>/<reseller>.xml -level domains

To restore all reseller accounts:

pleskrestore --restore <backup repository root>/<server>.xml -level resellers

To restore two resellers from a server backup:
pleskrestore --restore <backup repository root>/<server>.xml -level resellers -filter list:JohnDoe,JaneDoe
or

pleskrestore --restore <Upload directory>/<server backup name>.tar -level resellers -filter list:JohnDoe,JaneDoe


To restore two domains owned by Plesk admin:
pleskrestore --restore <backup repository root>/<server>.xml -level domains -filter list:example.com,sample.org


To restore client's several domains defined in a file:

pleskrestore --restore <backup repository root>/resellers/SandyLee/clients/JaneDow/<client>.xml -level domains -filter <path to the file>/restore-domains.txt

MẸO: nếu báo lỗi IP ...
làm như sau vào phần quản trị database https://103.211.212.53:8443/domains/databases/phpMyAdmin/

chọn database "psa" tìm table ip_pool chỉnh sửa Exclusive thành shared

Sau đó restore lại là OK

Thứ Ba, 11 tháng 10, 2016

Cài đặt Plesk trên centos

Để cài đặt Plesk trên linux centos cần đăng nhập với quyền root rồi cài với lệnh sau:

sh <(curl https://installer.plesk.com/one-click-installer || wget -O - https://installer.plesk.com/one-click-installer)

để xem lệnh bạn có thể vào http://page.plesk.com/plesk-free-download-wp để xem chci tiết hơn.

Nếu quá trình bài đặt xảy ra lỗi sau:

"Fatal error during packages installation: Test Transaction Errors: file /etc/httpd/conf.d/fcgid.conf from install of psa-mod_fcgid-2.3.9.1-centos7.14080113.x86_64 conflicts with file from package mod_fcgid-2.3.9-4.el7.x86_64
file /usr/lib/tmpfiles.d/mod_fcgid.conf from install of psa-mod_fcgid-2.3.9.1-centos7.14080113.x86_64 conflicts with file from package mod_fcgid-2.3.9-4.el7.x86_64
file /usr/lib64/httpd/modules/mod_fcgid.so from install of psa-mod_fcgid-2.3.9.1-centos7.14080113.x86_64 conflicts with file from package mod_fcgid-2.3.9-4.el7.x86_64

YumTestTransactionError: Test Transaction Errors: file /etc/httpd/conf.d/fcgid.conf from install of psa-mod_fcgid-2.3.9.1-centos7.14080113.x86_64 conflicts with file from package mod_fcgid-2.3.9-4.el7.x86_64
file /usr/lib/tmpfiles.d/mod_fcgid.conf from install of psa-mod_fcgid-2.3.9.1-centos7.14080113.x86_64 conflicts with file from package mod_fcgid-2.3.9-4.el7.x86_64
file /usr/lib64/httpd/modules/mod_fcgid.so from install of psa-mod_fcgid-2.3.9.1-centos7.14080113.x86_64 conflicts with file from package mod_fcgid-2.3.9-4.el7.x86_64


ERROR: The Yum utility failed to install the required packages.
Attention! Your software might be inoperable.
Please, contact product technical support."

Hãy chạy lệnh sau:

# rpm -e --test mod_fcgid

Nếu không được thì hãy chạy lệnh sau:

# rpm -e mod_fcgid

Sau đó hãy chạy lại lệnh cài đặt Plesk ban đầu.

Sau khi cài xong dùng lệnh sau để kiểm tra xem plesk đã chạy chưa:

# /etc/init.d/psa status

sw-cp-serverd (pid 1192) is running...

Nếu thấy Plesk đang tắt thì dùng lệnh sau để start

# service psa start

Muốn kiểm tra password của plesk admin, hãy chạy lệnh sau:


# plesk bin admin --show-password
hay

# /usr/local/psa/bin/admin --show-password

Sau khi cài xong check plesk running bạn vào: https://ip_cuaban:8443 nếu chạy được tức là đã OK
Nếu chưa chạy được thì bạn kiểm tra có thể firewall chặn. Bạn thử tắt firewall đi với lệnh

Disable Firewalld

systemctl disable firewalld

Stop Firewalld

systemctl stop firewalld

Check the Status of Firewalld

systemctl status firewalld

Enable Firewalld

systemctl enable firewalld

Start Firewalld

systemctl start firewalld

Check the Status of Firewalld

systemctl status firewalld

Nếu do Firewalld chặn thì hãy sử dụng lệnh để mở port 8443 lên.

Thứ Năm, 18 tháng 8, 2016

How to Upload Large Files in PHP

Uploading a file from a web form in PHP is easy. The online manual provides a Handling File Uploads section, and there are several articles on sitepoint.com, including How To Handle File Uploads With PHP by Kevin Yank.

Thứ Bảy, 16 tháng 7, 2016

5 commands to check memory usage on Linux

Memory Usage

On linux, there are commands for almost everything, because the gui might not be always available. When working on servers only shell access is available and everything has to be done from these commands. So today we shall be checking the commands that can be used to check memory usage on a linux system. Memory include RAM and swap.
It is often important to check memory usage and memory used per process on servers so that resources do not fall short and users are able to access the server. For example a website. If you are running a webserver, then the server must have enough memory to serve the visitors to the site. If not, the site would become very slow or even go down when there is a traffic spike, simply because memory would fall short. Its just like what happens on your desktop PC.

1. free command

The free command is the most simple and easy to use command to check memory usage on linux. Here is a quick example
$ free -m
             total       used       free     shared    buffers     cached
Mem:          7976       6459       1517          0        865       2248
-/+ buffers/cache:       3344       4631
Swap:         1951          0       1951

Thứ Sáu, 8 tháng 7, 2016

Tự động restart mysql khi quá tải

Khi quá tải, server sẽ bị đơ, giống như việc máy tính của bạn bị đơ bình thường thôi, để khắc phục hiện tượng này, bạn có thể tạo một file check kiểm tra xem server có quá tải ko, nếu có thì khởi động lại apache. cách làm như sau:
 Bước 1: Tạo file check

Code:
cd /usr/local/
mkdir auto
cd auto
nano -w restart.sh
Dán script sau:
Code:
#!/bin/sh
check=`cat /proc/loadavg | sed 's/\./ /' | awk '{print $1}'`
if [ $check -gt 20 ] //điền 5 cho VPS 512MB Ram, 10 cho 1GB Ram, 20 cho 2GB Ram
then
/etc/init.d/mysqld restart
fi
Lưu lại file, và chmod script về 755
Code:
chmod 755 restart.sh

Bước 2: Tạo file cron
Code:
cd ~
cd /etc/cron.d
nano -w auto_restart
Dán script sau:
Code:
*/5 * * * * root /usr/local/auto/restart.sh >/dev/null 2>&1
Lưu lại file cron để hoàn tất.

Chủ Nhật, 26 tháng 6, 2016

How to change phpMyAdmin post_max_size to more than 2MB

To change the post_max_size in Plesk it is not as simple as changing the /etc/php.ini file entries as there are not active when running phpMyAdmin from within with Plesk Control Panel.

Usually, on a regular *nix installation you would look for these values in /etc/php.ini

phpMyAdmin logoupload_max_filesize
phpMyAdmin logo
What you need to change in fact is this file:

# vi  /usr/local/psa/admin/conf/php.ini

change:

upload_max_filesize = 2147483647
post_max_size = 2147483647
to:

upload_max_filesize = 32M
post_max_size = 32M
This value will now allow phpMyAdmin uploads of files up to 32M is size. Enter your own value here.

Thứ Bảy, 25 tháng 6, 2016

Cách xem password Plesk admin

Symptoms

The password for the "admin" user in Plesk has been lost.

Resolution

For Plesk versions 10.x and above:
Use the ${PRODUCT_ROOT_D}/bin/admin utility to prompt the password for the "admin" user:
# /usr/local/psa/bin/admin --show-password
Use ${PRODUCT_ROOT_D}/bin/init_conf to reset the password for the "admin" user:
# /usr/local/psa/bin/init_conf -u -passwd <new_password>
If the init_conf utility cannot connect to the Plesk database, follow the steps from article #112492 "Cannot log into Plesk due to incorrect admin password" to reset the Plesk database password.
For Plesk versions up to 9.x:
The Plesk admin password is stored in a hidden file on the server. Use this command to get it:
# cat /etc/psa/.psa.shadow
This authenticates the "admin" user by trying to authorize access to the Plesk database using the password provided.

By kb.plesk.com

Thứ Năm, 23 tháng 6, 2016

How to backup and restore linux sever

Backing Up and Restore Your Server
Backup Your Server's OS
Making a backup of your Linux Operating System is a very simple process that uses tools included in every linux installation.

The first step is to create a location to store the backup. For this article we're going to store the backup on the same hard drive as the installed operating system, but you can attach USB devices like thumb drive and external hard drives and even special storage like iSCSI and NFS mounted device to store the backup.

Once you are logged into the server and at a command line make the directory to store the backup in an organized way such as:

mkdir /backups

Now we will create a compressed version of the Operating System in one single file (tarball) using the tar command.

For RedHat, CentOS and Fedora or any Operating System based on these linux flavors run the following command:

tar cvpzf /backups/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/sysconfig/network-scripts/ --exclude=/etc/udev/rules.d/70-persistent-net.rules /

For Debian or Ubuntu run the following command:

tar cvpzf /backups/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/network/interfaces --exclude=/etc/udev/rules.d/70-persistent-net.rules /

Once the command completes the tarball will be located at /backups/backup.tgz

***HINT: You can change the name of the tarball file with a date identifier and keep multiple versions or "snapshots" of your server's configuration.

Restore Your Server's OS From a Backup
In order to restore your server from the previously created tarball the server must have the same Operating System version loaded on it. This particular method of backup and restore is not meant for bare metal projects that need to restore an Operating System to an empty hard drive. It was actually designed to move a configured Operating System from one hardware platform to another, but also works well for rolling back an operating system to a previous configuration.

Once you have a working Operating System either on a new hardware platform or the same hardware platform move the tarball to the server you want to restore. If you stored the tarball on a USB device or other external storage just reattach the device and mount it. If the tarball is on another linux server use commands like this to copy it to the new server’s hard drive:

mkdir /backups
scp root@original_server:/backups/backup.tgz /backups

Of course replace "original_server" with the appropriate IP address.

Enter the root users password and the transfer will begin.

Once the transfer has completed run this command to extract the tarball thereby restoring the Operating System that the tarball contains:

tar xvpfz /backups/backup.tgz -C /

Complete the process with a reboot and troubleshoot any errors that may come up.

cp serverpronto.com

Thứ Ba, 14 tháng 6, 2016

How to install php-xmlrpc on centos - install php-xmlrpc on directadmin

If you want to add any extra modules to php, they'll most likely need to be compiled in. Any module that needs to be compiled in will have a --with-module type flag which will need to be used.

1) To add this flag, run the following:
cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2
cp -fp configure/ap2/configure.php5 custom/ap2/configure.php5

If you're using CustomBuild 2.0, the file might be configure.php55 (where 55 is the php 5.5 version, adjust as needed).
Also, "ap2" applies to mod_php. If you're using suPhp, it's "suphp". Also possible: fpm, fastcgi.
See 4) below, to confirm which configure file to copy to ./custom.

2) Add your --with-module line to the end of the custom/ap2/configure.php5 file, and make sure the \ character exists at the end of all lines except the last one. The \ character tells the line configure line to loop to the next line, making the configure settings easier to read.  Without the \ character to trigger the wrap, the next line becomes a separate command, which is not correct. (see error below). Once set, type:
./build php n
change configure.php5 to configure.php4 if you're using php4.
If you're using suphp, the paths would be configure/suphp/configure.php5 and custom/suphp/configure.php5.

3) Restart apache:

RedHat:
/sbin/service httpd restart

FreeBSD:
/usr/local/etc/rc.d/httpd restart

Please keep in mind that any changes to your stock DirectAdmin setup are beyond our techinal support, and you do so at your own risk.

4) To confirm that you're actually editing the correct configure file, type the following to see which configure files the custombuild script is using:
./build used_configs



A common error people run into looks like this:
/usr/local/directadmin/custombuild/custom/ap2/configure.php5: line 32: --with-module: command not found
which simply means that the \ character was not correctly added on the line before --with-module.

Thứ Sáu, 10 tháng 6, 2016

How to auto start MySQL if that stop for any reason?

Digital Ocean has a tutorial about it, which also includes an example on how to keep MySQL running. The short synopsis is:
  1. Install monit
    sudo apt-get install monit
    
  2. Edit the configuration file:
    sudo nano /etc/monit/monitrc
    
    and include the following in it:
    check process mysqld with pidfile /var/run/mysqld/mysqld.pid
        start program = "/etc/init.d/mysql start"
        stop program = "/etc/init.d/mysql stop"
    
  3. Reload the new configuration:
    monit reload
    
I strongly suggest you look at the MySQL error log to understand why it is stopping (it should not do this in normal operation). It would be a good idea to also run mysqlrepair to check the status of all tables as you might have some serious DB corruption.

Thứ Năm, 9 tháng 6, 2016

How to fix unsupported_db_table_row_format in moodle - Converting InnoDB tables to Barracuda

Here is a Unix "screen-shot":

$ cd /path/to/your/moodle
$ php admin/cli/mysql_compressed_rows.php
Script for detection of row size problems in MySQL InnoDB tables.

By default InnoDB storage table is using legacy Antelope file format
which has major restriction on database row size.
Use this script to detect and fix database tables with potential data
overflow problems.

Options:
-i, --info Show database information
-l, --list List problematic tables
-f, --fix Attempt to fix all tables (requires SUPER privilege)
-s, --showsql Print SQL statements for fixing of tables
-h, --help Print out this help

Thứ Hai, 6 tháng 6, 2016

Cách xem logfile trên centos server

1. Dùng lệnh vào thư mục log

# cd /var/log

2. Hiển thị danh sách file log

# ls

3. Một vài lệnh xem logfile

# less /var/log/messages
# more -f /var/log/messages
# cat /var/log/messages
# tail -f /var/log/messages
# grep -i error /var/log/messages

Cách start-stop mysql server trên centos webserver

Stop MySQL Server

# /etc/init.d/mysqld stop

Start MySQL Server

# /etc/init.d/mysqld start

Restart MySQL Server

# /etc/init.d/mysqld restart

Mong rằng những lệnh này sẽ hữu ích đối với các bạn!

Thứ Tư, 1 tháng 6, 2016

How to fix gmail SMTP debug error please log in via your web browser on phpmailler?


There are two ways to resolve this, and only one may work, depending on how you're accessing Google.

The first method is to authorize access for your IP or client machine using the https://accounts.google.com/DisplayUnlockCaptcha link. That can resolve authentication issues on client devices, like mobile or desktop apps. I would test this first, because it results in a lower overall decrease in account security.

If the above link doesn't work, it's because the session is being initiated by an app or device that is not associated with your particular location. Examples include:

An app that uses a remote server to retrieve data, like a web site or, in my case, other Google servers
A company mail server fetching mail on your behalf
In all such cases you have to use the https://www.google.com/settings/security/lesssecureapps link referenced above.

TLDR; check the captcha link first, and if it doesn't work, try the other one and enable less secure apps.