Tampilkan postingan dengan label linux. Tampilkan semua postingan
Tampilkan postingan dengan label linux. Tampilkan semua postingan

Rabu, 17 Agustus 2016

Redirect using .htaccess


Redirect include subfolder

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^layanankilat\.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www\.layanankilat\.com$
  RewriteRule (.*)$ http://prosides.magelangsoft.com/$1 [R=301,L]
</IfModule>
Redirect without subfolder

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^situsdesa\.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www\.situsdesa\.com$
  RewriteRule (.*)$ http://www.zheol.com/ [R=301,L]
</IfModule>
Redirect to root folder

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^.+$ / [R=301,NC,L]
</IfModule>



# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Redirect non to https


RewriteCond %{HTTP_HOST} ^pastioke\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://pastioke.com/$1 [R,L]


sumber : cholar.com/blog/redirect-an-old-domain-to-a-new-domain-with-htaccess/

Selasa, 15 Desember 2015

Proftpd

Install Proftp server
# opkg install proftpd
Edit /etc/proftpd.conf
# vi /etc/proftpd.conf
ServerName "ProFTPD Server" ServerIdent on "FTP Server ready." ServerType standalone DefaultServer on DefaultAddress 127.0.0.1 RequireValidShell off Port 21 UseIPv6 off Umask 022 MaxInstances 10 User nobody Group nogroup AuthUserFile /etc/passwd DefaultRoot /home AllowOverwrite on MaxClients 10 MaxClientsPerHost 10 MaxClientsPerUser 10 MaxHostsPerUser 10 DeleteAbortedStores on UserAlias anonymous ftp
Adding new user for ftp account by editing /etc/passwd, in my case i added user openwrt, copy paste configuration from user ftp, but change user ID number and group name.
# vi /etc/passwd-
root:$1$nvFplbd8$l05HR0mdTHcGprNaMg8QA1:0:0:root:/root:/bin/ash daemon:*:1:1:daemon:/var:/bin/false ftp:*:55:55:ftp:/home/ftp:/bin/false network:*:101:101:network:/var:/bin/false nobody:*:65534:65534:nobody:/var:/bin/false openwrt:*:65538:55:openwrt:/home:/bin/false

Adding password for user openwrt
# passwd openwrt
Change Otority
chmod o-rwx /etc/passwd
chmod o-rwx /etc/passwd-
chmod 777 /home
Enabling proftpd service upon start
# /etc/init.d/proftpd enable
To start proftpd service
# /etc/init.d/proftpd start
To stop proftpd service
# /etc/init.d/proftpd stop
Now start proftpd for debug and access it using ftp client and see if any errors
# proftpd -n -d 10
If everything ok, you should see something similar with this picture when accessing proftpd server

tutorial belong to : http://diantokam.blogspot.co.id/2012/11/openwrt-proftp-server.html

Kamis, 05 Februari 2015

Exroot OpenWRT on 3020

BESURE THAT FLASHDISK HAS BEEN Formatted
--------------------------------------------------UPDATE
opkg update
opkg install kmod-usb-storage kmod-fs-ext4 block-mount
-----------------------------------------------------MASUKKAN USB
ls /dev/
mkdir -p /mnt/sda2
mount /dev/sda2 /mnt/sda2
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/sda2 -xf -
umount /tmp/cproot
umount /mnt/sda2

-----------------------------------------------------EDIT FSTAB
vi /etc/config/fstab

config global automount
        option from_fstab 1
        option anon_mount 1

config global autoswap
        option from_fstab 1
        option anon_swap 0

config mount
        option target /
        option device /dev/sda2
        option options rw,sync
        option fstype ext4
        option enabled 1
        option enabled_fsck 0


config swap
        option device /dev/sda3
        option enabled 1


----------------------------------------------------CEK
/etc/init.d/fstab enable
/etc/init.d/fstab start
reboot
mount
df
-----------------------------------------------------INSTALL DRIVER NTFS
opkg update
opkg install kmod-fs-ntfs ntfs-3g
-----------------------------------------------------RE-EDIT FSTAB
vi /etc/config/fstab

config global automount
        option from_fstab 1
        option anon_mount 1

config global autoswap
        option from_fstab 1
        option anon_swap 0

config mount
        option target /
        option device /dev/sda2
        option options rw,sync
        option fstype ext4
        option enabled 1
        option enabled_fsck 0


