Kategori arşivi: Genel

npm vs bower vs composer

npm is nodejs package manager. It therefore targets nodejs environments, which usually means server-side nodejs projects or command-line projects (bower itself is a npm package). If you are going to do anything with nodejs, then you are going to use npm.

bower is a package manager that aims at (front-end) web projects. You need npm and nodejs to install bower and to execute it, though bower packages are not meant specifically for nodejs, but rather for the “browser” environment.

composer is a dependency manager that targets php projects. If you are doing something with symfony (or plain old php), this is likely the way to go

Summing it up:

  • doing node? you do npm
  • doing php? try composer
  • front-end javascript? try bower

And yes, the “json” files describe basic package information and dependencies. And yes, they are needed.

Now, what about the READMEs? 🙂

Pure CentOS LAMP

APACHE

  1. yum install httpd mod_ssl
  2. /usr/sbin/apachectl start
  3. nano /etc/httpd/conf/httpd.conf
  4. #ServerName www.example.com:80 -> ServerName sXX.domain.com
  5. /usr/sbin/apachectl restart
  6. OPTIONAL ->
    1. iptables -I INPUT -p tcp –dport 80 -j ACCEPT
    2. service iptables save
  7. Test IP http
  8. For OS run on restart:
    /sbin/chkconfig httpd on
  9. Test run on restart:
    sudo /sbin/chkconfig –list httpd

PHP

  1. yum install php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml
  2. /usr/sbin/apachectl restart

MYSQL

  1. yum install mysql-server
  2. service mysqld start
  3. Start on boot:
    /sbin/chkconfig –levels 235 mysqld on
  4. mysql_secure_installation

apache maintanance 2

The Apache Web server is well equipped to run production level websites and web services. A production setup sometimes has scheduled downtimes. There are a number of ways to handle a maintenance downtime. You can either handle it inside of your web application by adding a page and directing all traffic to that page, or you can set up your web server in a sort of maintenance mode. In the maintenance mode, Apache will automatically direct all traffic to a maintenance page that you can set up. Let’s take a look at how this can be set up.

Enable .htaccess

There are two ways to make changes to your Apache configuration – editing the Apache configuration directly, or using .htaccess files and storing the configuration along with the website’s files. If you are hosted on a shared hosting platform, it is quite likely that the setup required to permit .htaccess files to function as desired has been done. If you are on a dedicated server, open the Apache configuration file httpd.conf in a text editor and look for a section containing the word AllowOverride. Make sure that this is set to allow all over rides by setting it toAllowOverride All. Now you should be able to use .htaccess files.

Create the Maintenance page

Next up you need to create a maintenance page that you will direct all the traffic to during maintenance periods. You can make it so that it simply says “Site Down for Maintenance. We’ll be Back Soon.” or you can create something more elaborate with images. I’ll leave the decision on how you want to create this page to you. We can proceed with the assumption that a page called maintenance.html has been created with the maintenance notice.

Enable Mod Rewrite

We have covered the setup and usage of the Apache module mod_rewrite in a previous article. Use the article to set up mod_rewrite. If you are not certain if mod_rewrite has been set up on your server, you can use an example from the linked article to test your setup. Note that the maintenance page redirection will not work correctly without a functional mod_rewrite setup.

Creating the .htaccess File

You can now set up the forwarding to the maintenance page. Create a file with the name .htaccess in the root directly of your website or web application. Enter the following bit of code into the file. Replacemaintenance.html with the name of your maintenance file.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteRule $ /maintenance.html [R=302,L] 

Testing the Setup

Now that your setup is in place it’s time to run a test to make sure things are working as desired. Fire up your favorite web browser, clear the browser’s cache and history files, and then hit the URL of the site you just set to maintenance mode. You should be automatically redirected to the maintenance page. If not, revisit the set up instructions.

Getting out of Maintenance

When you are done with your site upgrade or maintenance work you should remember to roll back the changes we made here. For that all you need to do is to remove the code we added to the .htaccess file. Remove the code and test it in your web browser after clearing the cache files again.

IP Exceptions

If you are running an upgrade on your website, you will need to be able to look at and test out the site. There is a way by which you can post the maintenance notice for anyone hitting your websites but allow you to view the site as you would normally. For this, you will require a static public IP address. Add the following line to your.htaccess configuration:

RewriteCond %{REMOTE_HOST} !^117\.201\.1\.154

