短地址服務(wù)yourls的配置使用
yourls 是開源的PHP 項(xiàng)目,所以使用yourls 先要進(jìn)行PHP 運(yùn)行環(huán)境的配置,這個(gè)可以自己百度下,網(wǎng)上資料很多,LAMP 的環(huán)境裝好之后,就可以進(jìn)行yourls 的使用配置。1.yourl
yourls 是開源的PHP 項(xiàng)目,所以使用yourls 先要進(jìn)行PHP 運(yùn)行環(huán)境的配置,這個(gè)可以自己百度下,網(wǎng)上資料很多,LAMP 的環(huán)境裝好之后,就可以進(jìn)行yourls 的使用配置。
1.yourls 要用到數(shù)據(jù)庫,在MySQL 中為其穿件一個(gè)數(shù)據(jù)庫,假設(shè)名字取為yourls
2. 將yourls 項(xiàng)目放到Apache 的項(xiàng)目目錄下,一般為/var/www/html下,如果自己做了修改,根據(jù)自己的修改而定。
3. 進(jìn)行Apache 的Rewrite 功能的配置
(1)去除Apache 的配置文件httpd.conf 文件中"#LoadModule rewrite_module
modules/mod_rewrite.so"前面的"#"號; 如果沒有則添上這句話
(2)修改httpd.conf 文件中的"AllowOverride None"為"AllowOverride all",同時(shí)最好將Options 也置為"all", 否則可能會出問題。
(3)在配置的項(xiàng)目目錄中(例如上面的為/var/www/html即yourls 的同級目錄中)建立.htaccess 文件,并打開按如下方法編輯內(nèi)容
根據(jù)yourls 官網(wǎng)的內(nèi)容,內(nèi)容如下
如果配置在根目錄,如http://yoursite/,則內(nèi)容如下
# BEGIN YOURLS
RewriteEngine On
RewriteBase /
RewriteCond {REQUEST_FILENAME} !-f
RewriteCond {REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
# END YOURLS
如果配置在子目錄中,如http://yoursite/somedir/,內(nèi)容如下
# BEGIN YOURLS
RewriteEngine On
RewriteBase /somedir/
RewriteCond {REQUEST_FILENAME} !-f
RewriteCond {REQUEST_FILENAME} !-d
RewriteRule ^.*$ /somedir/yourls-loader.php [L]
# END YOURLS
4. 進(jìn)入yourls/user里面,將config-sample.php 改名為config.php, 打開此文件進(jìn)行配置
/** MySQL database username */
define('YOURLS_DB_USER', 'dbuser');// MySQL 數(shù)據(jù)庫用戶名
/** MySQL database password */
define('YOURLS_DB_PASS', 'dbpassword');// MySQL 數(shù)據(jù)庫密碼
,/** The name of the database for YOURLS */
define('YOURLS_DB_NAME', 'yourls');// MySQL 為yourls 配置給他用的數(shù)據(jù)庫名稱
/** MySQL hostname */
define('YOURLS_DB_HOST', 'localhost');
// MySQL 數(shù)據(jù)庫所在主機(jī),99情況不用修改,000webhost 等空間需要修改。
/** MySQL tables prefix */
define('YOURLS_DB_PREFIX', 'yourls_');
/**創(chuàng)建的 Yourls 的表的名字,同一個(gè)數(shù)據(jù)庫放多個(gè) Yourls 程序時(shí)需要修改。*/
/** YOURLS installation URL, no trailing slash */
define('YOURLS_SITE', 'http://site.com'); //站點(diǎn)域名
/** Timezone GMT offset */
define('YOURLS_HOURS_OFFSET', 0); //時(shí)區(qū)修改,基本沒必要
/** Allow multiple short URLs for a same long URL
** Set to true to have only one pair of shortURL/longURL (default YOURLS behavior) ** Set to false to allow multiple short URLs pointing to the same long URL (bit.ly behavior) */
define('YOURLS_UNIQUE_URLS', true);
//只允許一個(gè)要被縮短網(wǎng)址對應(yīng)一個(gè)短網(wǎng)址,若允許對應(yīng)多個(gè)短網(wǎng)址寫false
/** Private means protected with login/pass as defined below. Set to false for public usage. */ define('YOURLS_PRIVATE', true);//私人用還是公開用,公開的話寫false
/** A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: copy from
define('YOURLS_COOKIEKEY', 'qQ4KhL_pu|s@Zm7n#:b^{A[vhm');
//訪問 http://yourls.org/cookiekey.php 取得一個(gè)唯一的 Key 并且修改填入
/** Username(s) and password(s) allowed to access the site */
$yourls_user_passwords = array(
'username' => 'password',
'username2' => 'password2' // You can have one or more 'login'=>'password' lines
);/**username管理員用戶名和password 密碼,默認(rèn)兩組,可刪除一組或增加N 組 */
$yourls_reserved_URL = array(
'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', 'gay',
);/** 保留詞語,建議增加proxy 等詞。*/
,到此你的yourls 配置完畢,service httpd start啟動你的Apache 服務(wù)器。訪問http://site.com/admin/install.php 其中yoursite.com 就是你在define('YOURLS_SITE', 'http://site.com'); 中配置的站點(diǎn)名稱。
登錄賬號和密碼也是你在上面自己配置的賬號和密碼。
進(jìn)去之后就可以使用了