config swap
        option device /dev/sda3
        option enabled 1
----------------------------------------------------REBOOT
reboot
mount
df

-----------------------------------------------------INSTALL DRIVER MODEM
opkg update
opkg install kmod-ath9k-htc kmod-carl9170 kmod-rtl8187

Sabtu, 25 Oktober 2014

Give Apache Own User

CENTOS
--------------------------------------------------------------------------------------
Add a user (who isn’t root)
Add a new user to the wheel and apache groups. The wheel group gives root/sudo access. The apache group allows both user and apache to write to your website files. The -G tells useradd we want to add to multiple groups. Sam is the username in this example.
useradd -G wheel,apache us3r
passwd us3r
Set directory and file permissions
Make apache the owner of /var/www. The -R makes the ownership changes recursive (apply to all files and directories within /var/www.
The syntax here is user:group. All users automatically have a group of the same name (e.g. user sam has a group called sam).
chown -R apache:apache /var/www
Change the permissions to give the owner (apache) and members of the apache group write permission (775).
find /var/www/ -type f -exec chmod 664 {} \;
find /var/www/ -type d -exec chmod 775 {} \;
Now resecure /var/www by giving it back to root or the user you created earlier.
chown root:root /var/www
View/confirm directory ownership/permissions with the ls -lcommand.
ls -l /var
ls -l /var/www
If you prefer editing long config files via S/FTP in a desktop text editor like Coda, take ownership of the following.
chown sam:sam /etc/php.ini 
chown sam:sam /etc/my.cnf 
chown -R sam:sam /etc/php.d
chown -R sam:sam /etc/httpd
Give your new user root privileges
Start by using a special text editor visudo by issuing the following command.
visduo
Enable the wheel group by uncommenting the following line like so.
## Allows people in group wheel to run all commands
%wheel        ALL=(ALL)       ALL
Alternatively, uncomment the next line to enable the wheel group and allow these user to become root without having to renenter their password.
## Same thing without a password
%wheel        ALL=(ALL)       NOPASSWD: ALL
Now logout of your SSH session, then test logging in as the new user.
logout
ssh sam@YOUR_IP_HERE
Test that the new user can become root.
sudo su -
The # should change to & and the user should show root@YOUR_HOSTNAME. Now logout of root to get back to your user.
logout
For reference, you can also execute single line commands as root by prefixing with sudo e.g.
sudo visudo

source http://whatsamknows.tumblr.com/post/40245741052/centos-lamp-permissions


Kamis, 28 November 2013

linux command

delete directory
rm -rf letters/
Add User 
useradd -u <username> -p <password> -d <directory>
Change Port
vi /etc/ssh/sshd_config
Change Port
vi /etc/ssh/sshd_config
# Run ssh on a non-standard port:
Port 2345  #Change me
service sshd restart
List All User
cat /etc/passwd
Archieve
zip -r filename.zip files

Compress an Entire Directory or a Single File

tar -czvf archive.tar.gz /path/to/directory-or-file
or
tar -czvf archive.tar.gz /home/ubuntu/Downloads /usr/local/stuff /home/ubuntu/Documents/notes.txt

Extract an Archive

tar -xzvf archive.tar.gz

Find / Search File Recursive

find -name *tgz




source : http://www.howtogeek.com/248780/how-to-compress-and-extract-files-using-the-tar-command-on-linux/

Kamis, 25 Juli 2013

Optimize Apache and Mysql

source belong to http://tanmoy.me/vps/mysql-apache-optimization-on-kloxo/Set Timeout value from 120 to 40.
Timeout 40
Save pressing Crtl + X, then Y and vice versa.
MySQL Optimization:
Too simple, type
nano /etc/my.cnf
And add two lines bellow [mysqld], and it’ll look like bellow.
[mysqld]
skip-innodb
skip-bdb
Okay, save now.
Final Step:
Now you have to restart Apache and MySQL.
For Apache:
/etc/init.d/httpd restart
For MySQL:
/etc/init.d/mysqld restart
Now Check Memory :)
free -m

Apache Optimize
vi /etc/httpd/conf/httpd.conf

Find out the lines like bellow and replace the values.
StartServers       3
MinSpareServers    3
MaxSpareServers   10
ServerLimit      50
MaxClients       50
MaxRequestsPerChild  2000

Turn Keepalive off.
KeepAlive  off