Replace 117\.201\.1\.154 with your IP address. Your code will now look something like this:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_HOST} !^117\.201\.1\.154
RewriteRule $ /maintenance.html [R=302,L] 

Now launch the site in your web browser and you should see the site normally, while everyone else will be redirected to the maintenance page. Do remember to remove these settings once you are done with your maintenance work or upgrades.

ProFTPD Ubuntu 14.04 LTS install

  1. apt-get update
  2. apt-get -y install proftpd
    ->standalone, ok
  3. nano /etc/proftpd/proftpd.conf
    1. ServerName “s1.servername.com”
    2. uncomment #DefaultRoot ~
  4. service proftpd restart
  5. update-rc.d proftpd defaults
    (add to system reboot)
  6. Add users to system
    1. Make users home to their web site document root
    2. Give them username and password
    3. add user to www-data group
      usermod -a -G www-data username

Install Java 1.8 on Ubuntu 14.04 LTS

Source: http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux

  1. Download the Oracle Java JDK/JRE for Linux to your home directory eg (/home/somebody/java/jre-8u40-linux-x64.gz) (DOWNLOAD: http://www.oracle.com/technetwork/java/javase/downloads/index.html):
  2. Check if you have Java installed on your system:
    java -version
  3. Copy the Oracle Java binaries into the /usr/local/java directory
    First: cd ~
    JDK: sudo cp --parents java/jdk-8u40-linux-x64.gz /usr/local
    JRE: sudo cp –parents java/jre-8u40-linux-x64.gz /usr/local
  4. Unpack the compressed Java binaries:
    First: cd /usr/local/java
    JDK: sudo tar xvzf jdk-8u40-linux-x64.gz
    JRE: sudo tar xvzf jre-8u40-linux-x64.gz
  5. Edit the system PATH file /etc/profile and add the following system variables to your system path:
    First: sudo nano /etc/profile

    • If you are installing the JDK then Type/Copy/Paste:
      JAVA_HOME=/usr/local/java/jdk1.8.0_40
      JRE_HOME=$JAVA_HOME/jre
      PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
      export JAVA_HOME
      export JRE_HOME
      export PATH
    • Or if you are installing the JRE then Type/Copy/Paste:
      JRE_HOME=/usr/local/java/jre1.8.0_40
      PATH=$PATH:$JRE_HOME/bin
      export JRE_HOME
      export PATH

    Save the /etc/profile file and exit

  6. Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located:
    • If you are installing the JDK then Type/Copy/Paste: sudo update-alternatives –install “/usr/bin/java” “java” “/usr/local/java/jdk1.8.0_40/jre/bin/java” 1
    • Or if you are installing the JRE then Type/Copy/Paste: sudo update-alternatives –install “/usr/bin/java” “java” “/usr/local/java/jre1.8.0_40/bin/java” 1
      • this command notifies the system that Oracle Java JRE is available for use
    • Only if you are installing the JDK then Type/Copy/Paste: sudo update-alternatives –install “/usr/bin/javac” “javac” “/usr/local/java/jdk1.8.0_40/bin/javac” 1
      • this command notifies the system that Oracle Java JDK is available for use
  7. Inform your Ubuntu Linux system that Oracle Java JDK/JRE must be the default Java:
    • If you are installing the JDK then Type/Copy/Paste: sudo update-alternatives –set java /usr/local/java/jdk1.8.0_40/jre/bin/java
    • Or if you are installing only the JRE then Type/Copy/Paste: sudo update-alternatives –set java /usr/local/java/jre1.8.0_40/bin/java
      • this command will set the java runtime environment for the system
    • If you are installing only the JDK then Type/Copy/Paste: sudo update-alternatives –set javac /usr/local/java/jdk1.8.0_40/bin/javac
      • this command will set the javac compiler for the system
    • If you are installing the JDK then Type/Copy/Paste: sudo update-alternatives –set javaws /usr/local/java/jdk1.8.0_40/bin/javaws
    • Or if you are installing the JRE then Type/Copy/Paste: sudo update-alternatives –set javaws /usr/local/java/jre1.8.0_40/bin/javaws
      • this command will set Java Web start for the system
  8. Reload your system wide PATH /etc/profile by typing the following command:
    . /etc/profile
  9. Test to see if Oracle Java was installed correctly on your system:
    java -version
    javac -version
  10. reboot