Category Archives: LINUX

LINUX SERVER PHP configurations.

Yesterday, i finished the whole process to built up a completely new LAMP stacks. After that, i am going to import my test server to my production server.

During this transition, i have to upload my sql database dump from my production server 1 to this new server.

Unfortunately, there is a problem for myself that i left off from yesterday’s process. I did not modify any of the PHP configuration. Therefore, i wasn’t able to upload the sql file which size 14MB.  By default,t he upload single file is only 2MB.

So, today i am going to dig into this php configuration file and do some modifications.

First, i would go to change the file php.ini. You can run following command to edit the php.ini file. (Sometime it’s stored in /etc/php.ini, but it also could be in /etc/php.d/cgi/php.ini or /usr/local/etc/php.ini)

vi /etc/php.ini

Then use the vi ‘s search function to search for below syntax and modify to suit your needs. (type in /strings to find your keyword and use keybaord i to get into insert mode to modify it one by one.)

memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M

here is the search function: i type in /post_max and then hit enter

vi-search

Then, the cursor will jump to the result it found

search-result

After all the modification has been completed, you can do following command to restart the apache

sudo service httpd restart

LINUX(LAMP) stack 安装日记

今天重装了一台服务器的LAMP stack.纯粹做个日记,下次就可以参考参考了。哈哈。

系统:CentOS7 x86_64_1511
console远程登陆软件:Putty
stack选择:LINUX(centos7),Apache,MySQL,PHPD

首先安装好了linux.为了方便查看,装的时候选择了basic web server with GUI的包装。

跳过安装步骤。全部设置好,然后吧不需要的东西先删除掉。比如libreoffice的软件之类。然后确保磁盘空间分配正确。下面开始安装LAMP的网络服务包
为了方便安装,使用了SSH从另外一台电脑链接网络进去进行一下网络服务的安装。
putty

APACHE的安装命令

这个命令是进行Yum的安装包的更新和所有软件的更新

sudo yum update (yum软件包的更新。如果你是类似我一样是新系统,可能会更新一段时间。因为很多包的下载还是蛮多的。我就下载了奖金700多MB的新软件包更新。)
sudo yum install httpd(这个是进行apache的安装。apache的软件包名字就叫做httpd)
sudo systemctl start httpd.service (这个是开始运行apache的服务)
sudo systemctl enable httpd.service(这个是吧apache的服务运行加入启动就自动运行。
这里有一点比较重要的是,我每次进行centos的服务器的LAMP配置都会遇到的。不一定所有人多会有,那就是当我在本地网络的其他电脑的浏览器输入这个centos服务器的网络地址进行访问的时候,正常会显示apache的默认欢迎的网页。可是很多时候都是无法访问的,这个时候就需要进行防火墙的配置了。我在下面进行了防火墙加了两个端口。(我记得之前在做research的时候,有些人建议直接吧防火墙关闭了。虽然这个是本地的服务器和网络,可是安全期间,还是建议不要完全关闭,只要吧你需要的端口打开即可。)

sudo firewall-cmd –permanent –add-port=80/tcp
sudo firewall-cmd –permanent –add-port=443/tcp

以上两个命令在防火墙的命令配置里面增加了80和443的端口。
sudo firewall-cmd –reload
上面这个命令则是进行防火墙的重启。之后再试试看。是不是就可以打开了apache的经典默认欢迎界面了。

apache-default-screen

下面就开始mysql的安装了,这里我用了mariadb的安装包。这是社区开发版的MySQL

sudo yum install mariadb-server mariadb

mariadb

sudo systemctl start mariadb(开启服务)
sudo systemctl enable mariadb.service(开启开机自动启动服务)
sudo mysql_secure_installation(这个命令会进行mysql的初始化设置的一些工作)
mysql-installation
具体安装的设置,都不是那么困难,所以就大概讲一下:

Enter current password for root (enter for none):
OK, successfully used password, moving on…

第一个问题是问你当前的root密码。因为是首次安装,自然是没有面。直接回车跳过。
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!

然后问你要不要进行密码设置,输入y然后进行密码设置
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
… Success!

上面这一段话是说,默认情况下mariadb有匿名用户账户。这可以让任何人都进去却不需要创建账户。然后问你是否要删除掉匿名用户权限。当然就是回答y了!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
… skipping.

正常情况,root只可以从本地访问。这可以杜绝别人从网络访问去猜测root的密码。是否拒绝root的远程登陆。因为我经常要从本地和远程登陆进行管理。所以我会回答n 给这个问题。

By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!

默认情况下,mariaDB自带了一个叫做test的数据库,这个是完全拿来做测试用的blah blah.我直接回答y去吧这个数据库给删除掉了。

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

要不要重置所有权限,这样之前所做的所有改动就会立即生效。直接回答y就好了。

接下来就开始安装PHP了。
sudo yum install php php-mysql

yum-install-php

sudo systemctl restart httpd.service (重启apache的服务)

最后,做一个简单的php的探针的编写进行测试:

sudo vim /var/www/html/info.php

输入以下内容:

<?php

phpinfo();

?>
接着,用浏览器打开http://主机ip地址/info.php如果可以看到一下界面就完全成功了!

php-info

Last but not the least is to install phpmyadmin. This is a very useful tool with GUI to manage the MySQL database on the centos7 server.
Now, run the following commands:

sudo yum install php-gd php-pear (Install two very important php related packages.)
sudo yum install epel-release-7-1.noarch.rpm (This is to add the epel release package to the repo.)
sudo yum install epel-release (install and update the epel release package lists)
sudo yum install phpmyadmin (Install the phpmyadmin)

After that, if you go ahead and access http://ipaddress/phpmyadmin you should see something different message other than the 404 now.

Unfortunately, you still cant access phpmyadmin yet. Now, you need to change the file

vi /etc/httpd/conf.d/phpMyAdmin.conf
Below is the file what it looks like the first time you open it.

# phpMyAdmin - Web based MySQL browser written in php
# 
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>

Modify and add below items to. Check out the bold text carefully.

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       #ADD following line:
       Require all granted
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     #CHANGE following 2 lines:
     Order Allow,Deny
     Allow from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

After i did the above two changes, i would do a httpd restart service again.

sudo systemctl restart httpd.service

Boom! PHPMYADMIN!~ YAHOO~

phpmyadmin

Ubuntu 15.10 with Broadcom wireless.

Somehow i always struggling with the broadcom wireless that i have. This is just coincidence that even after two LAPTOP i have changed, both them came with Broadcom wireless module.

The current laptop i have is a Lenovo Z500. Which equiped with Intel core i5 4200M/8GB RAM/120GBSSD/1THDD. Nowaday, you can get a 6th gen core i laptop with something around $600. Though my laptop still runs pretty fast compare to the 6th gen core i gadgets.

This is really off topic. Now today, my problem is to go through the bottleneck of no drivers exsisting in my laptop with my Ubuntu 15.10 to support.

There is a couple simple command i ran to check whats really going on with my wireless.

First, i kicked off with following command to see the result of what network card avaliable. (wireless modules.)

lspci -vnn | grep Network

Then i get the result as below:

02:00.0 Network controller [0280]: Broadcom Corporation BCM43142 802.11b/g/n [14e4:4365] (rev 01)

Noted, above information is very important. In this case, it tells me the correct model and firmware that i have for my broadcom wireless module.

Then, here is the useful command for linux to configue wireless network.

iwconfig

lo no wireless extensions.

enp1s0 no wireless extensions.

The second line could be something similar but it could be different too… (I know some of my co-league would get eth0 for their module.)

Now, we are done with playing around and determining our wireless hardware. Let’s starting with the solutions to fix the wirless driver issue.

Remember the information we get above? The [14e4:4365] (rev 01) is something we would need to deceided which broadcome wireless module firmware we would need for installing with to support the wireless function.

02:00.0 Network controller [0280]: Broadcom Corporation BCM43142 802.11b/g/n [14e4:4365] (rev 01)

Now, lets update the source list with:

sudo apt-get update

Then, we can also updat the ubuntu PCI iDs:

sudo update-pciids

Then below steps by step to install:

sudo apt-get install bcmwl-kernel-source

sudo reboot

Please follow below table to select the correct packages to install from.

PCI.ID 14.04 LTS 15.10+
————————————————————————————
14e4:0576 Special Case #1 UNKNOWN
14e4:4301 firmware-b43-installer firmware-b43-installer
14e4:4306 firmware-b43-installer firmware-b43-installer
14e4:4306 rev 02 firmware-b43-installer firmware-b43-installer
14e4:4306 rev 03 firmware-b43-installer firmware-b43-installer
14e4:4307 firmware-b43-installer firmware-b43-installer
14e4:4311 firmware-b43-installer firmware-b43-installer
14e4:4312 firmware-b43-installer firmware-b43-installer
14e4:4313 firmware-b43-installer firmware-b43-installer
14e4:4315 firmware-b43-installer firmware-b43-installer
14e4:4315 rev 01 firmware-b43-installer / Case #2 UNKNOWN
14e4:4318 firmware-b43-installer firmware-b43-installer
14e4:4318 rev 02 firmware-b43-installer firmware-b43-installer
14e4:4319 firmware-b43-installer firmware-b43-installer
14e4:4320 rev 02 firmware-b43-installer firmware-b43-installer
14e4:4320 rev 03 firmware-b43-installer firmware-b43-installer
14e4:4324 firmware-b43-installer firmware-b43-installer
14e4:4325 firmware-b43-installer firmware-b43-installer
14e4:4328 firmware-b43-installer firmware-b43-installer
14e4:4329 bcmwl-kernel-source bcmwl-kernel-source
14e4:432a bcmwl-kernel-source bcmwl-kernel-source
14e4:432b bcmwl-kernel-source bcmwl-kernel-source
14e4:432c bcmwl-kernel-source bcmwl-kernel-source
14e4:432d bcmwl-kernel-source bcmwl-kernel-source
14e4:4331 firmware-b43-installer firmware-b43-installer
14e4:4335 firmware-b43-installer firmware-b43-installer
14e4:4353 Special Case #1 UNKNOWN
14e4:4353 rev 01 Special Case #1 UNKNOWN
14e4:4357 Special Case #1 UNKNOWN
14e4:4358 bcmwl-kernel-source bcmwl-kernel-source
14e4:4359 bcmwl-kernel-source bcmwl-kernel-source
14e4:4365 bcmwl-kernel-source bcmwl-kernel-source
14e4:4365 rev 01 bcmwl-kernel-source bcmwl-kernel-source
14e4:43a0 bcmwl-kernel-source bcmwl-kernel-source
14e4:43b1 bcmwl-kernel-source bcmwl-kernel-source
14e4:43b1 rev 03 bcmwl-kernel-source bcmwl-kernel-source
14e4:4727 bcmwl-kernel-source bcmwl-kernel-source
14e4:4727 rev 01 bcmwl-kernel-source bcmwl-kernel-source
14e4:a962 firmware-b43-installer firmware-b43-installer

After that the system reboots and hoepfully your wireless card will come up like mine. Otherwise, you can also try below:

sudo modprobe -r b43

sudo modprobe b43

sudo rfkill unblock all

if you have successfully installed the driver, You will happy to see below screens.

2015-12-18 17-34-21屏幕截图2015-12-18 17-42-20屏幕截图

 

 

 

 

Ubuntu stress test.

Command to install:

sudo apt-get install stress

Testing, sameple command:

stress -c 4 -m 5 -d 1
(Explaination:, -c means cpu cores number count that will under stress test. -m means how many memory threads are going to under stress test, -d HDD numbers.)

System configurations:

Intel core i3 2330E/8GB ram/80GB HDD

Tested with above and “stress -c 4 -m 20 -d 1”. Then tried adjusted -m to -m 40 and system crashed and hanged up.

 

Pfft, nice try.

Get my logitech unify receiver and keyboard / Mouse to work with my Ubuntu.

So, i reinstall my ubuntu and decided to go with a somewhat new distribution called Elementary OS. Everything works fine except that my Logitech Mouse is not working. It kinds of feel like the mouse is not pair with my Unify receiver.Here is the solution i found and seemd to work like a charm.

First thing first, get your terminal window out and throw in the below codes:
sudo apt-get install git gcc
git clone https://git.lekensteyn.nl/ltunify.git
cd ltunify
make install-home

Screenshot from 2015-02-19 11:43:22

  After that, you should be able to find your ltunify in $Home/bin/ltunify. Next thingyou need to do is redirect to this folder and run:
   ./ltunify pair
  The program will probably ask you to turn on and off of your mouse to pair with your Logitech USB receiver.
  After that, start enjoy your logitech and ubuntu!
  I found it also useful by installing a graphic UI program to manage your unify receiver. This App is call "Solaar".
  Go to your software center. (You can just click the left corner and type in "software" to search for software center.)
  After you launch the software center APP, click on the "Edit" and select "software source". Navigate to "Other software". Click on "Add..." button, then add following ppa:daniel.pavel/solaar
  After doing so, you will need to go to your terminal window and do a "sudo apt-get update". Then you can just type in command "sudo apt-get install solaar".
  Once everything is done. you will be able to search for your "solaar" in your application menu.
  This program will provide you some possible features provided by your unify receiveras well as the mouse battery level. (This could come in handy if you need to know if you possibly need to change your battery soon or if it still can last a while.)

   software sourcesadd software sources

dd (linux) for cloning a new HDD images.

So, just want to make a post and do some notes about a clone HDD images tha ti have been trying to do for a LINUX live that i have for a while.

It’s basically a LINUX live that i ran from a USB drive. I need it to perform some .sh script files and such to process some heavily network traffic and so to meter the LAN port’s healthy status.

Here is the problem, i have this fedora live originally installed to this USB drive for less than 1 GB. After time to time use and some more scripts file written to this USB drive, it has been now growth to gigantic 8GB USB DRIVE!. Although most of fthe files on the USB drive still only occupy the 2GB space. Now, i need to mass reproduced this USB drive to , let’s say 10 more copies. One simple methods that i have been trying to accomplished so far is by copy itself to another same 8GB USB drives. But i have those 4GB USB laying around with no absolutely no use at all. I really and likes to copy the original USB drive to those 4GB drive so i can save some money on buying more bigger size and perhaps more expensive gadgets.

I really want to use dd command which is a powerful yet strong enough to help me finish this target.

First of all, i would like to expertment a little bit and get a little bit of idea about the original USB drive.

By do so, i would need to run comamnd:
sudo fdisk -u -l /dev/sdb
(-u ->this extension would make all bytes in the times of 512 bytes, which  a sector block size. )

This command would allow me to check the layout and size of the USB drive. It could be something similar like below:
/dev/sdb1 5GB
/dev/sdb2 1GB ext
/dev/sdb5 1GB ext

Then we can use the following dd command to make the images:

dd bs=512 count=[max number of “end” result in fdisk command out put] if=/dev/sdb of=image.img

The fdisk command in Linux will identify and calculate the actual size and what ever that partition has been using regardless of it’s types. It wouldn’t matter if it’s a NTFS/FAT32 or even a EXT4 file system.

Above are all practice notes and study plan for cloning a hdd image.